diff options
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r-- | meta/lib/oeqa/selftest/base.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py index c3474a3da6..25ca84bd66 100644 --- a/meta/lib/oeqa/selftest/base.py +++ b/meta/lib/oeqa/selftest/base.py | |||
@@ -13,7 +13,7 @@ import logging | |||
13 | import errno | 13 | import errno |
14 | 14 | ||
15 | import oeqa.utils.ftools as ftools | 15 | import oeqa.utils.ftools as ftools |
16 | 16 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer | |
17 | 17 | ||
18 | class oeSelfTest(unittest.TestCase): | 18 | class oeSelfTest(unittest.TestCase): |
19 | 19 | ||
@@ -25,6 +25,7 @@ class oeSelfTest(unittest.TestCase): | |||
25 | self.localconf_path = os.path.join(self.builddir, "conf/local.conf") | 25 | self.localconf_path = os.path.join(self.builddir, "conf/local.conf") |
26 | self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") | 26 | self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") |
27 | self.testlayer_path = oeSelfTest.testlayer_path | 27 | self.testlayer_path = oeSelfTest.testlayer_path |
28 | self._extra_tear_down_commands = [] | ||
28 | super(oeSelfTest, self).__init__(methodName) | 29 | super(oeSelfTest, self).__init__(methodName) |
29 | 30 | ||
30 | def setUp(self): | 31 | def setUp(self): |
@@ -49,11 +50,26 @@ class oeSelfTest(unittest.TestCase): | |||
49 | pass | 50 | pass |
50 | 51 | ||
51 | def tearDown(self): | 52 | def tearDown(self): |
53 | if self._extra_tear_down_commands: | ||
54 | failed_extra_commands = [] | ||
55 | for command in self._extra_tear_down_commands: | ||
56 | result = runCmd(command, ignore_status=True) | ||
57 | if not result.status == 0: | ||
58 | failed_extra_commands.append(command) | ||
59 | if failed_extra_commands: | ||
60 | self.log.warning("tearDown commands have failed: %s" % ', '.join(map(str, failed_extra_commands))) | ||
61 | self.log.debug("Trying to move on.") | ||
62 | self._extra_tear_down_commands = [] | ||
52 | self.tearDownLocal() | 63 | self.tearDownLocal() |
53 | 64 | ||
54 | def tearDownLocal(self): | 65 | def tearDownLocal(self): |
55 | pass | 66 | pass |
56 | 67 | ||
68 | # add test specific commands to the tearDown method. | ||
69 | def add_command_to_tearDown(self, command): | ||
70 | self.log.debug("Adding command '%s' to tearDown for this test." % command) | ||
71 | self._extra_tear_down_commands.append(command) | ||
72 | |||
57 | # write to <builddir>/conf/selftest.inc | 73 | # write to <builddir>/conf/selftest.inc |
58 | def write_config(self, data): | 74 | def write_config(self, data): |
59 | self.log.debug("Writing to: %s\n%s\n" % (self.testinc_path, data)) | 75 | self.log.debug("Writing to: %s\n%s\n" % (self.testinc_path, data)) |