| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 import logging, os, shutil, sys, time, StringIO | 3 import logging, os, shutil, sys, time, StringIO |
| 4 import common | 4 import common |
| 5 | 5 |
| 6 from autotest_lib.client.bin import job, boottool, config, sysinfo, harness | 6 from autotest_lib.client.bin import job, boottool, config, sysinfo, harness |
| 7 from autotest_lib.client.bin import test, xen, kernel, utils | 7 from autotest_lib.client.bin import test, xen, kernel, utils |
| 8 from autotest_lib.client.common_lib import packages, error, log | 8 from autotest_lib.client.common_lib import packages, error, log |
| 9 from autotest_lib.client.common_lib import logging_manager, logging_config | 9 from autotest_lib.client.common_lib import logging_manager, logging_config |
| 10 from autotest_lib.client.common_lib import base_job_unittest | 10 from autotest_lib.client.common_lib import base_job_unittest |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 stub_sysinfo()) | 75 stub_sysinfo()) |
| 76 class stub_harness: | 76 class stub_harness: |
| 77 run_start = lambda self: None | 77 run_start = lambda self: None |
| 78 self.god.stub_function_to_return(job.harness, 'select', stub_harness()) | 78 self.god.stub_function_to_return(job.harness, 'select', stub_harness()) |
| 79 self.god.stub_function_to_return(job.boottool, 'boottool', object()) | 79 self.god.stub_function_to_return(job.boottool, 'boottool', object()) |
| 80 class options: | 80 class options: |
| 81 tag = '' | 81 tag = '' |
| 82 verbose = False | 82 verbose = False |
| 83 cont = False | 83 cont = False |
| 84 harness = 'stub' | 84 harness = 'stub' |
| 85 harness_args = None |
| 85 hostname = None | 86 hostname = None |
| 86 user = None | 87 user = None |
| 87 log = False | 88 log = False |
| 88 args = '' | 89 args = '' |
| 89 tap_report = None | 90 tap_report = None |
| 90 self.god.stub_function_to_return(job.utils, 'drop_caches', None) | 91 self.god.stub_function_to_return(job.utils, 'drop_caches', None) |
| 91 | 92 |
| 92 self.job._job_state = base_job_unittest.stub_job_state | 93 self.job._job_state = base_job_unittest.stub_job_state |
| 93 self.job.__init__('/control', options) | 94 self.job.__init__('/control', options) |
| 94 | 95 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 tmpdir = os.path.join(self.autodir, 'tmp') | 175 tmpdir = os.path.join(self.autodir, 'tmp') |
| 175 if not cont: | 176 if not cont: |
| 176 job.base_client_job._cleanup_debugdir_files.expect_call() | 177 job.base_client_job._cleanup_debugdir_files.expect_call() |
| 177 job.base_client_job._cleanup_results_dir.expect_call() | 178 job.base_client_job._cleanup_results_dir.expect_call() |
| 178 | 179 |
| 179 self.job._load_state.expect_call() | 180 self.job._load_state.expect_call() |
| 180 | 181 |
| 181 my_harness = self.god.create_mock_class(harness.harness, | 182 my_harness = self.god.create_mock_class(harness.harness, |
| 182 'my_harness') | 183 'my_harness') |
| 183 harness.select.expect_call(None, | 184 harness.select.expect_call(None, |
| 184 self.job).and_return(my_harness) | 185 self.job, |
| 186 None).and_return(my_harness) |
| 185 | 187 |
| 186 return resultdir, my_harness | 188 return resultdir, my_harness |
| 187 | 189 |
| 188 | 190 |
| 189 def _setup_post_record_init(self, cont, resultdir, my_harness): | 191 def _setup_post_record_init(self, cont, resultdir, my_harness): |
| 190 # now some specific stubs | 192 # now some specific stubs |
| 191 self.god.stub_function(self.job, 'config_get') | 193 self.god.stub_function(self.job, 'config_get') |
| 192 self.god.stub_function(self.job, 'config_set') | 194 self.god.stub_function(self.job, 'config_set') |
| 193 self.god.stub_function(self.job, 'record') | 195 self.god.stub_function(self.job, 'record') |
| 194 | 196 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 232 |
| 231 # record | 233 # record |
| 232 resultdir, my_harness = self._setup_pre_record_init(cont) | 234 resultdir, my_harness = self._setup_pre_record_init(cont) |
| 233 self._setup_post_record_init(cont, resultdir, my_harness) | 235 self._setup_post_record_init(cont, resultdir, my_harness) |
| 234 | 236 |
| 235 # finish constructor | 237 # finish constructor |
| 236 options = dummy() | 238 options = dummy() |
| 237 options.tag = self.jobtag | 239 options.tag = self.jobtag |
| 238 options.cont = cont | 240 options.cont = cont |
| 239 options.harness = None | 241 options.harness = None |
| 242 options.harness_args = None |
| 240 options.log = False | 243 options.log = False |
| 241 options.verbose = False | 244 options.verbose = False |
| 242 options.hostname = 'localhost' | 245 options.hostname = 'localhost' |
| 243 options.user = 'my_user' | 246 options.user = 'my_user' |
| 244 options.args = '' | 247 options.args = '' |
| 245 options.tap_report = None | 248 options.tap_report = None |
| 246 self.job.__init__(self.control, options, | 249 self.job.__init__(self.control, options, |
| 247 extra_copy_cmdline=['more-blah']) | 250 extra_copy_cmdline=['more-blah']) |
| 248 | 251 |
| 249 # check | 252 # check |
| (...skipping 20 matching lines...) Expand all Loading... |
| 270 | 273 |
| 271 def test_constructor_post_record_failure(self): | 274 def test_constructor_post_record_failure(self): |
| 272 """ | 275 """ |
| 273 Test post record initialization failure. | 276 Test post record initialization failure. |
| 274 """ | 277 """ |
| 275 self.job = job.base_client_job.__new__(job.base_client_job) | 278 self.job = job.base_client_job.__new__(job.base_client_job) |
| 276 options = dummy() | 279 options = dummy() |
| 277 options.tag = self.jobtag | 280 options.tag = self.jobtag |
| 278 options.cont = False | 281 options.cont = False |
| 279 options.harness = None | 282 options.harness = None |
| 283 options.harness_args = None |
| 280 options.log = False | 284 options.log = False |
| 281 options.verbose = False | 285 options.verbose = False |
| 282 options.hostname = 'localhost' | 286 options.hostname = 'localhost' |
| 283 options.user = 'my_user' | 287 options.user = 'my_user' |
| 284 options.args = '' | 288 options.args = '' |
| 285 options.tap_report = None | 289 options.tap_report = None |
| 286 error = Exception('fail') | 290 error = Exception('fail') |
| 287 | 291 |
| 288 self.god.stub_function(self.job, '_post_record_init') | 292 self.god.stub_function(self.job, '_post_record_init') |
| 289 self.god.stub_function(self.job, 'record') | 293 self.god.stub_function(self.job, 'record') |
| (...skipping 25 matching lines...) Expand all Loading... |
| 315 control_file = "blah" | 319 control_file = "blah" |
| 316 self.job.control_set(control_file) | 320 self.job.control_set(control_file) |
| 317 self.assertEquals(self.job.control_get(), os.path.abspath(control_file)) | 321 self.assertEquals(self.job.control_get(), os.path.abspath(control_file)) |
| 318 | 322 |
| 319 | 323 |
| 320 def test_harness_select(self): | 324 def test_harness_select(self): |
| 321 self.construct_job(True) | 325 self.construct_job(True) |
| 322 | 326 |
| 323 # record | 327 # record |
| 324 which = "which" | 328 which = "which" |
| 325 harness.select.expect_call(which, self.job).and_return(None) | 329 harness_args = '' |
| 330 harness.select.expect_call(which, self.job, |
| 331 harness_args).and_return(None) |
| 326 | 332 |
| 327 # run and test | 333 # run and test |
| 328 self.job.harness_select(which) | 334 self.job.harness_select(which, harness_args) |
| 329 self.god.check_playback() | 335 self.god.check_playback() |
| 330 | 336 |
| 331 | 337 |
| 332 def test_config_set(self): | 338 def test_config_set(self): |
| 333 self.construct_job(True) | 339 self.construct_job(True) |
| 334 | 340 |
| 335 # unstub config_set | 341 # unstub config_set |
| 336 self.god.unstub(self.job, 'config_set') | 342 self.god.unstub(self.job, 'config_set') |
| 337 # record | 343 # record |
| 338 name = "foo" | 344 name = "foo" |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 "a='b c d' no=argh": | 708 "a='b c d' no=argh": |
| 703 ["a='b c d'", "no=argh"]} | 709 ["a='b c d'", "no=argh"]} |
| 704 for t in test_set: | 710 for t in test_set: |
| 705 parsed_args = job.base_client_job._parse_args(t) | 711 parsed_args = job.base_client_job._parse_args(t) |
| 706 expected_args = test_set[t] | 712 expected_args = test_set[t] |
| 707 self.assertEqual(parsed_args, expected_args) | 713 self.assertEqual(parsed_args, expected_args) |
| 708 | 714 |
| 709 | 715 |
| 710 if __name__ == "__main__": | 716 if __name__ == "__main__": |
| 711 unittest.main() | 717 unittest.main() |
| OLD | NEW |