Turn client/[tests|site-tests] into read only directories, make all the output that required those dirs to be read write to go to a configurable location. Consolidate all previous options that dealt with test output:
* test_tmp_dir * pkg_dir * state_dir Into a single one: * test_output_dir If that variable is not set, use the client temporary directory to write those files into. Signed-off-by: Don Zickus <dzic...@redhat.com> Signed-off-by: Lucas Meneghel Rodrigues <l...@redhat.com> --- client/harness_standalone.py | 10 ++++++++-- client/job.py | 28 ++++++++++++---------------- client/shared/base_job.py | 34 +++++++++++++++++----------------- global_config.ini | 8 ++------ 4 files changed, 39 insertions(+), 41 deletions(-) diff --git a/client/harness_standalone.py b/client/harness_standalone.py index 5180595..64f9a20 100644 --- a/client/harness_standalone.py +++ b/client/harness_standalone.py @@ -5,10 +5,12 @@ The default interface as required for the standalone reboot helper. __author__ = """Copyright Andy Whitcroft 2007""" -from autotest.client.shared import error +from autotest.client.shared import error, global_config from autotest.client import utils import os, harness, shutil, logging +GLOBAL_CONFIG = global_config.global_config + class harness_standalone(harness.harness): """The standalone server harness @@ -25,8 +27,12 @@ class harness_standalone(harness.harness): self.autodir = os.path.abspath(os.environ['AUTODIR']) self.setup(job) + tmpdir = os.path.join(self.autodir, 'tmp') + tests_dir = GLOBAL_CONFIG.get_config_value('COMMON', 'test_output_dir', + default=tmpdir) + src = job.control_get() - dest = os.path.join(self.autodir, 'control') + dest = os.path.join(tests_dir, 'control') if os.path.abspath(src) != os.path.abspath(dest): shutil.copyfile(src, dest) job.control_set(dest) diff --git a/client/job.py b/client/job.py index 1b142f5..4dadd00 100644 --- a/client/job.py +++ b/client/job.py @@ -981,23 +981,19 @@ class base_client_job(base_job.base_job): def _load_state(self): + autodir = os.path.abspath(os.environ['AUTODIR']) + tmpdir = os.path.join(autodir, 'tmp') state_config = GLOBAL_CONFIG.get_config_value('COMMON', - 'state_dir', - default="") - if state_config: - if not os.path.isdir(state_config): - os.makedirs(state_config) - init_state_file = os.path.join(state_config, - ("%s.init.state" % - os.path.basename(self.control))) - self._state_file = os.path.join(state_config, - ("%s.state" % - os.path.basename(self.control))) - else: - # grab any initial state and set up $CONTROL.state as the backing - # file - init_state_file = self.control + '.init.state' - self._state_file = self.control + '.state' + 'test_output_dir', + default=tmpdir) + if not os.path.isdir(state_config): + os.makedirs(state_config) + init_state_file = os.path.join(state_config, + ("%s.init.state" % + os.path.basename(self.control))) + self._state_file = os.path.join(state_config, + ("%s.state" % + os.path.basename(self.control))) if os.path.exists(init_state_file): shutil.move(init_state_file, self._state_file) diff --git a/client/shared/base_job.py b/client/shared/base_job.py index 11397a9..5ef699a 100644 --- a/client/shared/base_job.py +++ b/client/shared/base_job.py @@ -1028,30 +1028,30 @@ class base_job(object): self._profdir = readonly_dir(self.clientdir, 'profilers') self._toolsdir = readonly_dir(self.clientdir, 'tools') - tmpdir_config = GLOBAL_CONFIG.get_config_value('COMMON', - 'test_tmp_dir', - default="") - # directories which are in serverdir on a server, clientdir on a client + autodir = os.path.abspath(os.environ['AUTODIR']) + tmpdir = os.path.join(autodir, 'tmp') + + tests_out_dir = GLOBAL_CONFIG.get_config_value('COMMON', + 'test_output_dir', + default=tmpdir) + if self.serverdir: root = self.serverdir else: root = self.clientdir - if tmpdir_config: - self._tmpdir = readwrite_dir(tmpdir_config) - else: - self._tmpdir = readwrite_dir(root, 'tmp') - pkgdir_config = GLOBAL_CONFIG.get_config_value('COMMON', - 'pkg_dir', - default="") - if pkgdir_config: - self._pkgdir = readwrite_dir(pkgdir_config) - else: - self._pkgdir = readwrite_dir(self.clientdir, 'packages') + self._tmpdir = readwrite_dir(tests_out_dir, 'tmp') + + # special case packages for backwards compatibility + pkg_dir = tests_out_dir + if pkg_dir == self.serverdir: + pkg_dir = self.clientdir + self._pkgdir = readwrite_dir(pkg_dir, 'packages') - self._testdir = readwrite_dir(root, 'tests') - self._site_testdir = readwrite_dir(root, 'site_tests') + # Now tests are read-only modules + self._testdir = readonly_dir(root, 'tests') + self._site_testdir = readonly_dir(root, 'site_tests') # various server-specific directories if self.serverdir: diff --git a/global_config.ini b/global_config.ini index 4f5a976..264afea 100644 --- a/global_config.ini +++ b/global_config.ini @@ -47,14 +47,10 @@ sql_debug_mode: False [COMMON] # The path for the toplevel autotest directory autotest_top_path: /usr/local/autotest -# The path for tests tmp directory -test_tmp_dir: +# The path for tests output directory +test_output_dir: # The path for tests bin/src directory test_src_dir: -# The path for client/server packages directory -pkg_dir: -# The path to store control state files -state_dir: [AUTOSERV] # Autotest potential install paths -- 1.7.10.2 _______________________________________________ Autotest mailing list Autotest@test.kernel.org http://test.kernel.org/cgi-bin/mailman/listinfo/autotest