diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-06-16 14:19:49 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-23 11:47:34 +0100 |
commit | 40764a309d7f20421ca199e2283070bb561bf8c3 (patch) | |
tree | a5e120c7736c7de279ff2f4dae5c5bb52e4c0d65 | |
parent | 5daadf85eddf6c5898fe2b9a9ef7b1e9ed434d84 (diff) | |
download | poky-40764a309d7f20421ca199e2283070bb561bf8c3.tar.gz |
wic: Return error code when wic fails to invoke command
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]
(From OE-Core rev: ebd9f7b1da8ed556e98aab4d5f4e81707ac44b27)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/selftest/wic.py | 11 | ||||
-rw-r--r-- | scripts/lib/image/help.py | 2 | ||||
-rwxr-xr-x | scripts/wic | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index 60c8cb3deb..5fa190db06 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py | |||
@@ -52,7 +52,7 @@ class Wic(oeSelfTest): | |||
52 | 52 | ||
53 | def test02_createhelp(self): | 53 | def test02_createhelp(self): |
54 | """Test wic create --help""" | 54 | """Test wic create --help""" |
55 | self.assertEqual(0, runCmd('wic creat --help').status) | 55 | self.assertEqual(0, runCmd('wic create --help').status) |
56 | 56 | ||
57 | def test03_listhelp(self): | 57 | def test03_listhelp(self): |
58 | """Test wic list --help""" | 58 | """Test wic list --help""" |
@@ -82,3 +82,12 @@ class Wic(oeSelfTest): | |||
82 | self.assertEqual(0, runCmd("wic create directdisk-gpt " | 82 | self.assertEqual(0, runCmd("wic create directdisk-gpt " |
83 | "--image-name core-image-minimal").status) | 83 | "--image-name core-image-minimal").status) |
84 | self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) | 84 | self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) |
85 | |||
86 | def test07_unsupported_subcommand(self): | ||
87 | """Test unsupported subcommand""" | ||
88 | self.assertEqual(1, runCmd('wic unsupported', | ||
89 | ignore_status=True).status) | ||
90 | |||
91 | def test08_no_command(self): | ||
92 | """Test wic without command""" | ||
93 | self.assertEqual(1, runCmd('wic', ignore_status=True).status) | ||
diff --git a/scripts/lib/image/help.py b/scripts/lib/image/help.py index ce42627cdb..93211498d5 100644 --- a/scripts/lib/image/help.py +++ b/scripts/lib/image/help.py | |||
@@ -81,11 +81,13 @@ def invoke_subcommand(args, parser, main_command_usage, subcommands): | |||
81 | if not args: | 81 | if not args: |
82 | logging.error("No subcommand specified, exiting") | 82 | logging.error("No subcommand specified, exiting") |
83 | parser.print_help() | 83 | parser.print_help() |
84 | return 1 | ||
84 | elif args[0] == "help": | 85 | elif args[0] == "help": |
85 | wic_help(args, main_command_usage, subcommands) | 86 | wic_help(args, main_command_usage, subcommands) |
86 | elif args[0] not in subcommands: | 87 | elif args[0] not in subcommands: |
87 | logging.error("Unsupported subcommand %s, exiting\n" % (args[0])) | 88 | logging.error("Unsupported subcommand %s, exiting\n" % (args[0])) |
88 | parser.print_help() | 89 | parser.print_help() |
90 | return 1 | ||
89 | else: | 91 | else: |
90 | usage = subcommands.get(args[0], subcommand_error)[1] | 92 | usage = subcommands.get(args[0], subcommand_error)[1] |
91 | subcommands.get(args[0], subcommand_error)[0](args[1:], usage) | 93 | subcommands.get(args[0], subcommand_error)[0](args[1:], usage) |
diff --git a/scripts/wic b/scripts/wic index dda72a9c27..a38ecc0b8b 100755 --- a/scripts/wic +++ b/scripts/wic | |||
@@ -305,7 +305,7 @@ def main(argv): | |||
305 | parser.print_help() | 305 | parser.print_help() |
306 | sys.exit(1) | 306 | sys.exit(1) |
307 | 307 | ||
308 | hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands) | 308 | return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands) |
309 | 309 | ||
310 | 310 | ||
311 | if __name__ == "__main__": | 311 | if __name__ == "__main__": |