From 08714d3b7e744b19dde2b102ed4d80fc171f07a1 Mon Sep 17 00:00:00 2001 From: Aníbal Limón Date: Tue, 8 Nov 2016 17:57:43 -0600 Subject: oeqa/core: Add base OEQA framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit case: Defines OETestCase base class that provides custom methods/attrs defined by the framework. Every OETestCase instance contains a reference to the test data (d), the test context (tc) and the logger. Also implements _oe{SetUp,TearDown}Class for make special handling of OEQA decorators and validations. runner: Defines OETestRunner/OETestResult with support for RAW and XML result logs. exception: Custom exceptions related to the OEQA framework based on class OEQAException. [YOCTO #10230] [YOCTO #10233] (From OE-Core rev: c466086ccc4d4bb02d578a821cfb945945bfd529) Signed-off-by: Aníbal Limón Signed-off-by: Mariano Lopez Signed-off-by: Richard Purdie --- meta/lib/oeqa/core/case.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 meta/lib/oeqa/core/case.py (limited to 'meta/lib/oeqa/core/case.py') diff --git a/meta/lib/oeqa/core/case.py b/meta/lib/oeqa/core/case.py new file mode 100644 index 0000000000..d2dbf20f9e --- /dev/null +++ b/meta/lib/oeqa/core/case.py @@ -0,0 +1,46 @@ +# Copyright (C) 2016 Intel Corporation +# Released under the MIT license (see COPYING.MIT) + +import unittest + +from oeqa.core.exception import OEQAMissingVariable + +def _validate_td_vars(td, td_vars, type_msg): + if td_vars: + for v in td_vars: + if not v in td: + raise OEQAMissingVariable("Test %s need %s variable but"\ + " isn't into td" % (type_msg, v)) + +class OETestCase(unittest.TestCase): + # TestContext and Logger instance set by OETestLoader. + tc = None + logger = None + + # td has all the variables needed by the test cases + # is the same across all the test cases. + td = None + + # td_vars has the variables needed by a test class + # or test case instance, if some var isn't into td a + # OEMissingVariable exception is raised + td_vars = None + + @classmethod + def _oeSetUpClass(clss): + _validate_td_vars(clss.td, clss.td_vars, "class") + clss.setUpClassMethod() + + @classmethod + def _oeTearDownClass(clss): + clss.tearDownClassMethod() + + def _oeSetUp(self): + for d in self.decorators: + d.setUpDecorator() + self.setUpMethod() + + def _oeTearDown(self): + for d in self.decorators: + d.tearDownDecorator() + self.tearDownMethod() -- cgit v1.2.3-54-g00ecf