Daniel, your patches look good to me, I've applied them to next. If no problems are found in further scrutinity of the next tree, they'll go to master soon.
FYI, I've rebased the 2 patches into one. Thanks! On Wed, May 23, 2012 at 8:43 PM, Daniel DeFolo <daniel.def...@hp.com> wrote: > Add a new command-line option to allow users to specify a kernel config_file > as previously the only way to do so would require them to specify a control > file with the kernel_list specified. Intent is to make it easier to specify > both a kernel version and config_file for basic tests. > > The new option accepts a comma separated list that is expected to match the > number of entries specifed in the --kernel option. > > Signed-off-by: Daniel DeFolo <daniel.def...@hp.com> > --- > cli/job.py | 47 +++++++++++++++++++++++++++++++--- > cli/job_unittest.py | 68 > +++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 110 insertions(+), 5 deletions(-) > > diff --git a/cli/job.py b/cli/job.py > index 2b3dac0..c044b03 100644 > --- a/cli/job.py > +++ b/cli/job.py > @@ -356,6 +356,7 @@ class job_create(job_create_or_clone): > """atest job create [--priority <Low|Medium|High|Urgent>] > [--synch_count] [--control-file </path/to/cfile>] > [--on-server] [--test <test1,test2>] [--kernel <http://kernel>] > + [--kernel-config <http://kernel-config-file] > [--mlist </path/to/machinelist>] [--machine <host1 host2 host3>] > [--labels <list of labels of machines to run on>] > [--reboot_before <option>] [--reboot_after <option>] > @@ -387,6 +388,10 @@ class job_create(job_create_or_clone): > self.parser.add_option('-k', '--kernel', help='A comma separated list' > ' of kernel versions/URLs/filenames to run the' > ' job on') > + self.parser.add_option('--kernel-config', help='A comma separated > list' > + ' of kernel config URLs/filenames to run the' > + ' job on. Entries will be paired (in order)' > + ' with values provided in the --kernel > option') > self.parser.add_option('--kernel-cmdline', help='A string that will > be' > ' given as cmdline to the booted kernel(s)' > ' specified by the -k option') > @@ -425,14 +430,44 @@ class job_create(job_create_or_clone): > help='Job maximum runtime in hours') > > > - @staticmethod > - def _get_kernel_data(kernel_list, cmdline): > - # the RPC supports cmdline per kernel version in a dictionary > - kernels = [] > + def _get_kernel_data(self, kernel_list, cmdline, config_list=None): > + """ Combine CLI options for kernel_list, cmdline, and config_list > + into a list of dictionary entries (the RPC requires version, > + with optional entries for config_file and cmdline). > + > + If a config_list is specified, it must have the same number of > + entries as the kernel_list. > + > + If a cmdline is specified, it will be associated with each entry > + in the kernel_list > + """ > + configs = [] > + versions = [] > + if (config_list): > + for config in re.split(r'[, ]+', config_list): > + if not config: > + continue > + if (config.lower() == 'none'): > + configs.append(None) > + else: > + configs.append(config) > + > for version in re.split(r'[, ]+', kernel_list): > if not version: > continue > + versions.append(version) > + if (config_list is None): > + configs.append(None) > + > + if (len(configs) != len(versions)): > + self.invalid_syntax('Must specify same number of entries in' > + ' --kernel and --kernel-config options'); > + > + kernels = [] > + for version, config in zip(versions, configs): > kernel_info = {'version': version} > + if config: > + kernel_info['config_file'] = config > if cmdline: > kernel_info['cmdline'] = cmdline > kernels.append(kernel_info) > @@ -459,7 +494,9 @@ class job_create(job_create_or_clone): > '--test, not both.') > if options.kernel: > self.ctrl_file_data['kernel'] = self._get_kernel_data( > - options.kernel, options.kernel_cmdline) > + options.kernel, > + options.kernel_cmdline, > + config_list=options.kernel_config) > if options.control_file: > try: > control_file_f = open(options.control_file) > diff --git a/cli/job_unittest.py b/cli/job_unittest.py > index 760570d..d08be16 100755 > --- a/cli/job_unittest.py > +++ b/cli/job_unittest.py > @@ -938,6 +938,61 @@ class job_create_unittest(cli_mock.cli_unittest): > out_words_ok=['test_job0', 'Created', > 'Uploading', 'Done']) > > + def test_execute_create_job_with_2kernels_and_2config(self): > + data = self.data.copy() > + data['control_file'] = self.kernel_ctrl_file > + self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', > + '-k', 'kernel1,kernel2', > + '--kernel-config', 'config1,config2', > + '--kernel-cmdline','arg1 arg2', > + 'test_job0', '-m', 'host0', '--ignore_site_file'], > + rpcs=[('generate_control_file', > + {'tests': ['sleeptest'], > + 'kernel': [{'version': 'kernel1', > + 'config_file': 'config1', > + 'cmdline': 'arg1 arg2'}, > + {'version': 'kernel2', > + 'config_file': 'config2', > + 'cmdline': 'arg1 arg2'}] > + }, > + True, > + {'control_file' : self.kernel_ctrl_file, > + 'synch_count' : 1, > + 'is_server' : False, > + 'dependencies' : []}), > + ('create_job', data, True, 180)], > + out_words_ok=['test_job0', 'Created', > + 'Uploading', 'Done']) > + > + > + def test_execute_create_job_with_3kernels_and_explicit_none_config(self): > + data = self.data.copy() > + data['control_file'] = self.kernel_ctrl_file > + self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', > + '-k', 'kernel1,kernel2,kernel3', > + '--kernel-config', 'config1,none,config3', > + '--kernel-cmdline','arg1 arg2', > + 'test_job0', '-m', 'host0', '--ignore_site_file'], > + rpcs=[('generate_control_file', > + {'tests': ['sleeptest'], > + 'kernel': [{'version': 'kernel1', > + 'config_file': 'config1', > + 'cmdline': 'arg1 arg2'}, > + {'version': 'kernel2', > + 'cmdline': 'arg1 arg2'}, > + {'version': 'kernel3', > + 'config_file': 'config3', > + 'cmdline': 'arg1 arg2'}] > + }, > + True, > + {'control_file' : self.kernel_ctrl_file, > + 'synch_count' : 1, > + 'is_server' : False, > + 'dependencies' : []}), > + ('create_job', data, True, 180)], > + out_words_ok=['test_job0', 'Created', > + 'Uploading', 'Done']) > + > > def test_execute_create_job_with_kernel_spaces(self): > data = self.data.copy() > @@ -1015,6 +1070,19 @@ class job_create_unittest(cli_mock.cli_unittest): > self.god.check_playback() > > > + def test_execute_create_job_more_kernels_than_configs(self): > + testjob = job.job_create() > + sys.argv = ['atest', 'job', 'create', '-f', 'control_file', '-k', > + 'kernel1,kernel2', '--kernel-config', 'config1', > + 'test_job0', '-m', 'host0', '--ignore_site_file'] > + self.god.mock_io() > + (sys.exit.expect_call(mock.anything_comparator()) > + .and_raises(cli_mock.ExitException)) > + self.assertRaises(cli_mock.ExitException, testjob.parse) > + self.god.unmock_io() > + self.god.check_playback() > + > + > def test_execute_create_job_bad_cfile(self): > testjob = job.job_create() > sys.argv = ['atest', 'job', 'create', '-f', 'control_file', > -- > 1.7.7.6 > > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest -- Lucas _______________________________________________ Autotest mailing list Autotest@test.kernel.org http://test.kernel.org/cgi-bin/mailman/listinfo/autotest