Merge remote branch 'autotest-upstream/master' into merge-upstream
rev 5270 and 5271.
BUG=None
TEST=Run BVT test.
Change-Id: I46ee56cea4861d9dd35b98f0a21536122714518c
[PATCH] After_iteration hooks are not executed if test fails.
Base_test's _call_run_once() does not execute the after_iteration hooks
if the test fails. It is important to execute the after_iteration hooks
in the event of a test failure since these hooks may be used to gather
important test logs to help diagnose the failure. This patch
modifies _call_run_once() to execute after_iteration hooks regardless of
the outcome of the test.
A new unit test was added to verify the behavior of _call_run_once(). The
patch was tested using unittest_suite.py to ensure that it did not break
other functionalities. It was also tested with an actual after_iteration
hook that collected test logs and the test was forced to fail.
Risk: High
Visibility: The order of when the after_iteration hooks has been changed
and may affect existing tests.
Bugs: None
Signed-off-by: Thieu Le <thieule@chromium.org>
git-svn-id: svn://test.kernel.org/autotest/trunk@5271 592f7852-d20e-0410-864c-8624ca9c26a4
KVM test: Make unattended setup copy finish.exe to floppies
Fixing yet another bug from the conversion of unattended
install to infrastructure.
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Review URL: http://codereview.chromium.org/6598041
diff --git a/client/common_lib/test_unittest.py b/client/common_lib/test_unittest.py
index 9710fd0..d2218ba 100755
--- a/client/common_lib/test_unittest.py
+++ b/client/common_lib/test_unittest.py
@@ -64,13 +64,35 @@
self.test.drop_caches_between_iterations.expect_call()
before_hook.expect_call(self.test)
self.test.run_once.expect_call(1, 2, arg='val')
- after_hook.expect_call(self.test)
self.test.postprocess_iteration.expect_call()
self.test.analyze_perf_constraints.expect_call([])
+ after_hook.expect_call(self.test)
self.test._call_run_once([], False, None, (1, 2), {'arg': 'val'})
self.god.check_playback()
+ def test_call_run_once_with_exception(self):
+ # setup
+ self.god.stub_function(self.test, 'drop_caches_between_iterations')
+ self.god.stub_function(self.test, 'run_once')
+ before_hook = self.god.create_mock_function('before_hook')
+ after_hook = self.god.create_mock_function('after_hook')
+ self.test.register_before_iteration_hook(before_hook)
+ self.test.register_after_iteration_hook(after_hook)
+ error = Exception('fail')
+
+ # tests the test._call_run_once implementation
+ self.test.drop_caches_between_iterations.expect_call()
+ before_hook.expect_call(self.test)
+ self.test.run_once.expect_call(1, 2, arg='val').and_raises(error)
+ after_hook.expect_call(self.test)
+ try:
+ self.test._call_run_once([], False, None, (1, 2), {'arg': 'val'})
+ except:
+ pass
+ self.god.check_playback()
+
+
def _expect_call_run_once(self):
self.test._call_run_once.expect_call((), False, None, (), {})