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

Paolo Bonzini posted 1 patch 16 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180818083145.16505-1-pbonzini@redhat.com
patchew-cli           | 16 +++++++++++++---
tests/test_testing.py |  8 ++++++++
2 files changed, 21 insertions(+), 3 deletions(-)

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

Posted by Paolo Bonzini 16 weeks ago
This can be useful for debugging.

Signed-off-by: Paolo Bonzini <pbonzini@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 1284498..93aaf8b 100755
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -237,6 +237,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

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel

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

Posted by Fam Zheng 15 weeks ago
On Sat, 08/18 10:31, Paolo Bonzini wrote:
> This can be useful for debugging.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Fam Zheng <famz@redhat.com>

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel