diff options
author | Yeoh Ee Peng <ee.peng.yeoh@intel.com> | 2019-04-09 13:53:07 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-05-22 00:31:48 +0100 |
commit | 3cbf1342dd6d59c29465c5f7792d9edbdb0e249d (patch) | |
tree | e38ccc6d045837f4e29ec33fc31c3a5da0bb8c2a /scripts | |
parent | 2acd92292d896156672de012914e9ef012bdaef4 (diff) | |
download | poky-3cbf1342dd6d59c29465c5f7792d9edbdb0e249d.tar.gz |
resulttool/manualexecution: Enable configuration options selection
Current manualexecution required user to input configuration manually
where there were inconsistent inputs and human typo issues.
Enable manualexecution to have the optional feature where it
will use pre-compiled configuration options file where user will
be able to select configuration from the pre-compiled list instead
of manual key-in the configuration. This will eliminate human error.
Expect the pre-compiled configuration options file in json format below
{
"bsps-hw": {
"IMAGE_BASENAME": {
"1": "core-image-sato-sdk"
},
"MACHINE": {
"1": "beaglebone-yocto",
"2": "edgerouter",
"3": "mpc8315e-rdb",
"4": "genericx86",
"5": "genericx86-64"
}
},
"bsps-qemu": {
"IMAGE_BASENAME": {
"1": "core-image-sato-sdk"
},
"MACHINE": {
"1": "qemuarm",
"2": "qemuarm64",
"3": "qemumips",
"4": "qemumips64",
"5": "qemuppc",
"6": "qemux86",
"7": "qemux86-64"
}
}
}
(From OE-Core rev: 4c6bac8453768cab9c416c012019ead5edeaafa5)
Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/lib/resulttool/manualexecution.py | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/scripts/lib/resulttool/manualexecution.py b/scripts/lib/resulttool/manualexecution.py index c94f98126b..57e7b2999e 100755 --- a/scripts/lib/resulttool/manualexecution.py +++ b/scripts/lib/resulttool/manualexecution.py | |||
@@ -38,7 +38,21 @@ class ManualTestRunner(object): | |||
38 | print('Only lowercase alphanumeric, hyphen and dot are allowed. Please try again') | 38 | print('Only lowercase alphanumeric, hyphen and dot are allowed. Please try again') |
39 | return output | 39 | return output |
40 | 40 | ||
41 | def _create_config(self): | 41 | def _get_available_config_options(self, config_options, test_module, target_config): |
42 | avail_config_options = None | ||
43 | if test_module in config_options: | ||
44 | avail_config_options = config_options[test_module].get(target_config) | ||
45 | return avail_config_options | ||
46 | |||
47 | def _choose_config_option(self, options): | ||
48 | while True: | ||
49 | output = input('{} = '.format('Option index number')) | ||
50 | if output in options: | ||
51 | break | ||
52 | print('Only integer index inputs from above available configuration options are allowed. Please try again.') | ||
53 | return options[output] | ||
54 | |||
55 | def _create_config(self, config_options): | ||
42 | from oeqa.utils.metadata import get_layers | 56 | from oeqa.utils.metadata import get_layers |
43 | from oeqa.utils.commands import get_bb_var | 57 | from oeqa.utils.commands import get_bb_var |
44 | from resulttool.resultutils import store_map | 58 | from resulttool.resultutils import store_map |
@@ -54,11 +68,22 @@ class ManualTestRunner(object): | |||
54 | 68 | ||
55 | extra_config = set(store_map['manual']) - set(self.configuration) | 69 | extra_config = set(store_map['manual']) - set(self.configuration) |
56 | for config in sorted(extra_config): | 70 | for config in sorted(extra_config): |
57 | print('---------------------------------------------') | 71 | avail_config_options = self._get_available_config_options(config_options, self.test_module, config) |
58 | print('This is configuration #%s. Please provide configuration value(use "None" if not applicable).' % config) | 72 | if avail_config_options: |
59 | print('---------------------------------------------') | 73 | print('---------------------------------------------') |
60 | value_conf = self._get_input('Configuration Value') | 74 | print('These are available configuration #%s options:' % config) |
61 | print('---------------------------------------------\n') | 75 | print('---------------------------------------------') |
76 | for option, _ in sorted(avail_config_options.items(), key=lambda x: int(x[0])): | ||
77 | print('%s: %s' % (option, avail_config_options[option])) | ||
78 | print('Please select configuration option, enter the integer index number.') | ||
79 | value_conf = self._choose_config_option(avail_config_options) | ||
80 | print('---------------------------------------------\n') | ||
81 | else: | ||
82 | print('---------------------------------------------') | ||
83 | print('This is configuration #%s. Please provide configuration value(use "None" if not applicable).' % config) | ||
84 | print('---------------------------------------------') | ||
85 | value_conf = self._get_input('Configuration Value') | ||
86 | print('---------------------------------------------\n') | ||
62 | self.configuration[config] = value_conf | 87 | self.configuration[config] = value_conf |
63 | 88 | ||
64 | def _create_result_id(self): | 89 | def _create_result_id(self): |
@@ -99,9 +124,12 @@ class ManualTestRunner(object): | |||
99 | basepath = os.environ['BUILDDIR'] | 124 | basepath = os.environ['BUILDDIR'] |
100 | self.write_dir = basepath + '/tmp/log/manual/' | 125 | self.write_dir = basepath + '/tmp/log/manual/' |
101 | 126 | ||
102 | def run_test(self, file): | 127 | def run_test(self, file, config_options_file): |
103 | self._get_testcases(file) | 128 | self._get_testcases(file) |
104 | self._create_config() | 129 | config_options = {} |
130 | if config_options_file: | ||
131 | config_options = load_json_file(config_options_file) | ||
132 | self._create_config(config_options) | ||
105 | self._create_result_id() | 133 | self._create_result_id() |
106 | self._create_write_dir() | 134 | self._create_write_dir() |
107 | test_results = {} | 135 | test_results = {} |
@@ -113,7 +141,7 @@ class ManualTestRunner(object): | |||
113 | 141 | ||
114 | def manualexecution(args, logger): | 142 | def manualexecution(args, logger): |
115 | testrunner = ManualTestRunner() | 143 | testrunner = ManualTestRunner() |
116 | get_configuration, get_result_id, get_write_dir, get_test_results = testrunner.run_test(args.file) | 144 | get_configuration, get_result_id, get_write_dir, get_test_results = testrunner.run_test(args.file, args.config_options_file) |
117 | resultjsonhelper = OETestResultJSONHelper() | 145 | resultjsonhelper = OETestResultJSONHelper() |
118 | resultjsonhelper.dump_testresult_file(get_write_dir, get_configuration, get_result_id, get_test_results) | 146 | resultjsonhelper.dump_testresult_file(get_write_dir, get_configuration, get_result_id, get_test_results) |
119 | return 0 | 147 | return 0 |
@@ -125,3 +153,5 @@ def register_commands(subparsers): | |||
125 | group='manualexecution') | 153 | group='manualexecution') |
126 | parser_build.set_defaults(func=manualexecution) | 154 | parser_build.set_defaults(func=manualexecution) |
127 | parser_build.add_argument('file', help='specify path to manual test case JSON file.Note: Please use \"\" to encapsulate the file path.') | 155 | parser_build.add_argument('file', help='specify path to manual test case JSON file.Note: Please use \"\" to encapsulate the file path.') |
156 | parser_build.add_argument('-c', '--config-options-file', default='', | ||
157 | help='the config options file to import and used as available configuration option selection') | ||