On 10/29/2013 11:23 AM, Rajeev S wrote:
Patch to specify the location of the test directory via an
extra command line option.
Usage:./autotest -d /path/to/dir path/to/control
Lack of Signed-off-by: tag
Lack of identification (patch signature)
This patch doesn't seem to be created using git send-email.
I had to fix this all. Please try to be more attentive of these details.
I am fine with people sending some patches to the mailing list and
bypassing github from time to time, but *please* at least use standard
procedure.
I did look at the patch, found a bug, that was fixed, see comment below.
After fixing the problems the patch was pushed to next
commit bec0b292180be277749321b56f38f30bbb280ce4
Author: Rajeev S <[email protected]>
Date: Wed Oct 30 15:31:46 2013 -0200
autotest-local: Specify test directory as a command line option
This patch allows to specify the location of the test
directory via an extra command line option, -d.
Usage:./autotest -d /path/to/dir path/to/control
Signed-off-by: Rajeev S <[email protected]>
Thanks,
Lucas
---
client/autotest_local.py | 6 ++++++
client/cmdparser.py | 11 ++++++++++-
client/optparser.py | 3 +++
client/setup_job.py | 8 ++++++++
client/shared/base_job.py | 6 ++++++
client/shared/base_job_unittest.py | 2 +-
client/shared/test.py | 2 +-
7 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/client/autotest_local.py b/client/autotest_local.py
index ab5dbd6..276fe16 100644
--- a/client/autotest_local.py
+++ b/client/autotest_local.py
@@ -46,6 +46,12 @@ class AutotestLocalApp:
self.options, args = self.opt_parser.parse_args()
self.args = self.cmd_parser.parse_args(args)
+ if self.options.test_directory is not None:
+ if os.path.isdir(self.options.test_directory):
+ os.environ['CUSTOM_DIR'] = self.options.test_directory
+ else:
+ print "The custom directory specifed does not exist,Hence
Ignoring."
+
# Check for a control file if not in prebuild mode.
if len(args) != 1 and self.options.client_test_setup is None:
print "Missing control file!"
diff --git a/client/cmdparser.py b/client/cmdparser.py
index 5683835..ccef3ed 100644
--- a/client/cmdparser.py
+++ b/client/cmdparser.py
@@ -173,6 +173,13 @@ class CommandParser(object):
cls._print_control_list(pipe, dirtest)
pipe.write("\n")
+ # Walk customtest directory
+ if 'CUSTOM_DIR' in os.environ:
+ dirtest = os.environ['CUSTOM_DIR']
+ pipe.write("Custom Test Directory (%s)\n" % dirtest)
+ cls._print_control_list(pipe, dirtest)
+ pipe.write("\n")
+
# Walk autodirtest directory
dirtest = os.environ['AUTODIRTEST']
pipe.write("Autotest prepackaged tests (%s)\n" % dirtest)
@@ -232,8 +239,10 @@ class CommandParser(object):
fetchdir = FETCHDIRTEST
globaldir = GLOBALDIRTEST
autodir = os.environ['AUTODIRTEST']
+ if 'CUSTOM_DIR' in os.environ:
+ customtestdir = os.environ['CUSTOM_DIR']
^ This is a bug. If there's no CUSTOM_DIR, then customtestdir below is
not defined and then an error will follow. I have fixed it.
- for dirtest in [localdir, fetchdir, globaldir, autodir]:
+ for dirtest in [localdir, fetchdir, globaldir, autodir, customtestdir]:
d = os.path.join(dirtest, test)
if os.path.isfile(d):
args.insert(0, d)
diff --git a/client/optparser.py b/client/optparser.py
index 717ba92..f5a5496 100644
--- a/client/optparser.py
+++ b/client/optparser.py
@@ -53,6 +53,9 @@ class AutotestLocalOptionParser(optparse.OptionParser):
help=('a comma seperated list of client tests to '
'prebuild on the server. Use all to prebuild
'
'all of them.'))
+ general.add_option("-d",'--test_directory', dest='test_directory',
+ type='string', default=None, action='store',
+ help=('Specify a custom test directory '))
self.add_option_group(general)
job_id = optparse.OptionGroup(self, 'JOB IDENTIFICATION')
diff --git a/client/setup_job.py b/client/setup_job.py
index a6547f2..9465d46 100644
--- a/client/setup_job.py
+++ b/client/setup_job.py
@@ -112,6 +112,14 @@ def load_all_client_tests(options):
all_tests.append(client_test)
else:
broken_tests.append(test_name)
+ if 'CUSTOM_DIR' in os.environ:
+ testdir = os.environ['CUSTOM_DIR']
+ for test_name in os.listdir(testdir):
+ client_test = init_test(options, os.path.join(testdir, test_name))
+ if client_test:
+ all_tests.append(client_test)
+ else:
+ broken_tests.append(test_name)
return all_tests, broken_tests
diff --git a/client/shared/base_job.py b/client/shared/base_job.py
index aff1ca7..15932e4 100644
--- a/client/shared/base_job.py
+++ b/client/shared/base_job.py
@@ -866,6 +866,7 @@ class base_job(object):
@property pkgdir: The job packages directory. [WRITABLE]
@property tmpdir: The job temporary directory. [WRITABLE]
@property testdir: The job test directory. [WRITABLE]
+ @property customtestdir: The custom test directory. [WRITABLE]
@property site_testdir: The job site test directory. [WRITABLE]
@property bindir: The client bin/ directory.
@@ -947,6 +948,7 @@ class base_job(object):
pkgdir = _job_directory.property_factory('pkgdir')
tmpdir = _job_directory.property_factory('tmpdir')
testdir = _job_directory.property_factory('testdir')
+ customtestdir = _job_directory.property_factory('customtestdir')
site_testdir = _job_directory.property_factory('site_testdir')
bindir = _job_directory.property_factory('bindir')
configdir = _job_directory.property_factory('configdir')
@@ -1057,6 +1059,10 @@ class base_job(object):
# Now tests are read-only modules
self._testdir = readonly_dir(test_dir)
+ if 'CUSTOM_DIR' in os.environ:
+ self._customtestdir = readonly_dir(os.environ['CUSTOM_DIR'])
+ else:
+ self._customtestdir = readonly_dir(test_dir)
self._site_testdir = readwrite_dir(test_out_dir, 'site_tests')
# various server-specific directories
diff --git a/client/shared/base_job_unittest.py
b/client/shared/base_job_unittest.py
index 210c069..2678e37 100755
--- a/client/shared/base_job_unittest.py
+++ b/client/shared/base_job_unittest.py
@@ -77,7 +77,7 @@ class test_init(unittest.TestCase):
# standard directories
'autodir', 'clientdir', 'serverdir', 'resultdir', 'pkgdir',
'tmpdir', 'testdir', 'site_testdir', 'bindir',
- 'configdir', 'profdir', 'toolsdir', 'conmuxdir',
+ 'configdir', 'profdir', 'toolsdir', 'conmuxdir', 'customtestdir',
# other special attributes
'args', 'automatic_test_tag', 'bootloader', 'control',
diff --git a/client/shared/test.py b/client/shared/test.py
index 9e0d6fe..0166e14 100644
--- a/client/shared/test.py
+++ b/client/shared/test.py
@@ -885,7 +885,7 @@ def runtest(job, url, tag, args, dargs,
# already exists on the machine
pass
- testdir_list = [job.testdir, getattr(job, 'site_testdir', None)]
+ testdir_list = [job.testdir, getattr(job, 'site_testdir', None),
job.customtestdir]
bindir_config = settings.get_value('COMMON', 'test_dir', default="")
if bindir_config:
testdir_list.extend(bindir_config.strip().split(','))
_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel
_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel