diff options
author | Ross Burton <ross.burton@intel.com> | 2018-12-03 11:47:58 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-12-16 14:31:33 +0000 |
commit | 72d7b5b5d409e9de83a6428d07e12d2ee0e2f810 (patch) | |
tree | 3de8b824983d958af535f774a62847682d7bd2f0 /meta/lib/oeqa/selftest | |
parent | 3c27f3b3a76e3cb11faf119a4edb3c96e9e7e607 (diff) | |
download | poky-72d7b5b5d409e9de83a6428d07e12d2ee0e2f810.tar.gz |
oeqa/oelib/path: don't leak temporary directories
setUp() is used to populate a directory of temporary files, and deleted in
__del__. However setUp() is called once *per test* so __del__ would only be
able to remove the last directory created.
Fix the code by using the natural counterpart to setUp, tearDown(), to clean up.
(From OE-Core rev: 68b4723e6fb11d171869185bccf28f32f6284c18)
(From OE-Core rev: eee30d799ff892443d21de4128e7d643215b0ac1)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/oelib/path.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/meta/lib/oeqa/selftest/cases/oelib/path.py b/meta/lib/oeqa/selftest/cases/oelib/path.py index 75a27c06f7..e0eb8134a9 100644 --- a/meta/lib/oeqa/selftest/cases/oelib/path.py +++ b/meta/lib/oeqa/selftest/cases/oelib/path.py | |||
@@ -38,13 +38,6 @@ class TestRealPath(TestCase): | |||
38 | ( "b/test", errno.ENOENT ), | 38 | ( "b/test", errno.ENOENT ), |
39 | ] | 39 | ] |
40 | 40 | ||
41 | def __del__(self): | ||
42 | try: | ||
43 | #os.system("tree -F %s" % self.tmpdir) | ||
44 | shutil.rmtree(self.tmpdir) | ||
45 | except: | ||
46 | pass | ||
47 | |||
48 | def setUp(self): | 41 | def setUp(self): |
49 | self.tmpdir = tempfile.mkdtemp(prefix = "oe-test_path") | 42 | self.tmpdir = tempfile.mkdtemp(prefix = "oe-test_path") |
50 | self.root = os.path.join(self.tmpdir, "R") | 43 | self.root = os.path.join(self.tmpdir, "R") |
@@ -59,6 +52,9 @@ class TestRealPath(TestCase): | |||
59 | for l in self.LINKS: | 52 | for l in self.LINKS: |
60 | os.symlink(l[1], os.path.join(self.root, l[0])) | 53 | os.symlink(l[1], os.path.join(self.root, l[0])) |
61 | 54 | ||
55 | def tearDown(self): | ||
56 | shutil.rmtree(self.tmpdir) | ||
57 | |||
62 | def __realpath(self, file, use_physdir, assume_dir = True): | 58 | def __realpath(self, file, use_physdir, assume_dir = True): |
63 | return oe.path.realpath(os.path.join(self.root, file), self.root, | 59 | return oe.path.realpath(os.path.join(self.root, file), self.root, |
64 | use_physdir, assume_dir = assume_dir) | 60 | use_physdir, assume_dir = assume_dir) |