TestNeedsBin() is used in all tests where binaries are required. It offers functionality to send binaries to DUTs both in unpacked (raw) and in an .rpm form. It is able to handle native binaries, intended for the machine launching tests on DUTs. It also offers functionality for removing DUTs related binaries after finishing the test.
Signed-off-by: Costin Constantin <costin.c.constan...@intel.com> --- meta/lib/oeqa/utils/decorators.py | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py index 0d79223..a3878ef 100644 --- a/meta/lib/oeqa/utils/decorators.py +++ b/meta/lib/oeqa/utils/decorators.py @@ -12,7 +12,9 @@ import sys import unittest import threading import signal +import re from functools import wraps +import testexport as te #get the "result" object from one of the upper frames provided that one of these upper frames is a unittest.case frame class getResults(object): @@ -260,3 +262,59 @@ def timeout_handler(seconds): else: return fn return decorator + +class TestNeedsBin(object): + """ + This decorator provides binary support for test cases. + Binaries can be versioned. The decorator works with .rpm files and can send + both the rpm or the content of the .rpm to the DUT in the corresponding location + as indicated inside it. When the .rpm file is sent to the DUT, it will be available + in /home/root. + It supports sent files removal after testcase completion. + In case no version is specified for the needed binary, it will take as default + the latest version of the corresponding package. + Future support for .deb and .ipk will be available. + """ + def __init__(self, *args): + self.args = args + self.params_list = list() + self.clean_list = list() + if self.args:# these are tuples of values + for param_tuple in self.args: + bn,bv,t, p,rm_b = ("", "", "", "", "") + for index,value in enumerate(param_tuple): + if index == 0: + bn = value + elif index == 1 and re.match("[0-9]+\.",value): + bv = value + elif value == "rpm": + p = value + elif value == "native": + t = value + elif value == "rm": + rm_b = value + self.params_list.append((bn, bv, p, t, rm_b)) #ensure order of params is as desired + + def deploy_binary(self, params): + from oeqa.oetest import oeRuntimeTest + p = params + if p[3] == "native": + te.process_binaries(oeRuntimeTest.tc.d, params) + else: + status = te.process_binaries(oeRuntimeTest.tc.d, params) + if status: + bin_to_rm = te.send_bin_to_DUT(oeRuntimeTest.tc.d, params) + if bin_to_rm: + self.clean_list.extend(bin_to_rm) + + def __call__(self, func): + def wrapped_f(*args): + for item in set(self.params_list): + self.deploy_binary(item) + func(*args) + te.rm_bin(self.clean_list) # used to remove sent binaries + return + wrapped_f.__name__ = func.__name__ + wrapped_f.args = self.args + return wrapped_f + -- 2.5.0 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core