summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2016-11-09 11:19:07 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:03:52 +0000
commit1bf66a370361912e9950d7ff45e382c93622a169 (patch)
treea96472cae81731d768d7ac6f51ad9b60ff8ffce0 /meta
parent047af4ce864bbf98e2617b348ae9ccb77ac52871 (diff)
downloadopenembedded-core-1bf66a370361912e9950d7ff45e382c93622a169.tar.gz
openembedded-core-1bf66a370361912e9950d7ff45e382c93622a169.tar.bz2
openembedded-core-1bf66a370361912e9950d7ff45e382c93622a169.zip
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] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/core/decorator/oetimeout.py25
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 @@
+# Copyright (C) 2016 Intel Corporation
+# Released under the MIT license (see COPYING.MIT)
+
+import signal
+from . import OETestDecorator, registerDecorator
+from oeqa.core.exception import OEQATimeoutError
+
+@registerDecorator
+class OETimeout(OETestDecorator):
+ attrs = ('oetimeout',)
+
+ def setUpDecorator(self):
+ timeout = self.oetimeout
+ def _timeoutHandler(signum, frame):
+ raise OEQATimeoutError("Timed out after %s "
+ "seconds of execution" % timeout)
+
+ self.logger.debug("Setting up a %d second(s) timeout" % self.oetimeout)
+ self.alarmSignal = signal.signal(signal.SIGALRM, _timeoutHandler)
+ signal.alarm(self.oetimeout)
+
+ def tearDownDecorator(self):
+ signal.alarm(0)
+ signal.signal(signal.SIGALRM, self.alarmSignal)
+ self.logger.debug("Removed SIGALRM handler")