harness_args option set to be persistent and survive reboots in standalone client. Code used for persistent harness option refactored to general method which can make any option persistent using the same rules.
Signed-off-by: Jan Stancek <[email protected]> --- client/bin/job.py | 39 ++++++++++++++++++++++++++------------- 1 files changed, 26 insertions(+), 13 deletions(-) diff --git a/client/bin/job.py b/client/bin/job.py index 948f899..cb39686 100644 --- a/client/bin/job.py +++ b/client/bin/job.py @@ -179,20 +179,10 @@ class base_client_job(base_job.base_job): self._next_step_index = 0 self._load_state() - # harness is chosen by following rules: - # 1. explicitly specified via command line - # 2. harness stored in state file (if continuing job '-c') - # 3. default harness - selected_harness = None - if options.harness: - selected_harness = options.harness - self._state.set('client', 'harness', selected_harness) - else: - stored_harness = self._state.get('client', 'harness', None) - if stored_harness: - selected_harness = stored_harness + _harness = self.handle_persistent_option(options, 'harness') + _harness_args = self.handle_persistent_option(options, 'harness_args') - self.harness = harness.select(selected_harness, self, options.harness_args) + self.harness = harness.select(_harness, self, _harness_args) # set up the status logger def client_job_record_hook(entry): @@ -924,6 +914,29 @@ class base_client_job(base_job.base_job): self._state.set('client', 'steps', []) + def handle_persistent_option(self, options, option_name): + """ + Select option from command line or persistent state. + Store selected option to allow standalone client to continue + after reboot with previously selected options. + Priority: + 1. explicitly specified via command line + 2. stored in state file (if continuing job '-c') + 3. default == None + """ + option = None + cmd_line_option = getattr(options, option_name) + if cmd_line_option: + option = cmd_line_option + self._state.set('client', option_name, option) + else: + stored_option = self._state.get('client', option_name, None) + if stored_option: + option = stored_option + logging.info('Persistent option: %s=%s', option_name, option) + return option + + def __create_step_tuple(self, fn, args, dargs): # Legacy code passes in an array where the first arg is # the function or its name. -- 1.7.1 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
