On a system wide install, it is undesirable that the control file state files are located in the same directory as the control files, since that location will be read only for non root users, for example:
/usr/lib/python2.7/site-packages/autotest/client/tests/sleeptest/control.state So make this directory configurable, hence allowing autotest to write job state files there on a system wide install yet leaving non root users able to run jobs. Signed-off-by: Lucas Meneghel Rodrigues <[email protected]> --- client/job.py | 21 ++++++++++++++++++--- global_config.ini | 2 ++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/client/job.py b/client/job.py index 9190c38..1b142f5 100644 --- a/client/job.py +++ b/client/job.py @@ -981,9 +981,24 @@ class base_client_job(base_job.base_job): def _load_state(self): - # 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' + 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' + if os.path.exists(init_state_file): shutil.move(init_state_file, self._state_file) self._state.set_backing_file(self._state_file) diff --git a/global_config.ini b/global_config.ini index 0736f62..4f5a976 100644 --- a/global_config.ini +++ b/global_config.ini @@ -53,6 +53,8 @@ test_tmp_dir: 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 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
