diff options
author | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-11-02 11:07:33 +0900 |
---|---|---|
committer | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-11-02 11:07:33 +0900 |
commit | 1c7d6584a7811b7785ae5c1e378f14b5ba0971cf (patch) | |
tree | cd70a267a5ef105ba32f200aa088e281fbd85747 /external/poky/meta/lib/oeqa/core/decorator | |
parent | 4204309872da5cb401cbb2729d9e2d4869a87f42 (diff) |
basesystem-jjsandbox/ToshikazuOhiwa/master-jj
recipes
Diffstat (limited to 'external/poky/meta/lib/oeqa/core/decorator')
6 files changed, 136 insertions, 59 deletions
diff --git a/external/poky/meta/lib/oeqa/core/decorator/__init__.py b/external/poky/meta/lib/oeqa/core/decorator/__init__.py index 14d7bfcd..1a82518a 100644 --- a/external/poky/meta/lib/oeqa/core/decorator/__init__.py +++ b/external/poky/meta/lib/oeqa/core/decorator/__init__.py @@ -1,8 +1,12 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# from functools import wraps from abc import abstractmethod, ABCMeta +from oeqa.core.utils.misc import strToList decoratorClasses = set() @@ -60,12 +64,16 @@ class OETestDiscover(OETestDecorator): def discover(registry): return registry['cases'] -class OETestFilter(OETestDecorator): +def OETestTag(*tags): + expandedtags = [] + for tag in tags: + expandedtags += strToList(tag) + def decorator(item): + if hasattr(item, "__oeqa_testtags"): + # do not append, create a new list (to handle classes with inheritance) + item.__oeqa_testtags = list(item.__oeqa_testtags) + expandedtags + else: + item.__oeqa_testtags = expandedtags + return item + return decorator - # OETestLoader call it while loading the tests - # in loadTestsFromTestCase method, it needs to - # return a bool, True if needs to be filtered. - # This method must consume the filter used. - @abstractmethod - def filtrate(self, filters): - return False diff --git a/external/poky/meta/lib/oeqa/core/decorator/data.py b/external/poky/meta/lib/oeqa/core/decorator/data.py index f0f65abb..bc4939e8 100644 --- a/external/poky/meta/lib/oeqa/core/decorator/data.py +++ b/external/poky/meta/lib/oeqa/core/decorator/data.py @@ -1,5 +1,8 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# from oeqa.core.exception import OEQAMissingVariable @@ -15,6 +18,26 @@ def has_feature(td, feature): return True return False +def has_machine(td, machine): + """ + Checks for MACHINE. + """ + + if (machine in td.get('MACHINE', '')): + return True + return False + +def is_qemu(td, qemu): + """ + Checks if MACHINE is qemu. + """ + + machine = td.get('MACHINE', '') + if (qemu in td.get('MACHINE', '') or + machine.startswith('qemu')): + return True + return False + @registerDecorator class skipIfDataVar(OETestDecorator): """ @@ -110,3 +133,90 @@ class skipIfNotFeature(OETestDecorator): self.logger.debug(msg) if not has_feature(self.case.td, self.value): self.case.skipTest(self.msg) + +@registerDecorator +class skipIfFeature(OETestDecorator): + """ + Skip test based on DISTRO_FEATURES. + + value must not be in distro features or it will skip the test + with msg as the reason. + """ + + attrs = ('value', 'msg') + + def setUpDecorator(self): + msg = ('Checking if %s is not in DISTRO_FEATURES ' + 'or IMAGE_FEATURES' % (self.value)) + self.logger.debug(msg) + if has_feature(self.case.td, self.value): + self.case.skipTest(self.msg) + +@registerDecorator +class skipIfNotMachine(OETestDecorator): + """ + Skip test based on MACHINE. + + value must be match MACHINE or it will skip the test + with msg as the reason. + """ + + attrs = ('value', 'msg') + + def setUpDecorator(self): + msg = ('Checking if %s is not this MACHINE' % self.value) + self.logger.debug(msg) + if not has_machine(self.case.td, self.value): + self.case.skipTest(self.msg) + +@registerDecorator +class skipIfMachine(OETestDecorator): + """ + Skip test based on Machine. + + value must not be this machine or it will skip the test + with msg as the reason. + """ + + attrs = ('value', 'msg') + + def setUpDecorator(self): + msg = ('Checking if %s is this MACHINE' % self.value) + self.logger.debug(msg) + if has_machine(self.case.td, self.value): + self.case.skipTest(self.msg) + +@registerDecorator +class skipIfNotQemu(OETestDecorator): + """ + Skip test based on MACHINE. + + value must be a qemu MACHINE or it will skip the test + with msg as the reason. + """ + + attrs = ('value', 'msg') + + def setUpDecorator(self): + msg = ('Checking if %s is not this MACHINE' % self.value) + self.logger.debug(msg) + if not is_qemu(self.case.td, self.value): + self.case.skipTest(self.msg) + +@registerDecorator +class skipIfQemu(OETestDecorator): + """ + Skip test based on Qemu Machine. + + value must not be a qemu machine or it will skip the test + with msg as the reason. + """ + + attrs = ('value', 'msg') + + def setUpDecorator(self): + msg = ('Checking if %s is this MACHINE' % self.value) + self.logger.debug(msg) + if is_qemu(self.case.td, self.value): + self.case.skipTest(self.msg) + diff --git a/external/poky/meta/lib/oeqa/core/decorator/depends.py b/external/poky/meta/lib/oeqa/core/decorator/depends.py index 950dbaa6..33f0841c 100644 --- a/external/poky/meta/lib/oeqa/core/decorator/depends.py +++ b/external/poky/meta/lib/oeqa/core/decorator/depends.py @@ -1,5 +1,8 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# from unittest import SkipTest diff --git a/external/poky/meta/lib/oeqa/core/decorator/oeid.py b/external/poky/meta/lib/oeqa/core/decorator/oeid.py deleted file mode 100644 index ea8017a5..00000000 --- a/external/poky/meta/lib/oeqa/core/decorator/oeid.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) - -from . import OETestFilter, registerDecorator -from oeqa.core.utils.misc import intToList - -def _idFilter(oeid, filters): - return False if oeid in filters else True - -@registerDecorator -class OETestID(OETestFilter): - attrs = ('oeid',) - - def bind(self, registry, case): - super(OETestID, self).bind(registry, case) - - def filtrate(self, filters): - if filters.get('oeid'): - filterx = intToList(filters['oeid'], 'oeid') - del filters['oeid'] - if _idFilter(self.oeid, filterx): - return True - return False diff --git a/external/poky/meta/lib/oeqa/core/decorator/oetag.py b/external/poky/meta/lib/oeqa/core/decorator/oetag.py deleted file mode 100644 index ad38ab78..00000000 --- a/external/poky/meta/lib/oeqa/core/decorator/oetag.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) - -from . import OETestFilter, registerDecorator -from oeqa.core.utils.misc import strToList - -def _tagFilter(tags, filters): - return False if set(tags) & set(filters) else True - -@registerDecorator -class OETestTag(OETestFilter): - attrs = ('oetag',) - - def bind(self, registry, case): - super(OETestTag, self).bind(registry, case) - self.oetag = strToList(self.oetag, 'oetag') - - def filtrate(self, filters): - if filters.get('oetag'): - filterx = strToList(filters['oetag'], 'oetag') - del filters['oetag'] - if _tagFilter(self.oetag, filterx): - return True - return False diff --git a/external/poky/meta/lib/oeqa/core/decorator/oetimeout.py b/external/poky/meta/lib/oeqa/core/decorator/oetimeout.py index a247583f..df90d1c7 100644 --- a/external/poky/meta/lib/oeqa/core/decorator/oetimeout.py +++ b/external/poky/meta/lib/oeqa/core/decorator/oetimeout.py @@ -1,5 +1,8 @@ +# # Copyright (C) 2016 Intel Corporation -# Released under the MIT license (see COPYING.MIT) +# +# SPDX-License-Identifier: MIT +# import signal from . import OETestDecorator, registerDecorator |