Skip to contentSkip to conversation

oeqa: don't litter /tmp with temporary directories

PATCH New Ross Burton 1 participant 3 messages Dec 3, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 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.

---
 meta/lib/oeqa/utils/buildproject.py | 5 ++++-
 meta/lib/oeqa/utils/targetbuild.py  | 5 +++--
 2 files changed, 7 insertions(+), 3 deletions(-)
meta/lib/oeqa/utils/buildproject.py +4 -1
index 7e9b84955f5..524015ede4b 100644
@@ -17,7 +17,10 @@ class BuildProject(metaclass=ABCMeta):
         self.uri = uri
         self.archive = os.path.basename(uri)
         if not tmpdir:
-            tmpdir = tempfile.mkdtemp(prefix='buildproject')
+            tmpdir = self.d.getVar('WORKDIR')
+            if not tmpdir:
+                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:
meta/lib/oeqa/utils/targetbuild.py +3 -2
index 1202d579fb0..b8db7b2aca0 100644
@@ -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:
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/3 oeqa/selftest/esdk: run selftest inside workdir not /tmp

---
 meta/lib/oeqa/selftest/cases/eSDK.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/lib/oeqa/selftest/cases/eSDK.py +7 -6
index d03188f2f75..14f75d8c09a 100644
@@ -70,11 +70,12 @@ CORE_IMAGE_EXTRA_INSTALL = "perl"
     @classmethod
     def setUpClass(cls):
         super(oeSDKExtSelfTest, cls).setUpClass()
-        cls.tmpdir_eSDKQA = tempfile.mkdtemp(prefix='eSDKQA')
+        cls.image = 'core-image-minimal'
 
-        sstate_dir = get_bb_var('SSTATE_DIR')
+        bb_vars = get_bb_vars(['SSTATE_DIR', 'WORKDIR'], cls.image)
+        cls.tmpdirobj = tempfile.TemporaryDirectory(prefix="selftest-esdk-", dir=bb_vars["WORKDIR"])
+        cls.tmpdir_eSDKQA = cls.tempdirobj.name
 
-        cls.image = 'core-image-minimal'
         oeSDKExtSelfTest.generate_eSDK(cls.image)
 
         # Install eSDK
@@ -87,14 +88,14 @@ CORE_IMAGE_EXTRA_INSTALL = "perl"
         sstate_config="""
 SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
 SSTATE_MIRRORS =  "file://.* file://%s/PATH"
-            """ % sstate_dir
+            """ % bb_vars["SSTATE_DIR"]
         with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
             f.write(sstate_config)
 
     @classmethod
     def tearDownClass(cls):
-        shutil.rmtree(cls.tmpdir_eSDKQA, ignore_errors=True)
-        super(oeSDKExtSelfTest, cls).tearDownClass()
+        cls.tmpdirobj.cleanup()
+        super().tearDownClass()
 
     @OETestID(1602)
     def test_install_libraries_headers(self):
Signature · 1 line
2.11.0
#2 lore raw

PATCH 3/3 insane: clarify GNU_HASH warning

In reply to Ross Burton

We have a fatal error if ELF objects don't have GNU_HASH segments don't don't explain what the problem is. At least give a hint to users by suggesting that LDFLAGS wasn't passed to the compiler.

---
 meta/classes/insane.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/insane.bbclass +1 -1
index 4644221bc6b..6718feb3af5 100644
@@ -383,7 +383,7 @@ def package_qa_hash_style(path, name, d, elf, messages):
             sane = True
 
     if has_syms and not sane:
-        package_qa_add_message(messages, "ldflags", "No GNU_HASH in the elf binary: '%s'" % path)
+        package_qa_add_message(messages, "ldflags", "No GNU_HASH in the ELF binary %s, didn't pass LDFLAGS?" % path)
 
 
 QAPATHTEST[buildpaths] = "package_qa_check_buildpaths"
Signature · 1 line
2.11.0