From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mail.openembedded.org (Postfix) with ESMTP id 00D8D731B3 for ; Fri, 18 Dec 2015 12:28:36 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 18 Dec 2015 04:28:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,446,1444719600"; d="scan'208";a="863931641" Received: from linux.intel.com ([10.23.219.25]) by fmsmga001.fm.intel.com with ESMTP; 18 Dec 2015 04:28:37 -0800 Received: from localhost.localdomain (unknown [10.237.112.252]) by linux.intel.com (Postfix) with ESMTP id C24326A4007 for ; Fri, 18 Dec 2015 05:16:38 -0800 (PST) From: Costin Constantin To: openembedded-core@lists.openembedded.org Date: Fri, 18 Dec 2015 14:40:55 +0200 Message-Id: <66fc1be529e8b27f03264fdc351c1f8392509f55.1450441923.git.costin.c.constantin@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH 03/12] utils/decorators.py: add TestNeedsBin() decorator X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Dec 2015 12:28:37 -0000 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 --- meta/lib/oeqa/utils/decorators.py | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py index 0d79223..93a728e 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,49 @@ def timeout_handler(seconds): else: return fn return decorator + +class TestNeedsBin(object): + """ + This decorator provides binary support for test cases + """ + def __init__(self, *args): + self.params_list = list() + self. clean_list = list() + if args:# these are tuples of values + for param_tuple in 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("%s_%s_%s_%s_%s" % (bn, bv, p, t, rm_b)) + + def deploy_binary(self, params): + from oeqa.oetest import oeRuntimeTest + p = params.split("_") + 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__ + return wrapped_f + -- 2.5.0