diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2016-11-09 11:19:07 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-23 12:05:18 +0000 |
commit | b685a7c1a887c5eab7f3a232c91be564afb87ba9 (patch) | |
tree | 8d9befd7d9d5c07d9bc8c3b7ad1dc813fbd76c85 /meta/lib/oeqa | |
parent | b8cebdb96cdda0a8b4b3d5f638798d0ec54e3a14 (diff) | |
download | poky-b685a7c1a887c5eab7f3a232c91be564afb87ba9.tar.gz |
oeqa/core/decorator: Add support for OETimeout decorator
The OETimeout provides support for specify certain timeout
in seconds for a test case, if the timeout is reach the SIGALRM
is sent and an exception is raised to notify the timeout.
[YOCTO #10235]
(From OE-Core rev: 1bf66a370361912e9950d7ff45e382c93622a169)
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r-- | meta/lib/oeqa/core/decorator/oetimeout.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/meta/lib/oeqa/core/decorator/oetimeout.py b/meta/lib/oeqa/core/decorator/oetimeout.py new file mode 100644 index 0000000000..a247583f7f --- /dev/null +++ b/meta/lib/oeqa/core/decorator/oetimeout.py | |||
@@ -0,0 +1,25 @@ | |||
1 | # Copyright (C) 2016 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | import signal | ||
5 | from . import OETestDecorator, registerDecorator | ||
6 | from oeqa.core.exception import OEQATimeoutError | ||
7 | |||
8 | @registerDecorator | ||
9 | class OETimeout(OETestDecorator): | ||
10 | attrs = ('oetimeout',) | ||
11 | |||
12 | def setUpDecorator(self): | ||
13 | timeout = self.oetimeout | ||
14 | def _timeoutHandler(signum, frame): | ||
15 | raise OEQATimeoutError("Timed out after %s " | ||
16 | "seconds of execution" % timeout) | ||
17 | |||
18 | self.logger.debug("Setting up a %d second(s) timeout" % self.oetimeout) | ||
19 | self.alarmSignal = signal.signal(signal.SIGALRM, _timeoutHandler) | ||
20 | signal.alarm(self.oetimeout) | ||
21 | |||
22 | def tearDownDecorator(self): | ||
23 | signal.alarm(0) | ||
24 | signal.signal(signal.SIGALRM, self.alarmSignal) | ||
25 | self.logger.debug("Removed SIGALRM handler") | ||