Allow additional parameters to be specified with test plans. Also wrap
the control file for each test in the test plan, so that the Test
Planner can prefix each intended test with a verify_test, along with
any site-specific prefixes that may be required.
Allowing additional parameters gives the users the option to directly
specify the parameters for the verify_test, along with what
site-specific prefixes, if any, to attach.
Signed-off-by: James Ren <jamesren@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@4469 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/planner/control_file_unittest.py b/frontend/planner/control_file_unittest.py
new file mode 100644
index 0000000..9f3263d
--- /dev/null
+++ b/frontend/planner/control_file_unittest.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+
+import unittest, base64
+import common
+from autotest_lib.frontend.planner import control_file
+from autotest_lib.client.common_lib.test_utils import mock
+
+
+class ControlFileUnittest(unittest.TestCase):
+ def setUp(self):
+ self.god = mock.mock_god()
+
+
+ def tearDown(self):
+ self.god.unstub_all()
+
+
+ def _test_wrap_control_file_helper(self):
+ self.verify_params = object()
+ self.control = 'control'
+ self.verify_segment = '|verify_segment|'
+ prepared_verify_args = 'prepared_verify_args'
+
+ self.god.stub_function(control_file, 'prepare_args')
+ self.god.stub_function(control_file, 'apply_string_arguments')
+ control_file.prepare_args.expect_call(
+ self.verify_params).and_return(prepared_verify_args)
+ control_file.apply_string_arguments.expect_call(
+ control_file.VERIFY_TEST_SEGMENT,
+ verify_args=prepared_verify_args).and_return(
+ self.verify_segment)
+
+
+ def test_wrap_control_file_client(self):
+ self._test_wrap_control_file_helper()
+ control_base64 = 'control_base64'
+ control_segment = '|control_segment|'
+
+ self.god.stub_function(base64, 'encodestring')
+ base64.encodestring.expect_call(self.control).and_return(control_base64)
+ control_file.apply_string_arguments.expect_call(
+ control_file.CLIENT_SEGMENT, control_base64=control_base64,
+ control_comment=mock.is_string_comparator()).and_return(
+ control_segment)
+
+ result = control_file.wrap_control_file(control_file=self.control,
+ is_server=False,
+ skip_verify=False,
+ verify_params=self.verify_params)
+
+ self.assertEqual(result, self.verify_segment + control_segment)
+ self.god.check_playback()
+
+
+ def test_wrap_control_file_server(self):
+ self._test_wrap_control_file_helper()
+ control_segment = '|control_segment|'
+
+ control_file.apply_string_arguments.expect_call(
+ control_file.SERVER_SEGMENT,
+ control_raw=self.control).and_return(control_segment)
+
+ result = control_file.wrap_control_file(control_file=self.control,
+ is_server=True,
+ skip_verify=False,
+ verify_params=self.verify_params)
+
+ self.assertEqual(result, self.verify_segment + control_segment)
+ self.god.check_playback()
+
+
+if __name__ == '__main__':
+ unittest.main()