From 4a01c2828ee0e6345eb66ca8c0eb629c160457f4 Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Tue, 10 Jun 2014 15:01:15 -0300 Subject: [PATCH] tests: Add timeouttest Add a timeout test module for avocado, to exercise the test timeout functionality. This test is supposed to fail by timeout. Signed-off-by: Lucas Meneghel Rodrigues --- tests/timeouttest/timeouttest.py | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 tests/timeouttest/timeouttest.py diff --git a/tests/timeouttest/timeouttest.py b/tests/timeouttest/timeouttest.py new file mode 100755 index 00000000..a81937a8 --- /dev/null +++ b/tests/timeouttest/timeouttest.py @@ -0,0 +1,41 @@ +#!/usr/bin/python + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See LICENSE for more details. +# +# Copyright: Red Hat Inc. 2013-2014 +# Author: Lucas Meneghel Rodrigues + +import time + +from avocado import test +from avocado import job + + +class timeouttest(test.Test): + + """ + Functional test for avocado. Throw a TestTimeoutError. + """ + default_params = {'timeout': 3.0, + 'sleep_time': 5.0} + + def action(self): + """ + This should throw a TestTimeoutError. + """ + self.log.info('Sleeping for %.2f seconds (2 more than the timeout)', + self.params.sleep_time) + time.sleep(self.params.sleep_time) + + +if __name__ == "__main__": + job.main() -- GitLab