summaryrefslogtreecommitdiffstats
path: root/meta
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:37:02 +0000
commitaffd7388f31813b7cb5f376905b13be6c4cbf0d1 (patch)
tree930774b8843497276dafd3eae35cbf2b2f305b17 /meta
parent8cd28e2f3fc3f1565287614666cfcb9eb13fdfd5 (diff)
downloadpoky-affd7388f31813b7cb5f376905b13be6c4cbf0d1.tar.gz
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. (From OE-Core rev: db0e658097130d146752785d0d45f46a3e0bad71) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-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):
17 self.uri = uri 17 self.uri = uri
18 self.archive = os.path.basename(uri) 18 self.archive = os.path.basename(uri)
19 if not tmpdir: 19 if not tmpdir:
20 tmpdir = tempfile.mkdtemp(prefix='buildproject') 20 self.tempdirobj = tempfile.TemporaryDirectory(prefix='buildproject-')
21 tmpdir = self.tempdirobj.name
21 self.localarchive = os.path.join(tmpdir, self.archive) 22 self.localarchive = os.path.join(tmpdir, self.archive)
22 self.dl_dir = dl_dir 23 self.dl_dir = dl_dir
23 if foldername: 24 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):
20 if not tmpdir: 20 if not tmpdir:
21 tmpdir = self.d.getVar('WORKDIR') 21 tmpdir = self.d.getVar('WORKDIR')
22 if not tmpdir: 22 if not tmpdir:
23 tmpdir = tempfile.mkdtemp(prefix='buildproject') 23 self.tempdirobj = tempfile.TemporaryDirectory(prefix='buildproject-')
24 self.localarchive = os.path.join(tmpdir,self.archive) 24 tmpdir = self.tempdirobj.name
25 self.localarchive = os.path.join(tmpdir, self.archive)
25 if foldername: 26 if foldername:
26 self.fname = foldername 27 self.fname = foldername
27 else: 28 else: