Add a global mechanism to the job object to allow users to change
the behaviour of profile_only, so that all tests default to
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3818 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/job.py b/client/bin/job.py
index 3784eb3..00e6b73 100755
--- a/client/bin/job.py
+++ b/client/bin/job.py
@@ -87,6 +87,8 @@
the job configuration for this job
drop_caches_between_iterations
drop the pagecache between each iteration
+ default_profile_only
+ default value for the test.execute profile_only paramete
"""
DEFAULT_LOG_FILENAME = "status"
@@ -185,6 +187,7 @@
self._init_drop_caches(drop_caches)
self._init_packages()
+ self.default_profile_only = False
self.run_test_cleanup = self.get_state("__run_test_cleanup",
default=True)
diff --git a/client/common_lib/test.py b/client/common_lib/test.py
index 589ad30..e948e1c 100644
--- a/client/common_lib/test.py
+++ b/client/common_lib/test.py
@@ -261,7 +261,7 @@
self.analyze_perf_constraints(constraints)
- def execute(self, iterations=None, test_length=None, profile_only=False,
+ def execute(self, iterations=None, test_length=None, profile_only=None,
_get_time=time.time, postprocess_profiled_run=None,
constraints=(), *args, **dargs):
"""
@@ -279,8 +279,8 @@
be silently ignored if you specify both.
@param profile_only: If true run X iterations with profilers enabled.
- Otherwise run X iterations and one with profiling if profiles are
- enabled.
+ If false run X iterations and one with profiling if profiles are
+ enabled. If None, default to the value of job.default_profile_only.
@param _get_time: [time.time] Used for unit test time injection.
@@ -295,6 +295,8 @@
profilers = self.job.profilers
if profilers.active():
profilers.stop(self)
+ if profile_only is None:
+ profile_only = self.job.default_profile_only
# If the user called this test in an odd way (specified both iterations
# and test_length), let's warn them.
if iterations and test_length:
diff --git a/client/common_lib/test_unittest.py b/client/common_lib/test_unittest.py
index 481bc72..9710fd0 100755
--- a/client/common_lib/test_unittest.py
+++ b/client/common_lib/test_unittest.py
@@ -22,6 +22,7 @@
def present(self):
return True
self.job = MockJob()
+ self.job.default_profile_only = False
self.job.profilers = MockProfilerManager()
self._new_keyval = False
self.iteration = 0
@@ -132,6 +133,19 @@
self.god.check_playback()
+ def test_execute_default_profile_only(self):
+ # test that profile_only=True works.
+ self.god.stub_function(self.test, 'drop_caches_between_iterations')
+ for _ in xrange(3):
+ self.test.drop_caches_between_iterations.expect_call()
+ self.test.run_once_profiling.expect_call(None)
+ self.test.postprocess.expect_call()
+ self.test.process_failed_constraints.expect_call()
+ self.test.job.default_profile_only = True
+ self.test.execute(iterations=3)
+ self.god.check_playback()
+
+
def test_execute_postprocess_profiled_false(self):
# test that postprocess_profiled_run=False works
self.god.stub_function(self.test, '_call_run_once')
diff --git a/server/autotest.py b/server/autotest.py
index 00e9297..73d035e 100644
--- a/server/autotest.py
+++ b/server/autotest.py
@@ -301,6 +301,8 @@
# build up the initialization prologue for the control file
prologue_lines = []
+ prologue_lines.append("job.default_profile_only = %r\n"
+ % host.job.default_profile_only)
prologue_lines.append("job.default_boot_tag(%r)\n"
% host.job.last_boot_tag)
prologue_lines.append("job.default_test_cleanup(%r)\n"
diff --git a/server/autotest_unittest.py b/server/autotest_unittest.py
index be241bc..2d38cab 100755
--- a/server/autotest_unittest.py
+++ b/server/autotest_unittest.py
@@ -28,6 +28,7 @@
profilers.profilers, "profilers")
self.host.job.profilers.add_log = {}
self.host.job.tmpdir = "/job/tmp"
+ self.host.job.default_profile_only = False
# stubs
self.god.stub_function(utils, "get_server_dir")
@@ -212,7 +213,8 @@
cfile = self.god.create_mock_class(file, "file")
cfile_orig = "original control file"
- cfile_new = "job.default_boot_tag('Autotest')\n"
+ cfile_new = "job.default_profile_only = False\n"
+ cfile_new += "job.default_boot_tag('Autotest')\n"
cfile_new += "job.default_test_cleanup(True)\n"
cfile_new += "job.add_repository(['repo'])\n"
cfile_new += cfile_orig
diff --git a/server/server_job.py b/server/server_job.py
index 7f2dd07..0b4b6ca 100755
--- a/server/server_job.py
+++ b/server/server_job.py
@@ -68,6 +68,8 @@
the control file for this job
drop_caches_between_iterations
drop the pagecache between each iteration
+ default_profile_only
+ default value for the test.execute profile_only parameter
"""
STATUS_VERSION = 1
@@ -130,6 +132,7 @@
self.ssh_port = ssh_port
self.ssh_pass = ssh_pass
self.tag = tag
+ self.default_profile_only = False
self.run_test_cleanup = True
self.last_boot_tag = None
self.hosts = set()