Skip to contentSkip to conversation

selftest-hardlink: don't RDEPEND on gdb explicitly

PATCH New Ross Burton 1 participant 4 messages Dec 9, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 selftest-hardlink: don't RDEPEND on gdb explicitly

For easy of reuse and speed of building, don't RDEPEND on gdb explicitly. Instead put gdb.sh into ${PN} and explicitly install gdb into the image if needed.

This means other tests that don't need to use gdb can reuse this recipe without waiting for a target gdb to build.

---
 .../recipes-test/selftest-hardlink/selftest-hardlink.bb       | 4 ----
 meta/lib/oeqa/selftest/cases/package.py                       | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)
meta-selftest/recipes-test/selftest-hardlink/selftest-hardlink.bb +0 -4
index 842a9772cbe..8b336a04c9f 100644
@@ -24,7 +24,3 @@ do_install () {
 
 	dd if=/dev/zero of=${D}${bindir}/sparsetest bs=1 count=0 seek=1M
 }
-
-RDEPENDS_${PN}-gdb += "gdb"
-PACKAGES =+ "${PN}-gdb"
-FILES_${PN}-gdb = "${bindir}/gdb.sh"
meta/lib/oeqa/selftest/cases/package.py +1 -1
index b87f8dc3e2c..c6444062674 100644
@@ -118,7 +118,7 @@ class PackageTests(OESelftestTestCase):
     def test_gdb_hardlink_debug(self):
         features = 'IMAGE_INSTALL_append = " selftest-hardlink"\n'
         features += 'IMAGE_INSTALL_append = " selftest-hardlink-dbg"\n'
-        features += 'IMAGE_INSTALL_append = " selftest-hardlink-gdb"\n'
+        features += 'IMAGE_INSTALL_append = " gdb"\n'
         self.write_config(features)
         bitbake("core-image-minimal")
 
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/4 oeqa: add insane package walk test

For reassurance when changing the insane.bbclass package walking code, add a sanity test to verify that the file listing is what is expected.

---
 meta-selftest/classes/insane-test.bbclass |  4 +++
 meta/lib/oeqa/selftest/cases/package.py   | 38 +++++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 meta-selftest/classes/insane-test.bbclass
meta-selftest/classes/insane-test.bbclass new file +4 -0
new file mode 100644
index 00000000000..aafb0031a5b
@@ -0,0 +1,4 @@
+QAPATHTEST[selftest-walk] = "package_qa_check_selftest_walk"
+def package_qa_check_selftest_walk(path, pkg, d, elf, messages):
+    path = package_qa_clean_path(path, d, pkg)
+    bb.warn("WALK %s %s %s" % (pkg, path, "ELF" if elf else "FILE"))
meta/lib/oeqa/selftest/cases/package.py +38 -0
index c6444062674..d9725b4f2a3 100644
@@ -148,3 +148,41 @@ class PackageTests(OESelftestTestCase):
                            '/usr/libexec/hello4']:
                 if not gdbtest(qemu, binary):
                     self.fail('GDB %s failed' % binary)
+
+
+class InsaneTest(OESelftestTestCase):
+    def test_insane_package_walk(self):
+        """
+        Check that the package walking in insane.bbclass is listing the files we
+        expect.
+        """
+
+        import re
+
+        config = """
+INHERIT += "insane-test"
+WARN_QA_append_pn-selftest-hardlink = " selftest-walk"
+        """
+        self.write_config(config)
+
+        result = bitbake("selftest-hardlink -c package_qa -f")
+        expected = set((
+            "selftest-hardlink:/usr/libexec/hello3:ELF",
+            "selftest-hardlink:/usr/libexec/hello4:ELF",
+            "selftest-hardlink:/usr/bin/sparsetest:FILE",
+            "selftest-hardlink:/usr/bin/gdb.sh:FILE",
+            "selftest-hardlink:/usr/bin/hello1:ELF",
+            "selftest-hardlink:/usr/bin/hello2:ELF",
+            "selftest-hardlink-dbg:/usr/libexec/.debug/hello1:ELF",
+            "selftest-hardlink-dbg:/usr/bin/.debug/hello1:ELF",
+            "selftest-hardlink-src:/usr/src/debug/selftest-hardlink/1.0-r0/hello.c:FILE"
+        ))
+
+        line_re = re.compile(r"^WARNING: WALK (.+) (.+) (FILE|ELF)$")
+        for line in result.output.splitlines():
+            m = line_re.match(line)
+            if m:
+                expected.remove(":".join(m.groups()))
+
+        if expected:
+            self.fail("Not all files were listed: " + str(expected))
Signature · 1 line
2.20.1
#2 lore raw

PATCH 3/4 rootfs: don't use oe.cachedpath

In reply to Ross Burton

Unless cachedpath is used correctly then it's just a glorified clone of os.walk, but without any of the recent optimisations in os.walk. In this codepath there is no point to using cachedpath.

---
 meta/lib/oe/rootfs.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
meta/lib/oe/rootfs.py +2 -3
index c62fa5f54ad..cd65e620300 100644
@@ -126,17 +126,16 @@ class Rootfs(object, metaclass=ABCMeta):
             bb.utils.mkdirhier(self.image_rootfs + os.path.dirname(dir))
             shutil.copytree(self.image_rootfs + '-orig' + dir, self.image_rootfs + dir, symlinks=True)
 
-        cpath = oe.cachedpath.CachedPath()
         # Copy files located in /usr/lib/debug or /usr/src/debug
         for dir in ["/usr/lib/debug", "/usr/src/debug"]:
             src = self.image_rootfs + '-orig' + dir
-            if cpath.exists(src):
+            if os.path.exists(src):
                 dst = self.image_rootfs + dir
                 bb.utils.mkdirhier(os.path.dirname(dst))
                 shutil.copytree(src, dst)
 
         # Copy files with suffix '.debug' or located in '.debug' dir.
-        for root, dirs, files in cpath.walk(self.image_rootfs + '-orig'):
+        for root, dirs, files in os.walk(self.image_rootfs + '-orig'):
             relative_dir = root[len(self.image_rootfs + '-orig'):]
             for f in files:
                 if f.endswith('.debug') or '/.debug' in relative_dir:
Signature · 1 line
2.20.1
#3 lore raw

PATCH 4/4 insane: don't use cachedpath

In reply to Ross Burton

Unless cachedpath is used correctly then it's just a glorified clone of os.walk, but without any of the recent optimisations in os.walk. In this codepath there is no point to using cachedpath.

---
 meta/classes/insane.bbclass | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
meta/classes/insane.bbclass +2 -3
index 0564f9c2a41..723348fc8e7 100644
@@ -937,14 +937,13 @@ python do_package_qa () {
     pkgdest = d.getVar('PKGDEST')
     packages = set((d.getVar('PACKAGES') or '').split())
 
-    cpath = oe.cachedpath.CachedPath()
     global pkgfiles
     pkgfiles = {}
     for pkg in packages:
         pkgfiles[pkg] = []
-        for walkroot, dirs, files in cpath.walk(pkgdest + "/" + pkg):
+        for walkroot, dirs, files in os.walk(os.path.join(pkgdest, pkg)):
             for file in files:
-                pkgfiles[pkg].append(walkroot + os.sep + file)
+                pkgfiles[pkg].append(os.path.join(walkroot, file))
 
     # no packages should be scanned
     if not packages:
Signature · 1 line
2.20.1