summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorCorneliu Stoicescu <corneliux.stoicescu@intel.com>2013-12-11 17:09:39 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-14 09:11:17 +0000
commit90fa0fd4a7b071e914d0dabe8f9a3fc551c189b8 (patch)
tree7927a1052fd29fbaecd4f4c0b2a378c01c10238e /meta/lib/oeqa
parent46215bd89e2e1136d6af7bacd5931952ee21716b (diff)
downloadpoky-90fa0fd4a7b071e914d0dabe8f9a3fc551c189b8.tar.gz
oe-selftest: implement add_command_to_tearDown method
Add a new method that can be used by the tester to add a command to the executed in the tearDown stage of the test. This mechanism can be used to make sure certain test-specific cleanup tasks are done in the case of a test failure. (From OE-Core rev: b59466ec341e6596b7ade7f1813b25e454b11a32) Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/selftest/base.py18
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
13import errno 13import errno
14 14
15import oeqa.utils.ftools as ftools 15import oeqa.utils.ftools as ftools
16 16from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
17 17
18class oeSelfTest(unittest.TestCase): 18class 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))