]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
wic: Return error code when wic fails to invoke command
authorEd Bartosh <ed.bartosh@linux.intel.com>
Tue, 16 Jun 2015 11:19:49 +0000 (14:19 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 23 Jun 2015 10:38:16 +0000 (11:38 +0100)
Return 1 if command doesn't exist or wic is called without
any commmand.
Return result of invoke_command as wic return code.

Added tests for unsupported command and no command.

Fixed typo in test case test02_createhelp spotted by this fix.

[YOCTO #7856]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
meta/lib/oeqa/selftest/wic.py
scripts/lib/image/help.py
scripts/wic

index 60c8cb3deb5744150a16fd41f1f9d915403cf05f..5fa190db068661e2698c586158352c881764fe7e 100644 (file)
@@ -52,7 +52,7 @@ class Wic(oeSelfTest):
 
     def test02_createhelp(self):
         """Test wic create --help"""
-        self.assertEqual(0, runCmd('wic creat --help').status)
+        self.assertEqual(0, runCmd('wic create --help').status)
 
     def test03_listhelp(self):
         """Test wic list --help"""
@@ -82,3 +82,12 @@ class Wic(oeSelfTest):
         self.assertEqual(0, runCmd("wic create directdisk-gpt "
                                    "--image-name core-image-minimal").status)
         self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
+
+    def test07_unsupported_subcommand(self):
+        """Test unsupported subcommand"""
+        self.assertEqual(1, runCmd('wic unsupported',
+                         ignore_status=True).status)
+
+    def test08_no_command(self):
+        """Test wic without command"""
+        self.assertEqual(1, runCmd('wic', ignore_status=True).status)
index ce42627cdb16997104683162d9e1f3131279e1b1..93211498d5601d09d2ca59b9639f221763442e48 100644 (file)
@@ -81,11 +81,13 @@ def invoke_subcommand(args, parser, main_command_usage, subcommands):
     if not args:
         logging.error("No subcommand specified, exiting")
         parser.print_help()
+        return 1
     elif args[0] == "help":
         wic_help(args, main_command_usage, subcommands)
     elif args[0] not in subcommands:
         logging.error("Unsupported subcommand %s, exiting\n" % (args[0]))
         parser.print_help()
+        return 1
     else:
         usage = subcommands.get(args[0], subcommand_error)[1]
         subcommands.get(args[0], subcommand_error)[0](args[1:], usage)
index dda72a9c2775567524e34fc59de0a199a7337ffa..a38ecc0b8b6ad8eeb104edf873a822e18fe87a79 100755 (executable)
@@ -305,7 +305,7 @@ def main(argv):
                 parser.print_help()
                 sys.exit(1)
 
-    hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands)
+    return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands)
 
 
 if __name__ == "__main__":