aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-25 22:20:11 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-26 13:58:59 +0100
commitb59a2bbbf3c56b71f6118970ed2269dddfbdbe0c (patch)
treedee968ee46960e3f87791d070563ba902c26de2a
parent7cf314f3eb83750ec70f5b86045a5f5d195cddef (diff)
downloadopenembedded-core-contrib-b59a2bbbf3c56b71f6118970ed2269dddfbdbe0c.tar.gz
openembedded-core-contrib-b59a2bbbf3c56b71f6118970ed2269dddfbdbe0c.tar.bz2
openembedded-core-contrib-b59a2bbbf3c56b71f6118970ed2269dddfbdbe0c.zip
targetcontrol: Fix leaking log handler
We had a mystery failure on the autobuilder where runqemu appeared to be failing as a logfile directory no longer existed. The key to reproducing was running a runqemu where the image was deleted (as devtool does), then running another runqemu test. E.g.: 'oe-selftest -r devtool.DevtoolExtractTests.test_devtool_deploy_target wic.Wic2.test_qemu_efi' This then tries to write to the logfile from the first test, the image directory was deleted and we get strange failures. The fix is to remove the logging handler when qemu is stopped. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/targetcontrol.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index 0b2915d5ccd..2aa548e1ad2 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -117,9 +117,9 @@ class QemuTarget(BaseTarget):
import oe.path
bb.utils.mkdirhier(self.testdir)
self.qemurunnerlog = os.path.join(self.testdir, 'qemurunner_log.%s' % self.datetime)
- loggerhandler = logging.FileHandler(self.qemurunnerlog)
- loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
- self.logger.addHandler(loggerhandler)
+ self.loggerhandler = logging.FileHandler(self.qemurunnerlog)
+ self.loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
+ self.logger.addHandler(self.loggerhandler)
oe.path.symlink(os.path.basename(self.qemurunnerlog), os.path.join(self.testdir, 'qemurunner_log'), force=True)
if d.getVar("DISTRO") == "poky-tiny":
@@ -183,6 +183,7 @@ class QemuTarget(BaseTarget):
def stop(self):
self.runner.stop()
+ self.logger.removeHandler(self.loggerhandler)
self.connection = None
self.ip = None
self.server_ip = None