Skip to content

Commit

Permalink
functional test for the "simple test fork bomb"
Browse files Browse the repository at this point in the history
Signed-off-by: Cleber Rosa <crosa@redhat.com>
  • Loading branch information
clebergnu committed Jan 18, 2016
1 parent 6d82209 commit 744e261
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions selftests/functional/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,34 @@ def hello():
"""


AVOCADO_SIMPLE_PYTHON_LIKE_MULTIPLE_FILES = """#!/usr/bin/env python
# A simple test (executable bit set when saved to file) that looks like
# an Avocado instrumented test, with base class on separate file
from avocado import Test
from avocado import main
from test2 import *
class BasicTestSuite(SuperTest):
def test1(self):
self.xxx()
self.assertTrue(True)
if __name__ == '__main__':
main()
"""

AVOCADO_SIMPLE_PYTHON_LIKE_MULTIPLE_FILES_LIB = """
#!/usr/bin/python
from avocado import Test
class SuperTest(Test):
def xxx(self):
print "ahoj"
"""


class LoaderTestFunctional(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -161,6 +189,27 @@ def test_load_not_a_test(self):
def test_load_not_a_test_not_exec(self):
self._test('notatest.py', NOT_A_TEST, 'NOT_A_TEST')

def test_runner_simple_python_like_multiple_files(self):
mylib = script.TemporaryScript(
'test2.py',
AVOCADO_SIMPLE_PYTHON_LIKE_MULTIPLE_FILES_LIB,
'avocado_simpletest_functional',
0644)
mylib.save()
mytest = script.Script(
os.path.join(os.path.dirname(mylib.path), 'test.py'),
AVOCADO_SIMPLE_PYTHON_LIKE_MULTIPLE_FILES)
os.chdir(basedir)
mytest.save()
cmd_line = "./scripts/avocado list -V %s" % mytest
result = process.run(cmd_line)
self.assertIn('SIMPLE: 1', result.stdout)
# job should be able to finish under 5 seconds. If this fails, it's
# possible that we hit the "simple test fork bomb" bug
cmd_line = ("./scripts/avocado run --sysinfo=off --job-results-dir %s "
"--job-timeout=5s %s" % (self.tmpdir, mytest))
process.run(cmd_line)

def tearDown(self):
shutil.rmtree(self.tmpdir)

Expand Down

0 comments on commit 744e261

Please sign in to comment.