mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 18:49:32 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
46215bd89e
commit
90fa0fd4a7
@@ -13,7 +13,7 @@ import logging
|
|||||||
import errno
|
import errno
|
||||||
|
|
||||||
import oeqa.utils.ftools as ftools
|
import oeqa.utils.ftools as ftools
|
||||||
|
from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
|
||||||
|
|
||||||
class oeSelfTest(unittest.TestCase):
|
class oeSelfTest(unittest.TestCase):
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@ class oeSelfTest(unittest.TestCase):
|
|||||||
self.localconf_path = os.path.join(self.builddir, "conf/local.conf")
|
self.localconf_path = os.path.join(self.builddir, "conf/local.conf")
|
||||||
self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc")
|
self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc")
|
||||||
self.testlayer_path = oeSelfTest.testlayer_path
|
self.testlayer_path = oeSelfTest.testlayer_path
|
||||||
|
self._extra_tear_down_commands = []
|
||||||
super(oeSelfTest, self).__init__(methodName)
|
super(oeSelfTest, self).__init__(methodName)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -49,11 +50,26 @@ class oeSelfTest(unittest.TestCase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
if self._extra_tear_down_commands:
|
||||||
|
failed_extra_commands = []
|
||||||
|
for command in self._extra_tear_down_commands:
|
||||||
|
result = runCmd(command, ignore_status=True)
|
||||||
|
if not result.status == 0:
|
||||||
|
failed_extra_commands.append(command)
|
||||||
|
if failed_extra_commands:
|
||||||
|
self.log.warning("tearDown commands have failed: %s" % ', '.join(map(str, failed_extra_commands)))
|
||||||
|
self.log.debug("Trying to move on.")
|
||||||
|
self._extra_tear_down_commands = []
|
||||||
self.tearDownLocal()
|
self.tearDownLocal()
|
||||||
|
|
||||||
def tearDownLocal(self):
|
def tearDownLocal(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# add test specific commands to the tearDown method.
|
||||||
|
def add_command_to_tearDown(self, command):
|
||||||
|
self.log.debug("Adding command '%s' to tearDown for this test." % command)
|
||||||
|
self._extra_tear_down_commands.append(command)
|
||||||
|
|
||||||
# write to <builddir>/conf/selftest.inc
|
# write to <builddir>/conf/selftest.inc
|
||||||
def write_config(self, data):
|
def write_config(self, data):
|
||||||
self.log.debug("Writing to: %s\n%s\n" % (self.testinc_path, data))
|
self.log.debug("Writing to: %s\n%s\n" % (self.testinc_path, data))
|
||||||
|
|||||||
Reference in New Issue
Block a user