avocado: Make tests to refer their ids

Make avocado tests to refer to their test ids (paths),
relative to the directory you are in. For example,
running:

avocado run tests/sleeptest.py

will give you

DEBUG LOG: /home/lmr/avocado/logs/run-2014-07-31-12.54.01/debug.log
TOTAL TESTS: 1
(1/1) tests/synctest.py.1: PASS (1.93 s)

Test log and data directories were changed accordingly. Now,
if your test is synctest.py, your data dir will be called
synctest.py.data.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 22f21dd4
......@@ -80,7 +80,7 @@ class TestRunner(object):
path_analyzer = path.PathInspector(test_path)
else:
test_class = test.MissingTest
test_instance = test_class(name=module_name,
test_instance = test_class(name=t_id,
base_logdir=self.job.logdir,
params=params,
job=self.job)
......@@ -96,7 +96,7 @@ class TestRunner(object):
except ImportError:
test_class = test.MissingTest
finally:
test_instance = test_class(name=module_name,
test_instance = test_class(name=t_id,
base_logdir=self.job.logdir,
params=params,
job=self.job)
......
......@@ -116,14 +116,22 @@ class Test(unittest.TestCase):
s_tag = ".".join(split_shortname[1:])
self.tag = tag or s_tag
self.job = job
basename = os.path.basename(self.name)
self.basedir = os.path.dirname(inspect.getfile(self.__class__))
self.datadir = os.path.join(self.basedir, '%s.data' % self.name)
self.workdir = path.init_dir(data_dir.get_tmp_dir(), self.name)
self.datadir = os.path.join(self.basedir, '%s.data' % basename)
self.workdir = path.init_dir(data_dir.get_tmp_dir(), basename)
self.srcdir = path.init_dir(self.workdir, 'src')
if base_logdir is None:
base_logdir = data_dir.get_job_logs_dir()
self.tagged_name = self.get_tagged_name(base_logdir)
self.logdir = path.init_dir(base_logdir, self.tagged_name)
# We need log directory names to be unique
tagged_name = self.tagged_name.replace('/', '.')
if tagged_name.startswith('.'):
tagged_name = tagged_name[1:]
self.logdir = path.init_dir(base_logdir, tagged_name)
self.logfile = os.path.join(self.logdir, 'debug.log')
self.outputdir = path.init_dir(self.logdir, 'data')
self.sysinfodir = path.init_dir(self.logdir, 'sysinfo')
......@@ -387,10 +395,8 @@ class DropinTest(Test):
"""
def __init__(self, path, params=None, base_logdir=None, tag=None, job=None):
basename = os.path.basename(path)
name = basename.split(".")[0]
self.path = os.path.abspath(path)
super(DropinTest, self).__init__(name=name, base_logdir=base_logdir,
super(DropinTest, self).__init__(name=path, base_logdir=base_logdir,
params=params, tag=tag, job=job)
def _log_detailed_cmd_info(self, result):
......
......@@ -60,7 +60,7 @@ class MultiplexTests(unittest.TestCase):
"%d:\n%s" % (cmd_line, expected_rc, result))
def test_mplex_plugin(self):
cmd_line = './scripts/avocado multiplex tests/sleeptest.data/sleeptest.mplx'
cmd_line = './scripts/avocado multiplex tests/sleeptest.py.data/sleeptest.mplx'
expected_rc = 0
self.run_and_check(cmd_line, expected_rc)
......@@ -70,12 +70,12 @@ class MultiplexTests(unittest.TestCase):
self.run_and_check(cmd_line, expected_rc)
def test_run_mplex_noid(self):
cmd_line = './scripts/avocado run --multiplex tests/sleeptest.data/sleeptest.mplx'
cmd_line = './scripts/avocado run --multiplex tests/sleeptest.py.data/sleeptest.mplx'
expected_rc = 0
self.run_and_check(cmd_line, 2)
def test_run_mplex_sleeptest(self):
cmd_line = './scripts/avocado run sleeptest --multiplex tests/sleeptest.data/sleeptest.mplx'
cmd_line = './scripts/avocado run sleeptest --multiplex tests/sleeptest.py.data/sleeptest.mplx'
expected_rc = 0
# A typical sleeptest has about 14 lines of output,
# so we expect the full job log has at least 3 times
......@@ -84,7 +84,7 @@ class MultiplexTests(unittest.TestCase):
self.run_and_check(cmd_line, expected_rc, 14*3)
def test_run_mplex_noalias_sleeptest(self):
cmd_line = './scripts/avocado run tests/sleeptest.py --multiplex tests/sleeptest.data/sleeptest.mplx'
cmd_line = './scripts/avocado run tests/sleeptest.py --multiplex tests/sleeptest.py.data/sleeptest.mplx'
expected_rc = 0
# A typical sleeptest has about 14 lines of output,
# so we expect the full job log has at least 3 times
......@@ -93,12 +93,12 @@ class MultiplexTests(unittest.TestCase):
self.run_and_check(cmd_line, expected_rc, 14*3)
def test_run_mplex_doublesleep(self):
cmd_line = './scripts/avocado run "sleeptest sleeptest" --multiplex tests/sleeptest.data/sleeptest.mplx'
cmd_line = './scripts/avocado run "sleeptest sleeptest" --multiplex tests/sleeptest.py.data/sleeptest.mplx'
expected_rc = 0
self.run_and_check(cmd_line, expected_rc)
def test_run_mplex_failtest(self):
cmd_line = './scripts/avocado run "sleeptest failtest" --multiplex tests/sleeptest.data/sleeptest.mplx'
cmd_line = './scripts/avocado run "sleeptest failtest" --multiplex tests/sleeptest.py.data/sleeptest.mplx'
expected_rc = 1
self.run_and_check(cmd_line, expected_rc)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册