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 /meta/lib | |
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>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/selftest/case.py | 76 |
1 files changed, 66 insertions, 10 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) |