diff options
author | Lucian Musat <george.l.musat@intel.com> | 2015-09-15 18:11:59 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-09-15 17:50:07 +0100 |
commit | ce9a7501ea29ddba61ef7c297223b3f7eca5a2a1 (patch) | |
tree | 8a3ee9d5fb4ab9730e7ac3ca471056a7832ef173 /meta/lib/oeqa/utils | |
parent | 6c6c6528954952e1e323f5a26afd93b99913e6f2 (diff) | |
download | openembedded-core-ce9a7501ea29ddba61ef7c297223b3f7eca5a2a1.tar.gz openembedded-core-ce9a7501ea29ddba61ef7c297223b3f7eca5a2a1.tar.bz2 openembedded-core-ce9a7501ea29ddba61ef7c297223b3f7eca5a2a1.zip |
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]
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.py | 25 |
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): ret = __gettags(obj) ret.update(__gettags(tc_method)) return ret + +def timeout_handler(seconds): + def decorator(fn): + if hasattr(signal, 'alarm'): + @wraps(fn) + def wrapped_f(self, *args, **kw): + current_frame = sys._getframe() + def raiseTimeOut(signal, frame): + if frame is not current_frame: + try: + self.target.restart() + raise TimeOut('%s seconds' % seconds) + except: + raise TimeOut('%s seconds' % seconds) + prev_handler = signal.signal(signal.SIGALRM, raiseTimeOut) + try: + signal.alarm(seconds) + return fn(self, *args, **kw) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, prev_handler) + return wrapped_f + else: + return fn + return decorator |