I don't suppose I could convince you to use a character other than '.' to identify hierarchal tests. I know it's the more natural way to do it in python, but it now means that if I see a result for X.Y I can't tell if it's test X with tag Y or test X.Y, and if you have multiple tags it's even messier (is X.Y.Z test X or X.Y or X.Y.Z?)
In practice it probably won't be much of a problem for a person, there probably won't be much of a naming conflict, but when trying to write any kind of generic queries or scripts it'll be more of a pain. -- John On Fri, Mar 26, 2010 at 9:59 AM, Martin Bligh <[email protected]> wrote: > This patch allows you to have tests/a/b/foo, rather than just tests/foo > > eg. this: > > job.run_test('a.sleeptest', seconds = 1) > job.run_test('b.c.sleeptest', seconds = 1) > > Results in: > > START ---- ---- timestamp=1269622268 localtime=Mar 26 09:51:08 > START a.sleeptest a.sleeptest timestamp=1269622268 > localtime=Mar 26 09:51:08 > GOOD a.sleeptest a.sleeptest > timestamp=1269622270 localtime=Mar 26 09:51:10 completed > successfully > END GOOD a.sleeptest a.sleeptest > timestamp=1269622270 localtime=Mar 26 09:51:10 > START b.c.sleeptest b.c.sleeptest timestamp=1269622270 > localtime=Mar 26 09:51:10 > GOOD b.c.sleeptest b.c.sleeptest > timestamp=1269622272 localtime=Mar 26 09:51:12 completed > successfully > END GOOD b.c.sleeptest b.c.sleeptest > timestamp=1269622272 localtime=Mar 26 09:51:12 > END GOOD ---- ---- timestamp=1269622272 localtime=Mar > 26 09:51:12 > > and picks up from tests/a/sleeptest and tests/b/c/sleeptest > > Signed-off-by: Martin J. Bligh <[email protected]> > > Index: client/common_lib/test.py > =================================================================== > --- client/common_lib/test.py (revision 4348) > +++ client/common_lib/test.py (working copy) > @@ -615,62 +615,55 @@ > # if this is not a plain test name then download and install the > # specified test > if url.endswith('.tar.bz2'): > - (group, testname) = _installtest(job, url) > - bindir = os.path.join(job.testdir, 'download', group, testname) > + (testgroup, testname) = _installtest(job, url) > + bindir = os.path.join(job.testdir, 'download', testgroup, > testname) > + importdir = os.path.join(testdir, 'download', testgroup) > site_bindir = None > + modulename = '%s.%s' % (re.sub('/', '.', testgroup), testname) > + classname = '%s.%s' % (modulename, testname) > + path = testname > else: > - # if the test is local, it can be found in either testdir > - # or site_testdir. tests in site_testdir override tests > - # defined in testdir > - (group, testname) = ('', url) > - bindir = os.path.join(job.testdir, group, testname) > - if hasattr(job, 'site_testdir'): > - site_bindir = os.path.join(job.site_testdir, > - group, testname) > - else: > - site_bindir = None > + # If the test is local, it may be under either testdir or > site_testdir. > + # Tests in site_testdir override tests defined in testdir > + testname = path = url > + testgroup = '' > + path = re.sub('\.', '/', testname) > + modulename = os.path.basename(path) > + classname = '%s.%s' % (modulename, modulename) > > - # The job object here can be that of a server side job or a client > - # side job. 'install_pkg' method won't be present for server side > - # jobs, so do the fetch only if that method is present in the job > - # obj. > + # Try installing the test package > + # The job object may be either a server side job or a client side > job. > + # 'install_pkg' method will be present only if it's a client side > job. > if hasattr(job, 'install_pkg'): > try: > + bindir = os.path.join(job.testdir, testname) > job.install_pkg(testname, 'test', bindir) > except error.PackageInstallError, e: > # continue as a fall back mechanism and see if the test > code > # already exists on the machine > pass > > + bindir = testdir = None > + for dir in [job.testdir, getattr(job, 'site_testdir', None)]: > + if dir is not None and os.path.exists(os.path.join(dir, > path)): > + testdir = dir > + importdir = bindir = os.path.join(dir, path) > + if not bindir: > + raise error.TestError(testname + ': test does not exist') > + > outputdir = os.path.join(job.resultdir, testname) > if tag: > outputdir += '.' + tag > > - # if we can find the test in site_bindir, use this version > - if site_bindir and os.path.exists(site_bindir): > - bindir = site_bindir > - testdir = job.site_testdir > - elif os.path.exists(bindir): > - testdir = job.testdir > - else: > - raise error.TestError(testname + ': test does not exist') > - > local_namespace['job'] = job > local_namespace['bindir'] = bindir > local_namespace['outputdir'] = outputdir > > - if group: > - sys.path.insert(0, os.path.join(testdir, 'download')) > - group += '.' > - else: > - sys.path.insert(0, os.path.join(testdir, testname)) > - > + sys.path.insert(0, importdir) > try: > - exec ("import %s%s" % (group, testname), > + exec ('import %s' % modulename, local_namespace, global_namespace) > + exec ("mytest = %s(job, bindir, outputdir)" % classname, > local_namespace, global_namespace) > - exec ("mytest = %s%s.%s(job, bindir, outputdir)" % > - (group, testname, testname), > - local_namespace, global_namespace) > finally: > sys.path.pop(0) > _______________________________________________ > Autotest mailing list > [email protected] > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest >
_______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
