diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2021-04-20 19:32:58 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-04-23 10:12:10 +0100 |
commit | b40f78a5c70985aac36c57055a51a8a673c3d12d (patch) | |
tree | 992c567dfdf3372000ed03a36bb8834b1355deaf /meta/lib | |
parent | 942b80e82e77a6ddc7cf4288eb89c7f3abdc023b (diff) | |
download | poky-b40f78a5c70985aac36c57055a51a8a673c3d12d.tar.gz |
oeqa: tear down oeqa decorators if one of them raises an exception in setup
Some of the decorators need proper cleanup, such as OETimeout
which sets a signal handler that needs to be cleared via teardown.
If this is not done then the signal gets called later with unpredictable effects.
This can be seen if there's a test that is skipped via a decorator and sets a timeout
at the same time: the timeout isn't cleared, and is invoked later in a
completely unrelated context. The test case for this is added in the
next commit.
(From OE-Core rev: f42a08e1aabf1ca57e0c09d69fb69cc717c7f156)
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/core/case.py | 9 | ||||
-rw-r--r-- | meta/lib/oeqa/core/decorator/oetimeout.py | 5 |
2 files changed, 10 insertions, 4 deletions
diff --git a/meta/lib/oeqa/core/case.py b/meta/lib/oeqa/core/case.py index aae451fef2..bc4446a938 100644 --- a/meta/lib/oeqa/core/case.py +++ b/meta/lib/oeqa/core/case.py | |||
@@ -43,8 +43,13 @@ class OETestCase(unittest.TestCase): | |||
43 | clss.tearDownClassMethod() | 43 | clss.tearDownClassMethod() |
44 | 44 | ||
45 | def _oeSetUp(self): | 45 | def _oeSetUp(self): |
46 | for d in self.decorators: | 46 | try: |
47 | d.setUpDecorator() | 47 | for d in self.decorators: |
48 | d.setUpDecorator() | ||
49 | except: | ||
50 | for d in self.decorators: | ||
51 | d.tearDownDecorator() | ||
52 | raise | ||
48 | self.setUpMethod() | 53 | self.setUpMethod() |
49 | 54 | ||
50 | def _oeTearDown(self): | 55 | def _oeTearDown(self): |
diff --git a/meta/lib/oeqa/core/decorator/oetimeout.py b/meta/lib/oeqa/core/decorator/oetimeout.py index df90d1c798..5e6873ad48 100644 --- a/meta/lib/oeqa/core/decorator/oetimeout.py +++ b/meta/lib/oeqa/core/decorator/oetimeout.py | |||
@@ -24,5 +24,6 @@ class OETimeout(OETestDecorator): | |||
24 | 24 | ||
25 | def tearDownDecorator(self): | 25 | def tearDownDecorator(self): |
26 | signal.alarm(0) | 26 | signal.alarm(0) |
27 | signal.signal(signal.SIGALRM, self.alarmSignal) | 27 | if hasattr(self, 'alarmSignal'): |
28 | self.logger.debug("Removed SIGALRM handler") | 28 | signal.signal(signal.SIGALRM, self.alarmSignal) |
29 | self.logger.debug("Removed SIGALRM handler") | ||