test runtest should be a test attribute
Move the test initialisation we are doing in the job class over
to the test class.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@100 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/bin/test.py b/bin/test.py
index 87bb6bf..e0faad6 100644
--- a/bin/test.py
+++ b/bin/test.py
@@ -85,3 +85,31 @@
fd = file(status, "w")
fd.write("GOOD Completed Successfully\n")
fd.close()
+
+
+# runtest: main interface for importing and instantiating new tests.
+def runtest(self, tag, testname, test_args):
+ sys.path.insert(0, self.testdir + '/' + testname)
+ exec "import %s" % testname
+ exec "mytest = %s.%s(self, testname + '.' + tag)" % (testname, testname)
+
+ mytest.bindir = self.testdir + '/' + testname
+ mytest.srcdir = mytest.bindir + '/src'
+ mytest.tmpdir = self.tmpdir + '/' + testname
+ if os.path.exists(mytest.tmpdir):
+ system('rm -rf ' + mytest.tmpdir)
+ os.mkdir(mytest.tmpdir)
+
+ versionfile = mytest.srcdir + '/.version'
+ newversion = mytest.version
+ if os.path.exists(versionfile):
+ existing_version = pickle.load(open(versionfile, 'r'))
+ if (existing_version != newversion):
+ system('rm -rf ' + mytest.srcdir)
+ if not os.path.exists(mytest.srcdir):
+ # DANGER, will robinson. Error catching here ????
+ mytest.setup()
+ if os.path.exists(mytest.srcdir):
+ pickle.dump(newversion, open(versionfile, 'w'))
+ mytest.run(testname, test_args)
+