Make it possible to use another directory to store test
results. With this, user can choose either to:

1) Pass a flag --output_dir to autotest specifying results
2) Set it in global_config.ini
3) Do neither and autotest behaves as usual

Changes from v1:
 * Used --output_dir as the flag name rather than --result_dir.
   Had to keep underscores on the flag name since other flags
   of the autotest program do use this convention.

Changes from v2:
 * Fixed job_unittest.py accordingly.

Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
 client/bin/autotest        |    4 ++++
 client/bin/job.py          |   19 +++++++++++++++----
 client/bin/job_unittest.py |    3 +++
 global_config.ini          |    3 +++
 4 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/client/bin/autotest b/client/bin/autotest
index 28c6015..af521de 100755
--- a/client/bin/autotest
+++ b/client/bin/autotest
@@ -55,6 +55,10 @@ parser.add_option('--hostname', dest='hostname', 
type='string',
                   help='Take this as the hostname of this machine '
                        '(given by autoserv)')
 
+parser.add_option('--output_dir', dest='output_dir',
+                  type='string', default="", action='store',
+                  help='Specify an alternate path to store test result logs')
+
 parser.add_option('--client_test_setup', dest='client_test_setup',
                   type='string', default=None, action='store',
                   help='a comma seperated list of client tests to prebuild on '
diff --git a/client/bin/job.py b/client/bin/job.py
index 1abdbcd..11a4175 100644
--- a/client/bin/job.py
+++ b/client/bin/job.py
@@ -19,6 +19,7 @@ from autotest_lib.client.common_lib import base_packages, 
packages
 from autotest_lib.client.common_lib import global_config
 from autotest_lib.client.tools import html_report
 
+GLOBAL_CONFIG = global_config.global_config
 
 LAST_BOOT_TAG = object()
 JOB_PREAMBLE = """
@@ -146,7 +147,17 @@ class base_client_job(base_job.base_job):
         always <autodir>/results/<tag>, where tag is passed in on the command
         line as an option.
         """
-        return os.path.join(self.autodir, 'results', options.tag)
+        output_dir_config = GLOBAL_CONFIG.get_config_value('CLIENT',
+                                                           'output_dir',
+                                                            default="")
+        if options.output_dir:
+            basedir = options.output_dir
+        elif output_dir_config:
+            basedir = output_dir_config
+        else:
+            basedir = self.autodir
+
+        return os.path.join(basedir, 'results', options.tag)
 
 
     def _get_status_logger(self):
@@ -270,9 +281,9 @@ class base_client_job(base_job.base_job):
         Perform the drop caches initialization.
         """
         self.drop_caches_between_iterations = (
-                       global_config.global_config.get_config_value('CLIENT',
-                                            'drop_caches_between_iterations',
-                                            type=bool, default=True))
+                                    GLOBAL_CONFIG.get_config_value('CLIENT',
+                                    'drop_caches_between_iterations',
+                                    type=bool, default=True))
         self.drop_caches = drop_caches
         if self.drop_caches:
             utils.drop_caches()
diff --git a/client/bin/job_unittest.py b/client/bin/job_unittest.py
index f3e1ae1..990d871 100755
--- a/client/bin/job_unittest.py
+++ b/client/bin/job_unittest.py
@@ -87,6 +87,7 @@ class test_init_minimal_options(abstract_test_init, 
job_test_case):
             user = None
             log = False
             args = ''
+            output_dir = ''
             tap_report = None
         self.god.stub_function_to_return(job.utils, 'drop_caches', None)
 
@@ -245,6 +246,7 @@ class test_base_job(unittest.TestCase):
         options.hostname = 'localhost'
         options.user = 'my_user'
         options.args = ''
+        options.output_dir = ''
         options.tap_report = None
         self.job.__init__(self.control, options,
                           extra_copy_cmdline=['more-blah'])
@@ -286,6 +288,7 @@ class test_base_job(unittest.TestCase):
         options.hostname = 'localhost'
         options.user = 'my_user'
         options.args = ''
+        options.output_dir = ''
         options.tap_report = None
         error = Exception('fail')
 
diff --git a/global_config.ini b/global_config.ini
index 805eb90..b1ac4ba 100644
--- a/global_config.ini
+++ b/global_config.ini
@@ -34,6 +34,9 @@ client_autodir_paths: /usr/local/autotest,/home/autotest
 [CLIENT]
 drop_caches: True
 drop_caches_between_iterations: True
+# Specify an alternate location to store the test results
+#output_dir: /var/log/autotest/
+output_dir:
 
 [SERVER]
 hostname: autotest
-- 
1.7.6

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

Reply via email to