I was helping to debug install quirks that would write to the read-only
install path.  I noticed a couple of directories were being written
and to fix them it was easier to consolidate some of the config options.

The directories/files in particular were:

/usr/lib/python-2.6/site-packages/autotest/tests/
/usr/lib/python-2.6/site-packages/autotest/site_tests/
/usr/lib/python-2.6/site-packages/autotest/control

I realized they all have similar redirections to a
/var/lib/autotest/tests/ directory.

So I decided to modify the code to assume that was the
output of the test results and just point everything there
if it was configured.

As a result, the following options disappear:

test_tmp_dir
pkg_dir
state_dir

and are replaced with

testout_dir

I tested this by running as a non-root user and making the /usr/lib/python-2.6..
path read-only.  These changes allowed things to work again from a client
perspective.  The command I used was

autotest-local run sleeptest

with test_src_dir configured to point at my autotest git tree's client/test
directory.

Signed-off-by: Don Zickus <[email protected]>
---

There is probably some blind ignorance with this patch as I didn't test with the
autotest-remote command and other harnesses besides harness_standalone.  I also 
do not
know how to run the standalone testsuite. :-(

If anyone knows of an easy way to do some more test coverage I can run those 
commands.
Though setting up the server will take some effort to download all the right 
packages
and configure things.
---
 client/harness_standalone.py |    7 +++++--
 client/job.py                |    2 +-
 client/shared/base_job.py    |   30 ++++++++++++------------------
 global_config.ini            |    8 ++------
 4 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/client/harness_standalone.py b/client/harness_standalone.py
index 5180595..c122c00 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,9 @@ class harness_standalone(harness.harness):
         self.autodir = os.path.abspath(os.environ['AUTODIR'])
         self.setup(job)
 
+        tests_dir = GLOBAL_CONFIG.get_config_value('COMMON', 'testout_dir', 
default=self.autodir)
         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..7b0deed 100644
--- a/client/job.py
+++ b/client/job.py
@@ -982,7 +982,7 @@ class base_client_job(base_job.base_job):
 
     def _load_state(self):
         state_config = GLOBAL_CONFIG.get_config_value('COMMON',
-                                                      'state_dir',
+                                                      'testout_dir',
                                                       default="")
         if state_config:
             if not os.path.isdir(state_config):
diff --git a/client/shared/base_job.py b/client/shared/base_job.py
index 11397a9..b02cf89 100644
--- a/client/shared/base_job.py
+++ b/client/shared/base_job.py
@@ -1028,30 +1028,24 @@ 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
         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._testdir = readwrite_dir(root, 'tests')
-        self._site_testdir = readwrite_dir(root, 'site_tests')
+        tests_dir = GLOBAL_CONFIG.get_config_value('COMMON',
+                                                        'testout_dir',
+                                                        default=root)
+        self._tmpdir = readwrite_dir(tests_dir, 'tmp')
+        self._testdir = readwrite_dir(tests_dir, 'tests')
+        self._site_testdir = readwrite_dir(tests_dir, 'site_tests')
+
+        # special case packages for backwards compatibility
+        pkg_dir = tests_dir
+        if pkg_dir == self.serverdir:
+            pkg_dir = self.clientdir
+        self._pkgdir = readwrite_dir(pkg_dir, 'packages')
 
         # various server-specific directories
         if self.serverdir:
diff --git a/global_config.ini b/global_config.ini
index 4f5a976..b7ae4cb 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 test output directory
+testout_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.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to