[Patchew-devel] [PATCH] patchew-cli: tester: add subcommand to print capabilities of the current host

Paolo Bonzini pbonzini at redhat.com
Sat Aug 18 08:29:46 UTC 2018


This can be useful for debugging.

Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
---
 patchew-cli           | 16 +++++++++++++---
 tests/test_testing.py |  8 ++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/patchew-cli b/patchew-cli
index f4539a7..c67abd5 100755
--- a/patchew-cli
+++ b/patchew-cli
@@ -446,6 +446,8 @@ class TesterCommand(SubCommand):
     want_argv = True
 
     def arguments(self, parser):
+        parser.add_argument("--print-capabilities", action="store_true",
+                            help="print capabilities for the current machine")
         parser.add_argument("--singleton", "-S", action="store_true",
                             help="quit if another singleton mode tester is running")
         parser.add_argument("--project", "-p", required=True,
@@ -591,14 +593,22 @@ class TesterCommand(SubCommand):
 
     def do(self, args, argv):
         # Make sure git works
+        projects = [x.strip() for x in args.project.split(",") if len(x.strip())]
+        if not projects:
+            raise Exception("No project specified")
+        if args.print_capabilities:
+            if len(projects) > 1:
+                print("Only one project is allowed for --print-capabilities")
+                return 1
+            caps = self._refresh_capabilities(projects[0], args.name)
+            for i in caps:
+                print(i)
+            return 0
         if args.singleton:
             self._check_singleton()
         subprocess.check_output(["git", "version"])
         count = 0
         cap_refresh = 10
-        projects = [x.strip() for x in args.project.split(",") if len(x.strip())]
-        if not projects:
-            raise Exception("No project specified")
         capabilities = {}
         while True:
             progress = False
diff --git a/tests/test_testing.py b/tests/test_testing.py
index 5b6420a..c9452a4 100755
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -242,6 +242,14 @@ class TesterTest(PatchewTestCase):
                                        cwd=self.repo).decode()
         p.set_property("git.head", head)
 
+    def test_print_capability(self):
+        self.cli_login()
+        out, err = self.check_cli(["tester", "-p", "ALLOW", "--print-capabilities"])
+        self.assertEqual(out, 'allow')
+        out, err = self.check_cli(["tester", "-p", "DENY", "--print-capabilities"])
+        self.assertEqual(out, '')
+        self.cli_logout()
+
     def test_tester(self):
         self.cli_login()
         out, err = self.check_cli(["tester", "-p", "QEMU,UMEQ,ALLOW,DENY",
-- 
2.17.1




More information about the Patchew-devel mailing list