From 1573aba862c7102c01fd08ce3d8f47a1d0a812db Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 15 Aug 2014 11:22:24 -0300 Subject: [PATCH] Job main loop: add functional tests to the selftest suite Signed-off-by: Cleber Rosa --- .../all/functional/avocado/basic_tests.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/selftests/all/functional/avocado/basic_tests.py b/selftests/all/functional/avocado/basic_tests.py index 5906991f..f496256f 100644 --- a/selftests/all/functional/avocado/basic_tests.py +++ b/selftests/all/functional/avocado/basic_tests.py @@ -19,6 +19,7 @@ import unittest import os import signal import shutil +import time import sys import tempfile import xml.dom.minidom @@ -204,6 +205,41 @@ class RunnerDropinTest(unittest.TestCase): "Avocado did not return rc %d:\n%s" % (expected_rc, result)) + def test_runner_onehundred_fail_timing(self): + """ + We can be pretty sure that a failtest should return immediattely. Let's + run 100 of them and assure they not take more than 2 seconds to run. + + Notice: on a current machine this takes about 0.12s, so 2 second is + pretty safe here. + """ + os.chdir(basedir) + one_hundred = 'failtest ' * 100 + cmd_line = './scripts/avocado run "%s"' % one_hundred + initial_time = time.time() + result = process.run(cmd_line, ignore_status=True) + actual_time = time.time() - initial_time + self.assertLess(actual_time, 2.0) + expected_rc = 1 + self.assertEqual(result.exit_status, expected_rc, + "Avocado did not return rc %d:\n%s" % (expected_rc, result)) + + def test_runner_sleep_fail_sleep_timing(self): + """ + Sleeptest is supposed to take 1 second, let's make a sandwich of + 100 failtests and check the test runner timing. + """ + os.chdir(basedir) + sleep_fail_sleep = 'sleeptest ' + 'failtest ' * 100 + 'sleeptest' + cmd_line = './scripts/avocado run "%s"' % sleep_fail_sleep + initial_time = time.time() + result = process.run(cmd_line, ignore_status=True) + actual_time = time.time() - initial_time + self.assertLess(actual_time, 4.0) + expected_rc = 1 + self.assertEqual(result.exit_status, expected_rc, + "Avocado did not return rc %d:\n%s" % (expected_rc, result)) + def tearDown(self): if os.path.isdir(self.base_logdir): shutil.rmtree(self.base_logdir, ignore_errors=True) -- GitLab