diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-02-19 18:32:19 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-02-21 09:39:00 +0000 |
commit | bf745476ea75da66ba7a5d78a017e0ae2648a6da (patch) | |
tree | 2de5a87ea6f9a58da9e2b520d0f63ef91ba55af0 | |
parent | c569157d9d8aa43eddb98e9fbe66339bf7f20958 (diff) | |
download | poky-bf745476ea75da66ba7a5d78a017e0ae2648a6da.tar.gz |
oeqa/selftest: Drop 'backup' code and SIGTERM handler
Now selftest is using its own copied build directory, we can stop worrying about
copying files around as backup, and drop the SIGTERM handler to try and restore
them, simplifying the code.
(From OE-Core rev: b8ea8a910267fee4bb9e57f24ba829064e22d016)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/selftest/case.py | 30 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/context.py | 47 |
2 files changed, 4 insertions, 73 deletions
diff --git a/meta/lib/oeqa/selftest/case.py b/meta/lib/oeqa/selftest/case.py index ac3308d8a4..dcad4f76ec 100644 --- a/meta/lib/oeqa/selftest/case.py +++ b/meta/lib/oeqa/selftest/case.py | |||
@@ -6,7 +6,6 @@ | |||
6 | 6 | ||
7 | import sys | 7 | import sys |
8 | import os | 8 | import os |
9 | import shutil | ||
10 | import glob | 9 | import glob |
11 | import errno | 10 | import errno |
12 | from unittest.util import safe_repr | 11 | from unittest.util import safe_repr |
@@ -30,9 +29,7 @@ class OESelftestTestCase(OETestCase): | |||
30 | cls.builddir = cls.tc.config_paths['builddir'] | 29 | cls.builddir = cls.tc.config_paths['builddir'] |
31 | 30 | ||
32 | cls.localconf_path = cls.tc.config_paths['localconf'] | 31 | cls.localconf_path = cls.tc.config_paths['localconf'] |
33 | cls.localconf_backup = cls.tc.config_paths['localconf_class_backup'] | ||
34 | cls.local_bblayers_path = cls.tc.config_paths['bblayers'] | 32 | cls.local_bblayers_path = cls.tc.config_paths['bblayers'] |
35 | cls.local_bblayers_backup = cls.tc.config_paths['bblayers_class_backup'] | ||
36 | 33 | ||
37 | cls.testinc_path = os.path.join(cls.tc.config_paths['builddir'], | 34 | cls.testinc_path = os.path.join(cls.tc.config_paths['builddir'], |
38 | "conf/selftest.inc") | 35 | "conf/selftest.inc") |
@@ -43,8 +40,7 @@ class OESelftestTestCase(OETestCase): | |||
43 | 40 | ||
44 | cls._track_for_cleanup = [ | 41 | cls._track_for_cleanup = [ |
45 | cls.testinc_path, cls.testinc_bblayers_path, | 42 | cls.testinc_path, cls.testinc_bblayers_path, |
46 | cls.machineinc_path, cls.localconf_backup, | 43 | cls.machineinc_path] |
47 | cls.local_bblayers_backup] | ||
48 | 44 | ||
49 | cls.add_include() | 45 | cls.add_include() |
50 | 46 | ||
@@ -102,30 +98,6 @@ class OESelftestTestCase(OETestCase): | |||
102 | def setUp(self): | 98 | def setUp(self): |
103 | super(OESelftestTestCase, self).setUp() | 99 | super(OESelftestTestCase, self).setUp() |
104 | os.chdir(self.builddir) | 100 | os.chdir(self.builddir) |
105 | # Check if local.conf or bblayers.conf files backup exists | ||
106 | # from a previous failed test and restore them | ||
107 | if os.path.isfile(self.localconf_backup) or os.path.isfile( | ||
108 | self.local_bblayers_backup): | ||
109 | self.logger.debug("\ | ||
110 | Found a local.conf and/or bblayers.conf backup from a previously aborted test.\ | ||
111 | Restoring these files now, but tests should be re-executed from a clean environment\ | ||
112 | to ensure accurate results.") | ||
113 | try: | ||
114 | shutil.copyfile(self.localconf_backup, self.localconf_path) | ||
115 | except OSError as e: | ||
116 | if e.errno != errno.ENOENT: | ||
117 | raise | ||
118 | try: | ||
119 | shutil.copyfile(self.local_bblayers_backup, | ||
120 | self.local_bblayers_path) | ||
121 | except OSError as e: | ||
122 | if e.errno != errno.ENOENT: | ||
123 | raise | ||
124 | else: | ||
125 | # backup local.conf and bblayers.conf | ||
126 | shutil.copyfile(self.localconf_path, self.localconf_backup) | ||
127 | shutil.copyfile(self.local_bblayers_path, self.local_bblayers_backup) | ||
128 | self.logger.debug("Creating local.conf and bblayers.conf backups.") | ||
129 | # we don't know what the previous test left around in config or inc files | 101 | # we don't know what the previous test left around in config or inc files |
130 | # if it failed so we need a fresh start | 102 | # if it failed so we need a fresh start |
131 | try: | 103 | try: |
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py index cd893261d3..409698d57c 100644 --- a/meta/lib/oeqa/selftest/context.py +++ b/meta/lib/oeqa/selftest/context.py | |||
@@ -9,9 +9,7 @@ import time | |||
9 | import glob | 9 | import glob |
10 | import sys | 10 | import sys |
11 | import importlib | 11 | import importlib |
12 | import signal | ||
13 | import subprocess | 12 | import subprocess |
14 | from shutil import copyfile | ||
15 | from random import choice | 13 | from random import choice |
16 | 14 | ||
17 | import oeqa | 15 | import oeqa |
@@ -185,26 +183,10 @@ class OESelftestTestContextExecutor(OETestContextExecutor): | |||
185 | 183 | ||
186 | builddir = os.environ.get("BUILDDIR") | 184 | builddir = os.environ.get("BUILDDIR") |
187 | self.tc_kwargs['init']['config_paths'] = {} | 185 | self.tc_kwargs['init']['config_paths'] = {} |
188 | self.tc_kwargs['init']['config_paths']['testlayer_path'] = \ | 186 | self.tc_kwargs['init']['config_paths']['testlayer_path'] = get_test_layer() |
189 | get_test_layer() | ||
190 | self.tc_kwargs['init']['config_paths']['builddir'] = builddir | 187 | self.tc_kwargs['init']['config_paths']['builddir'] = builddir |
191 | self.tc_kwargs['init']['config_paths']['localconf'] = \ | 188 | self.tc_kwargs['init']['config_paths']['localconf'] = os.path.join(builddir, "conf/local.conf") |
192 | os.path.join(builddir, "conf/local.conf") | 189 | self.tc_kwargs['init']['config_paths']['bblayers'] = os.path.join(builddir, "conf/bblayers.conf") |
193 | self.tc_kwargs['init']['config_paths']['localconf_backup'] = \ | ||
194 | os.path.join(builddir, "conf/local.conf.orig") | ||
195 | self.tc_kwargs['init']['config_paths']['localconf_class_backup'] = \ | ||
196 | os.path.join(builddir, "conf/local.conf.bk") | ||
197 | self.tc_kwargs['init']['config_paths']['bblayers'] = \ | ||
198 | os.path.join(builddir, "conf/bblayers.conf") | ||
199 | self.tc_kwargs['init']['config_paths']['bblayers_backup'] = \ | ||
200 | os.path.join(builddir, "conf/bblayers.conf.orig") | ||
201 | self.tc_kwargs['init']['config_paths']['bblayers_class_backup'] = \ | ||
202 | os.path.join(builddir, "conf/bblayers.conf.bk") | ||
203 | |||
204 | copyfile(self.tc_kwargs['init']['config_paths']['localconf'], | ||
205 | self.tc_kwargs['init']['config_paths']['localconf_backup']) | ||
206 | copyfile(self.tc_kwargs['init']['config_paths']['bblayers'], | ||
207 | self.tc_kwargs['init']['config_paths']['bblayers_backup']) | ||
208 | 190 | ||
209 | def tag_filter(tags): | 191 | def tag_filter(tags): |
210 | if args.exclude_tags: | 192 | if args.exclude_tags: |
@@ -329,18 +311,9 @@ class OESelftestTestContextExecutor(OETestContextExecutor): | |||
329 | 311 | ||
330 | return rc | 312 | return rc |
331 | 313 | ||
332 | def _signal_clean_handler(self, signum, frame): | ||
333 | if self.ourpid == os.getpid(): | ||
334 | sys.exit(1) | ||
335 | |||
336 | def run(self, logger, args): | 314 | def run(self, logger, args): |
337 | self._process_args(logger, args) | 315 | self._process_args(logger, args) |
338 | 316 | ||
339 | # Setup a SIGTERM handler to allow restoration of files like local.conf and bblayers.conf | ||
340 | # but don't interfer with other processes | ||
341 | self.ourpid = os.getpid() | ||
342 | signal.signal(signal.SIGTERM, self._signal_clean_handler) | ||
343 | |||
344 | rc = None | 317 | rc = None |
345 | try: | 318 | try: |
346 | if args.machine: | 319 | if args.machine: |
@@ -369,20 +342,6 @@ class OESelftestTestContextExecutor(OETestContextExecutor): | |||
369 | rc = self._internal_run(logger, args) | 342 | rc = self._internal_run(logger, args) |
370 | finally: | 343 | finally: |
371 | config_paths = self.tc_kwargs['init']['config_paths'] | 344 | config_paths = self.tc_kwargs['init']['config_paths'] |
372 | if os.path.exists(config_paths['localconf_backup']): | ||
373 | copyfile(config_paths['localconf_backup'], | ||
374 | config_paths['localconf']) | ||
375 | os.remove(config_paths['localconf_backup']) | ||
376 | |||
377 | if os.path.exists(config_paths['bblayers_backup']): | ||
378 | copyfile(config_paths['bblayers_backup'], | ||
379 | config_paths['bblayers']) | ||
380 | os.remove(config_paths['bblayers_backup']) | ||
381 | |||
382 | if os.path.exists(config_paths['localconf_class_backup']): | ||
383 | os.remove(config_paths['localconf_class_backup']) | ||
384 | if os.path.exists(config_paths['bblayers_class_backup']): | ||
385 | os.remove(config_paths['bblayers_class_backup']) | ||
386 | 345 | ||
387 | output_link = os.path.join(os.path.dirname(args.output_log), | 346 | output_link = os.path.join(os.path.dirname(args.output_log), |
388 | "%s-results.log" % self.name) | 347 | "%s-results.log" % self.name) |