diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2021-04-20 19:32:59 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-04-23 10:12:10 +0100 |
commit | c13be2e1dc927b92297d27dd6bfd1fe0b1b95efe (patch) | |
tree | b3f666826be51113f1783cee9f08574e6ff423e9 | |
parent | b40f78a5c70985aac36c57055a51a8a673c3d12d (diff) | |
download | poky-c13be2e1dc927b92297d27dd6bfd1fe0b1b95efe.tar.gz |
meta/lib/oeqa/core/tests/cases/timeout.py: add a testcase for the previous fix
This is the sequence that didn't properly operate:
- a test case that skips and isn't executed
- a second test case that is skipped via a dependency decorator, and sets a timeout
- a third test case that takes longer than the timeout from the second
test case
Without the fix, the timeout is not cleared, and the third test case is
erroneously aborted. With the fix, the timeout is cleared and the third
test case is able to complete.
(From OE-Core rev: 54ef07a9aa1af8f41cfb9a4802929c918efc43c8)
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/core/tests/cases/timeout.py | 13 | ||||
-rwxr-xr-x | meta/lib/oeqa/core/tests/test_decorators.py | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/meta/lib/oeqa/core/tests/cases/timeout.py b/meta/lib/oeqa/core/tests/cases/timeout.py index 5dfecc7b7c..69cf969a67 100644 --- a/meta/lib/oeqa/core/tests/cases/timeout.py +++ b/meta/lib/oeqa/core/tests/cases/timeout.py | |||
@@ -8,6 +8,7 @@ from time import sleep | |||
8 | 8 | ||
9 | from oeqa.core.case import OETestCase | 9 | from oeqa.core.case import OETestCase |
10 | from oeqa.core.decorator.oetimeout import OETimeout | 10 | from oeqa.core.decorator.oetimeout import OETimeout |
11 | from oeqa.core.decorator.depends import OETestDepends | ||
11 | 12 | ||
12 | class TimeoutTest(OETestCase): | 13 | class TimeoutTest(OETestCase): |
13 | 14 | ||
@@ -19,3 +20,15 @@ class TimeoutTest(OETestCase): | |||
19 | def testTimeoutFail(self): | 20 | def testTimeoutFail(self): |
20 | sleep(2) | 21 | sleep(2) |
21 | self.assertTrue(True, msg='How is this possible?') | 22 | self.assertTrue(True, msg='How is this possible?') |
23 | |||
24 | |||
25 | def testTimeoutSkip(self): | ||
26 | self.skipTest("This test needs to be skipped, so that testTimeoutDepends()'s OETestDepends kicks in") | ||
27 | |||
28 | @OETestDepends(["timeout.TimeoutTest.testTimeoutSkip"]) | ||
29 | @OETimeout(3) | ||
30 | def testTimeoutDepends(self): | ||
31 | self.assertTrue(False, msg='How is this possible?') | ||
32 | |||
33 | def testTimeoutUnrelated(self): | ||
34 | sleep(6) | ||
diff --git a/meta/lib/oeqa/core/tests/test_decorators.py b/meta/lib/oeqa/core/tests/test_decorators.py index b798bf7d33..5095f39948 100755 --- a/meta/lib/oeqa/core/tests/test_decorators.py +++ b/meta/lib/oeqa/core/tests/test_decorators.py | |||
@@ -133,5 +133,11 @@ class TestTimeoutDecorator(TestBase): | |||
133 | msg = "OETestTimeout didn't restore SIGALRM" | 133 | msg = "OETestTimeout didn't restore SIGALRM" |
134 | self.assertIs(alarm_signal, signal.getsignal(signal.SIGALRM), msg=msg) | 134 | self.assertIs(alarm_signal, signal.getsignal(signal.SIGALRM), msg=msg) |
135 | 135 | ||
136 | def test_timeout_cancel(self): | ||
137 | tests = ['timeout.TimeoutTest.testTimeoutSkip', 'timeout.TimeoutTest.testTimeoutDepends', 'timeout.TimeoutTest.testTimeoutUnrelated'] | ||
138 | msg = 'Unrelated test failed to complete' | ||
139 | tc = self._testLoader(modules=self.modules, tests=tests) | ||
140 | self.assertTrue(tc.runTests().wasSuccessful(), msg=msg) | ||
141 | |||
136 | if __name__ == '__main__': | 142 | if __name__ == '__main__': |
137 | unittest.main() | 143 | unittest.main() |