diff options
| author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2017-05-25 14:25:39 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-06 19:02:43 +0100 |
| commit | 628ba5801b2a7bcf1a3fb7249667976c342abe43 (patch) | |
| tree | 6fdb6048b20ff77f6bc3a6a3d59a4e582eaa02f2 | |
| parent | a80aa4c025cb9af621fae474e8f1361cdf7b124f (diff) | |
| download | poky-628ba5801b2a7bcf1a3fb7249667976c342abe43.tar.gz | |
scripts/oe-selftest: Move {add,remove}_include files to case
The oe-selftest creates include files to store custom configuration to
make specific tests, every class executes a different test and may be
uses custom configuration.
So move to case class in order to simplify oe-selftest script and later
implement later a build folder per class.
(From OE-Core rev: 1130b40c3dfa65e7ece08a95b3941e4d1d20bcf0)
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/lib/oeqa/selftest/case.py | 76 | ||||
| -rwxr-xr-x | scripts/oe-selftest | 54 |
2 files changed, 66 insertions, 64 deletions
diff --git a/meta/lib/oeqa/selftest/case.py b/meta/lib/oeqa/selftest/case.py index 95a8769bef..ca95b7e8b5 100644 --- a/meta/lib/oeqa/selftest/case.py +++ b/meta/lib/oeqa/selftest/case.py | |||
| @@ -14,17 +14,17 @@ from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer | |||
| 14 | from oeqa.core.case import OETestCase | 14 | from oeqa.core.case import OETestCase |
| 15 | 15 | ||
| 16 | class OESelftestTestCase(OETestCase): | 16 | class OESelftestTestCase(OETestCase): |
| 17 | builddir = os.environ.get("BUILDDIR") or "" | ||
| 18 | localconf_path = os.path.join(builddir, "conf/local.conf") | ||
| 19 | localconf_backup = os.path.join(builddir, "conf/local.bk") | ||
| 20 | testinc_path = os.path.join(builddir, "conf/selftest.inc") | ||
| 21 | local_bblayers_path = os.path.join(builddir, "conf/bblayers.conf") | ||
| 22 | local_bblayers_backup = os.path.join(builddir, "conf/bblayers.bk") | ||
| 23 | testinc_bblayers_path = os.path.join(builddir, "conf/bblayers.inc") | ||
| 24 | machineinc_path = os.path.join(builddir, "conf/machine.inc") | ||
| 25 | testlayer_path = get_test_layer() | ||
| 26 | |||
| 17 | def __init__(self, methodName="runTest"): | 27 | def __init__(self, methodName="runTest"): |
| 18 | self.builddir = os.environ.get("BUILDDIR") | ||
| 19 | self.localconf_path = os.path.join(self.builddir, "conf/local.conf") | ||
| 20 | self.localconf_backup = os.path.join(self.builddir, "conf/local.bk") | ||
| 21 | self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") | ||
| 22 | self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf") | ||
| 23 | self.local_bblayers_backup = os.path.join(self.builddir, | ||
| 24 | "conf/bblayers.bk") | ||
| 25 | self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc") | ||
| 26 | self.machineinc_path = os.path.join(self.builddir, "conf/machine.inc") | ||
| 27 | self.testlayer_path = get_test_layer() | ||
| 28 | self._extra_tear_down_commands = [] | 28 | self._extra_tear_down_commands = [] |
| 29 | self._track_for_cleanup = [ | 29 | self._track_for_cleanup = [ |
| 30 | self.testinc_path, self.testinc_bblayers_path, | 30 | self.testinc_path, self.testinc_bblayers_path, |
| @@ -33,6 +33,62 @@ class OESelftestTestCase(OETestCase): | |||
| 33 | 33 | ||
| 34 | super(OESelftestTestCase, self).__init__(methodName) | 34 | super(OESelftestTestCase, self).__init__(methodName) |
| 35 | 35 | ||
| 36 | @classmethod | ||
| 37 | def setUpClass(cls): | ||
| 38 | super(OESelftestTestCase, cls).setUpClass() | ||
| 39 | cls.add_include() | ||
| 40 | |||
| 41 | @classmethod | ||
| 42 | def tearDownClass(cls): | ||
| 43 | cls.remove_include() | ||
| 44 | cls.remove_inc_files() | ||
| 45 | super(OESelftestTestCase, cls).tearDownClass() | ||
| 46 | |||
| 47 | @classmethod | ||
| 48 | def add_include(cls): | ||
| 49 | if "#include added by oe-selftest" \ | ||
| 50 | not in ftools.read_file(os.path.join(cls.builddir, "conf/local.conf")): | ||
| 51 | cls.logger.info("Adding: \"include selftest.inc\" in %s" % os.path.join(cls.builddir, "conf/local.conf")) | ||
| 52 | ftools.append_file(os.path.join(cls.builddir, "conf/local.conf"), \ | ||
| 53 | "\n#include added by oe-selftest\ninclude machine.inc\ninclude selftest.inc") | ||
| 54 | |||
| 55 | if "#include added by oe-selftest" \ | ||
| 56 | not in ftools.read_file(os.path.join(cls.builddir, "conf/bblayers.conf")): | ||
| 57 | cls.logger.info("Adding: \"include bblayers.inc\" in bblayers.conf") | ||
| 58 | ftools.append_file(os.path.join(cls.builddir, "conf/bblayers.conf"), \ | ||
| 59 | "\n#include added by oe-selftest\ninclude bblayers.inc") | ||
| 60 | |||
| 61 | @classmethod | ||
| 62 | def remove_include(cls): | ||
| 63 | if "#include added by oe-selftest.py" \ | ||
| 64 | in ftools.read_file(os.path.join(cls.builddir, "conf/local.conf")): | ||
| 65 | cls.logger.info("Removing the include from local.conf") | ||
| 66 | ftools.remove_from_file(os.path.join(cls.builddir, "conf/local.conf"), \ | ||
| 67 | "\n#include added by oe-selftest.py\ninclude machine.inc\ninclude selftest.inc") | ||
| 68 | |||
| 69 | if "#include added by oe-selftest.py" \ | ||
| 70 | in ftools.read_file(os.path.join(cls.builddir, "conf/bblayers.conf")): | ||
| 71 | cls.logger.info("Removing the include from bblayers.conf") | ||
| 72 | ftools.remove_from_file(os.path.join(cls.builddir, "conf/bblayers.conf"), \ | ||
| 73 | "\n#include added by oe-selftest.py\ninclude bblayers.inc") | ||
| 74 | |||
| 75 | @classmethod | ||
| 76 | def remove_inc_files(cls): | ||
| 77 | try: | ||
| 78 | os.remove(os.path.join(cls.builddir, "conf/selftest.inc")) | ||
| 79 | for root, _, files in os.walk(get_test_layer()): | ||
| 80 | for f in files: | ||
| 81 | if f == 'test_recipe.inc': | ||
| 82 | os.remove(os.path.join(root, f)) | ||
| 83 | except OSError as e: | ||
| 84 | pass | ||
| 85 | |||
| 86 | for incl_file in ['conf/bblayers.inc', 'conf/machine.inc']: | ||
| 87 | try: | ||
| 88 | os.remove(os.path.join(cls.builddir, incl_file)) | ||
| 89 | except: | ||
| 90 | pass | ||
| 91 | |||
| 36 | def setUp(self): | 92 | def setUp(self): |
| 37 | super(OESelftestTestCase, self).setUp() | 93 | super(OESelftestTestCase, self).setUp() |
| 38 | os.chdir(self.builddir) | 94 | os.chdir(self.builddir) |
diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 52366b1c8d..490915759f 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest | |||
| @@ -159,56 +159,6 @@ def preflight_check(): | |||
| 159 | 159 | ||
| 160 | return True | 160 | return True |
| 161 | 161 | ||
| 162 | def add_include(): | ||
| 163 | global builddir | ||
| 164 | if "#include added by oe-selftest.py" \ | ||
| 165 | not in ftools.read_file(os.path.join(builddir, "conf/local.conf")): | ||
| 166 | log.info("Adding: \"include selftest.inc\" in local.conf") | ||
| 167 | ftools.append_file(os.path.join(builddir, "conf/local.conf"), \ | ||
| 168 | "\n#include added by oe-selftest.py\ninclude machine.inc\ninclude selftest.inc") | ||
| 169 | |||
| 170 | if "#include added by oe-selftest.py" \ | ||
| 171 | not in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")): | ||
| 172 | log.info("Adding: \"include bblayers.inc\" in bblayers.conf") | ||
| 173 | ftools.append_file(os.path.join(builddir, "conf/bblayers.conf"), \ | ||
| 174 | "\n#include added by oe-selftest.py\ninclude bblayers.inc") | ||
| 175 | |||
| 176 | def remove_include(): | ||
| 177 | global builddir | ||
| 178 | if builddir is None: | ||
| 179 | return | ||
| 180 | if "#include added by oe-selftest.py" \ | ||
| 181 | in ftools.read_file(os.path.join(builddir, "conf/local.conf")): | ||
| 182 | log.info("Removing the include from local.conf") | ||
| 183 | ftools.remove_from_file(os.path.join(builddir, "conf/local.conf"), \ | ||
| 184 | "\n#include added by oe-selftest.py\ninclude machine.inc\ninclude selftest.inc") | ||
| 185 | |||
| 186 | if "#include added by oe-selftest.py" \ | ||
| 187 | in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")): | ||
| 188 | log.info("Removing the include from bblayers.conf") | ||
| 189 | ftools.remove_from_file(os.path.join(builddir, "conf/bblayers.conf"), \ | ||
| 190 | "\n#include added by oe-selftest.py\ninclude bblayers.inc") | ||
| 191 | |||
| 192 | def remove_inc_files(): | ||
| 193 | global builddir | ||
| 194 | if builddir is None: | ||
| 195 | return | ||
| 196 | try: | ||
| 197 | os.remove(os.path.join(builddir, "conf/selftest.inc")) | ||
| 198 | for root, _, files in os.walk(get_test_layer()): | ||
| 199 | for f in files: | ||
| 200 | if f == 'test_recipe.inc': | ||
| 201 | os.remove(os.path.join(root, f)) | ||
| 202 | except OSError as e: | ||
| 203 | pass | ||
| 204 | |||
| 205 | for incl_file in ['conf/bblayers.inc', 'conf/machine.inc']: | ||
| 206 | try: | ||
| 207 | os.remove(os.path.join(builddir, incl_file)) | ||
| 208 | except: | ||
| 209 | pass | ||
| 210 | |||
| 211 | |||
| 212 | def get_tests_modules(include_hidden=False): | 162 | def get_tests_modules(include_hidden=False): |
| 213 | modules_list = list() | 163 | modules_list = list() |
| 214 | for modules_path in oeqa.selftest.__path__: | 164 | for modules_path in oeqa.selftest.__path__: |
| @@ -583,7 +533,6 @@ def main(): | |||
| 583 | log.error("Failed to import %s" % test) | 533 | log.error("Failed to import %s" % test) |
| 584 | log.error(e) | 534 | log.error(e) |
| 585 | return 1 | 535 | return 1 |
| 586 | add_include() | ||
| 587 | 536 | ||
| 588 | if args.machine: | 537 | if args.machine: |
| 589 | # Custom machine sets only weak default values (??=) for MACHINE in machine.inc | 538 | # Custom machine sets only weak default values (??=) for MACHINE in machine.inc |
| @@ -808,7 +757,4 @@ if __name__ == "__main__": | |||
| 808 | ret = 1 | 757 | ret = 1 |
| 809 | import traceback | 758 | import traceback |
| 810 | traceback.print_exc() | 759 | traceback.print_exc() |
| 811 | finally: | ||
| 812 | remove_include() | ||
| 813 | remove_inc_files() | ||
| 814 | sys.exit(ret) | 760 | sys.exit(ret) |
