summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorLucian Musat <george.l.musat@intel.com>2015-09-15 18:11:59 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-18 09:05:21 +0100
commitd8eb9d41b0afb48f98dc59383cf886c8ca53c21a (patch)
tree36f2ee6a2ce7c302c16b74ccd167baea2b9bd74f /meta/lib/oeqa/utils
parent5acf99d1afc7efa962e4e698cc09a7f08133a64e (diff)
downloadpoky-d8eb9d41b0afb48f98dc59383cf886c8ca53c21a.tar.gz
oeqa/decorators: Added decorator to restart the DUT in case of test hang.
Once the DUT is hanged during testing, currently all the following test cases have to wait for default timeout to exit. Using this decorator the user can choose a timeout at case by case basis and what happens when the timeout is reached by overwriting the self.target.restart method. [YOCTO #7853] (From OE-Core rev: ce9a7501ea29ddba61ef7c297223b3f7eca5a2a1) Signed-off-by: Lucian Musat <george.l.musat@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/decorators.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index 162a88fb78..b6adcb1846 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -220,3 +220,28 @@ def getAllTags(obj):
220 ret = __gettags(obj) 220 ret = __gettags(obj)
221 ret.update(__gettags(tc_method)) 221 ret.update(__gettags(tc_method))
222 return ret 222 return ret
223
224def timeout_handler(seconds):
225 def decorator(fn):
226 if hasattr(signal, 'alarm'):
227 @wraps(fn)
228 def wrapped_f(self, *args, **kw):
229 current_frame = sys._getframe()
230 def raiseTimeOut(signal, frame):
231 if frame is not current_frame:
232 try:
233 self.target.restart()
234 raise TimeOut('%s seconds' % seconds)
235 except:
236 raise TimeOut('%s seconds' % seconds)
237 prev_handler = signal.signal(signal.SIGALRM, raiseTimeOut)
238 try:
239 signal.alarm(seconds)
240 return fn(self, *args, **kw)
241 finally:
242 signal.alarm(0)
243 signal.signal(signal.SIGALRM, prev_handler)
244 return wrapped_f
245 else:
246 return fn
247 return decorator