summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2018-12-03 20:35:14 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-05 12:34:06 +0000
commitdb0e658097130d146752785d0d45f46a3e0bad71 (patch)
tree8211778535bc1c2b1f553dcdb718007e5585f3f6
parent8e7d756862d2a8d62f3c87497d6d65ddb3c1b962 (diff)
downloadopenembedded-core-contrib-db0e658097130d146752785d0d45f46a3e0bad71.tar.gz
openembedded-core-contrib-db0e658097130d146752785d0d45f46a3e0bad71.tar.bz2
openembedded-core-contrib-db0e658097130d146752785d0d45f46a3e0bad71.zip
oeqa: don't litter /tmp with temporary directories
If we need to create a temporary directory in targetbuild or buildproject use tempfile.TemporaryDirectory so that when the test case is finished, the directory is deleted. Also synchronise the logic and don't possibly store the temporary directory in self.tmpdir as nothing uses that. Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/utils/buildproject.py3
-rw-r--r--meta/lib/oeqa/utils/targetbuild.py5
2 files changed, 5 insertions, 3 deletions
diff --git a/meta/lib/oeqa/utils/buildproject.py b/meta/lib/oeqa/utils/buildproject.py
index 7e9b84955f..01a803ab61 100644
--- a/meta/lib/oeqa/utils/buildproject.py
+++ b/meta/lib/oeqa/utils/buildproject.py
@@ -17,7 +17,8 @@ class BuildProject(metaclass=ABCMeta):
self.uri = uri
self.archive = os.path.basename(uri)
if not tmpdir:
- tmpdir = tempfile.mkdtemp(prefix='buildproject')
+ self.tempdirobj = tempfile.TemporaryDirectory(prefix='buildproject-')
+ tmpdir = self.tempdirobj.name
self.localarchive = os.path.join(tmpdir, self.archive)
self.dl_dir = dl_dir
if foldername:
diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py
index 1202d579fb..b8db7b2aca 100644
--- a/meta/lib/oeqa/utils/targetbuild.py
+++ b/meta/lib/oeqa/utils/targetbuild.py
@@ -20,8 +20,9 @@ class BuildProject(metaclass=ABCMeta):
if not tmpdir:
tmpdir = self.d.getVar('WORKDIR')
if not tmpdir:
- tmpdir = tempfile.mkdtemp(prefix='buildproject')
- self.localarchive = os.path.join(tmpdir,self.archive)
+ self.tempdirobj = tempfile.TemporaryDirectory(prefix='buildproject-')
+ tmpdir = self.tempdirobj.name
+ self.localarchive = os.path.join(tmpdir, self.archive)
if foldername:
self.fname = foldername
else: