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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 pass | 497 pass |
498 real_error = MyError("this is the real error message") | 498 real_error = MyError("this is the real error message") |
499 unhandled_error = error.UnhandledTestError(real_error) | 499 unhandled_error = error.UnhandledTestError(real_error) |
500 | 500 |
501 # set up the recording | 501 # set up the recording |
502 testname = "error_test" | 502 testname = "error_test" |
503 outputdir = os.path.join(self.job.resultdir, testname) | 503 outputdir = os.path.join(self.job.resultdir, testname) |
504 self.job.pkgmgr.get_package_name.expect_call( | 504 self.job.pkgmgr.get_package_name.expect_call( |
505 testname, 'test').and_return(("", testname)) | 505 testname, 'test').and_return(("", testname)) |
506 os.path.exists.expect_call(outputdir).and_return(False) | 506 os.path.exists.expect_call(outputdir).and_return(False) |
507 self.job.record.expect_call("START", testname, testname) | 507 self.job.record.expect_call("START", testname, testname, |
508 self.job._runtest.expect_call(testname, "", (), {}).and_raises( | 508 optional_fields=None) |
| 509 self.job._runtest.expect_call(testname, "", None, (), {}).and_raises( |
509 unhandled_error) | 510 unhandled_error) |
510 self.job.record.expect_call("ERROR", testname, testname, | 511 self.job.record.expect_call("ERROR", testname, testname, |
511 first_line_comparator(str(real_error))) | 512 first_line_comparator(str(real_error))) |
512 self.job.record.expect_call("END ERROR", testname, testname) | 513 self.job.record.expect_call("END ERROR", testname, testname) |
513 self.job.harness.run_test_complete.expect_call() | 514 self.job.harness.run_test_complete.expect_call() |
514 utils.drop_caches.expect_call() | 515 utils.drop_caches.expect_call() |
515 | 516 |
516 # run and check | 517 # run and check |
517 self.job.run_test(testname) | 518 self.job.run_test(testname) |
518 self.god.check_playback() | 519 self.god.check_playback() |
(...skipping 12 matching lines...) Expand all Loading... |
531 real_error = MyError("this is the real error message") | 532 real_error = MyError("this is the real error message") |
532 unhandled_error = error.UnhandledTestError(real_error) | 533 unhandled_error = error.UnhandledTestError(real_error) |
533 reason = first_line_comparator("Unhandled MyError: %s" % real_error) | 534 reason = first_line_comparator("Unhandled MyError: %s" % real_error) |
534 | 535 |
535 # set up the recording | 536 # set up the recording |
536 testname = "error_test" | 537 testname = "error_test" |
537 outputdir = os.path.join(self.job.resultdir, testname) | 538 outputdir = os.path.join(self.job.resultdir, testname) |
538 self.job.pkgmgr.get_package_name.expect_call( | 539 self.job.pkgmgr.get_package_name.expect_call( |
539 testname, 'test').and_return(("", testname)) | 540 testname, 'test').and_return(("", testname)) |
540 os.path.exists.expect_call(outputdir).and_return(False) | 541 os.path.exists.expect_call(outputdir).and_return(False) |
541 self.job.record.expect_call("START", testname, testname) | 542 self.job.record.expect_call("START", testname, testname, |
542 self.job._runtest.expect_call(testname, "", (), {}).and_raises( | 543 optional_fields=None) |
| 544 self.job._runtest.expect_call(testname, "", None, (), {}).and_raises( |
543 unhandled_error) | 545 unhandled_error) |
544 self.job.record.expect_call("ERROR", testname, testname, reason) | 546 self.job.record.expect_call("ERROR", testname, testname, reason) |
545 self.job.record.expect_call("END ERROR", testname, testname) | 547 self.job.record.expect_call("END ERROR", testname, testname) |
546 self.job.harness.run_test_complete.expect_call() | 548 self.job.harness.run_test_complete.expect_call() |
547 utils.drop_caches.expect_call() | 549 utils.drop_caches.expect_call() |
548 | 550 |
549 # run and check | 551 # run and check |
550 self.job.run_test(testname) | 552 self.job.run_test(testname) |
551 self.god.check_playback() | 553 self.god.check_playback() |
552 | 554 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 "a='foo bar baz' only=gah": | 708 "a='foo bar baz' only=gah": |
707 ["a='foo bar baz'", "only=gah"], | 709 ["a='foo bar baz'", "only=gah"], |
708 "a='b c d' no=argh": | 710 "a='b c d' no=argh": |
709 ["a='b c d'", "no=argh"]} | 711 ["a='b c d'", "no=argh"]} |
710 for t in test_set: | 712 for t in test_set: |
711 parsed_args = job.base_client_job._parse_args(t) | 713 parsed_args = job.base_client_job._parse_args(t) |
712 expected_args = test_set[t] | 714 expected_args = test_set[t] |
713 self.assertEqual(parsed_args, expected_args) | 715 self.assertEqual(parsed_args, expected_args) |
714 | 716 |
715 | 717 |
| 718 def test_run_test_timeout_parameter_is_propagated(self): |
| 719 self.construct_job(True) |
| 720 |
| 721 # set up stubs |
| 722 self.god.stub_function(self.job.pkgmgr, 'get_package_name') |
| 723 self.god.stub_function(self.job, "_runtest") |
| 724 |
| 725 # create an unhandled error object |
| 726 #class MyError(error.TestError): |
| 727 # pass |
| 728 #real_error = MyError("this is the real error message") |
| 729 #unhandled_error = error.UnhandledTestError(real_error) |
| 730 |
| 731 # set up the recording |
| 732 testname = "test" |
| 733 outputdir = os.path.join(self.job.resultdir, testname) |
| 734 self.job.pkgmgr.get_package_name.expect_call( |
| 735 testname, 'test').and_return(("", testname)) |
| 736 os.path.exists.expect_call(outputdir).and_return(False) |
| 737 timeout = 60 |
| 738 optional_fields = {} |
| 739 optional_fields['timeout'] = timeout |
| 740 self.job.record.expect_call("START", testname, testname, |
| 741 optional_fields=optional_fields) |
| 742 self.job._runtest.expect_call(testname, "", timeout, (), {}) |
| 743 self.job.record.expect_call("GOOD", testname, testname, |
| 744 "completed successfully") |
| 745 self.job.record.expect_call("END GOOD", testname, testname) |
| 746 self.job.harness.run_test_complete.expect_call() |
| 747 utils.drop_caches.expect_call() |
| 748 |
| 749 # run and check |
| 750 self.job.run_test(testname, timeout=timeout) |
| 751 self.god.check_playback() |
| 752 |
| 753 |
716 if __name__ == "__main__": | 754 if __name__ == "__main__": |
717 unittest.main() | 755 unittest.main() |
OLD | NEW |