提交 5b8e7675 编写于 作者: C Cleber Rosa

Functional selftests: conditionally skip based tests that need cc

When no C compiler is available, these tests will produce errors.
Let's skip them when the requirements cannot be met.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 d1321790
......@@ -19,7 +19,7 @@ from avocado.core import exit_codes
from avocado.utils import astring
from avocado.utils import process
from avocado.utils import script
from avocado.utils import path as utils_path
basedir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..')
basedir = os.path.abspath(basedir)
......@@ -96,6 +96,14 @@ class MyTest(Test):
'''
def missing_binary(binary):
try:
utils_path.find_command(binary)
return False
except utils_path.CmdNotFoundError:
return True
class RunnerOperationTest(unittest.TestCase):
def setUp(self):
......@@ -160,6 +168,8 @@ class RunnerOperationTest(unittest.TestCase):
self.assertEqual(result.exit_status, expected_rc,
"Avocado did not return rc %d:\n%s" % (expected_rc, result))
@unittest.skipIf(missing_binary('cc'),
"C compiler is required by the underlying datadir.py test")
def test_datadir_alias(self):
os.chdir(basedir)
cmd_line = ('./scripts/avocado run --sysinfo=off --job-results-dir %s '
......@@ -173,6 +183,8 @@ class RunnerOperationTest(unittest.TestCase):
'env_variables.sh' % self.tmpdir)
process.run(cmd_line)
@unittest.skipIf(missing_binary('cc'),
"C compiler is required by the underlying datadir.py test")
def test_datadir_noalias(self):
os.chdir(basedir)
cmd_line = ('./scripts/avocado run --sysinfo=off --job-results-dir %s examples/tests/datadir.py '
......
......@@ -17,6 +17,7 @@ from avocado.core import exit_codes
from avocado.core.output import TermSupport
from avocado.utils import process
from avocado.utils import script
from avocado.utils import path as utils_path
basedir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..')
basedir = os.path.abspath(basedir)
......@@ -56,11 +57,21 @@ def perl_tap_parser_uncapable():
return os.system("perl -e 'use TAP::Parser;'") != 0
def missing_binary(binary):
try:
utils_path.find_command(binary)
return False
except utils_path.CmdNotFoundError:
return True
class OutputTest(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix='avocado_' + __name__)
@unittest.skipIf(missing_binary('cc'),
"C compiler is required by the underlying doublefree.py test")
def test_output_doublefree(self):
os.chdir(basedir)
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off '
......
......@@ -11,6 +11,7 @@ else:
from avocado.core import exit_codes
from avocado.utils import process
from avocado.utils import script
from avocado.utils import path as utils_path
basedir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..')
basedir = os.path.abspath(basedir)
......@@ -26,6 +27,14 @@ exec -- $@
"""
def missing_binary(binary):
try:
utils_path.find_command(binary)
return False
except utils_path.CmdNotFoundError:
return True
class WrapperTest(unittest.TestCase):
def setUp(self):
......@@ -42,6 +51,8 @@ class WrapperTest(unittest.TestCase):
'avocado_wrapper_functional')
self.dummy.save()
@unittest.skipIf(missing_binary('cc'),
"C compiler is required by the underlying datadir.py test")
def test_global_wrapper(self):
os.chdir(basedir)
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off --wrapper %s '
......@@ -56,6 +67,8 @@ class WrapperTest(unittest.TestCase):
"%s\nCmdline: %s" %
(self.tmpfile, result.stdout, cmd_line))
@unittest.skipIf(missing_binary('cc'),
"C compiler is required by the underlying datadir.py test")
def test_process_wrapper(self):
os.chdir(basedir)
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off --wrapper %s:*/datadir '
......@@ -70,6 +83,8 @@ class WrapperTest(unittest.TestCase):
"%s\nStdout: %s" %
(self.tmpfile, cmd_line, result.stdout))
@unittest.skipIf(missing_binary('cc'),
"C compiler is required by the underlying datadir.py test")
def test_both_wrappers(self):
os.chdir(basedir)
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off --wrapper %s --wrapper %s:*/datadir '
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册