]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
dpkg: add ptest support
authorGyorgy Sarvari <skandigraun@gmail.com>
Thu, 7 Aug 2025 20:13:50 +0000 (22:13 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 11 Aug 2025 17:03:13 +0000 (18:03 +0100)
Added it to slow tests, as it takes betwen 165 and 190 seconds on my
machine to execute (qemux86-64 + kvm).

The test folder's Makefile contains a list of passing, failing and manual
tests. By default, only the expected-to-pass tests are executed by the
Makefile (unless magic environment variable is set).

The run-ptest script mimics the default behavior of executing the
expected-to-pass tests, however they are executed one by one, instead of
running them as one batch - that way it is easier to determine exactly
which tests pass and which fail.

One other thing that might worth a note, is that the tests folder that needs to be
installed contains a number of subfolders called "DEBIAN". When packaging them
at least with rpm, these folders are omitted from the package.
However these are essential for the tests, as they contain test data. As a
workaround, these folders are renamed during installation to DEBIAN-ptest,
and before execution the run-ptest script restores their names.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
meta/conf/distro/include/ptest-packagelists.inc
meta/recipes-devtools/dpkg/dpkg.inc
meta/recipes-devtools/dpkg/dpkg/run-ptest [new file with mode: 0644]
meta/recipes-devtools/dpkg/dpkg_1.22.21.bb

index 85c03501614736e9175636629f9c08ad641f24a3..e3099439f4c973250e654f8fe6c34d55cf7bda70 100644 (file)
@@ -101,6 +101,7 @@ PTESTS_SLOW = "\
     curl \
     dbus \
     dosfstools \
+    dpkg \
     e2fsprogs \
     elfutils \
     gettext \
index dea1894a4c870cc4cab3f1adbd42504fbdb027a9..b4e9667107e3e5f36a40ba625e63c8941462ffe0 100644 (file)
@@ -11,7 +11,7 @@ RDEPENDS:${PN}:class-native = ""
 
 UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>(\d+(\.\d+)+))"
 
-inherit autotools gettext perlnative pkgconfig perl-version update-alternatives bash-completion
+inherit autotools gettext perlnative pkgconfig perl-version ptest update-alternatives bash-completion
 
 PERL:class-native = "${STAGING_BINDIR_NATIVE}/perl-native/perl"
 
@@ -56,6 +56,18 @@ do_install:append () {
        fi
 }
 
+do_install_ptest () {
+        install -d ${D}${PTEST_PATH}/tests ${D}${PTEST_PATH}/src/sh
+        install -m 0755 ${S}/src/sh/dpkg-error.sh ${D}${PTEST_PATH}/src/sh/
+        cp --preserve=mode,timestamps -R ${S}/tests/* ${D}${PTEST_PATH}/tests
+
+        # The folder has a number of test folders called DEBIAN, but these are
+        # explicitly omitted from some packages, e.g. from rpm.
+        # However these are essential for the tests, so rename them to DEBIAN-ptest, and at runtime
+        # from the run-ptest script restore their names
+        find ${D}${PTEST_PATH}/tests -name DEBIAN -type d | xargs -n1 -I{} mv "{}" "{}-ptest"
+}
+
 PROV = "virtual/update-alternatives"
 PROV:class-native = ""
 PROV:class-nativesdk = ""
@@ -90,6 +102,8 @@ RDEPENDS:${PN}-perl += "perl-module-carp perl-module-constant \
                         perl-module-time-hires perl-module-time-piece \
                         perl-module-xsloader"
 
+RDEPENDS:${PN}-ptest += "make coreutils findutils"
+
 # Split out start-stop-daemon to its own package.  Note that it
 # is installed in a different directory than the one used for
 # the bitbake version.
diff --git a/meta/recipes-devtools/dpkg/dpkg/run-ptest b/meta/recipes-devtools/dpkg/dpkg/run-ptest
new file mode 100644 (file)
index 0000000..8c4739a
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+rm -f dpkg-test.log
+cd tests
+
+FAILED_TESTS=0
+ALL_TESTS=0
+
+# During installation the "DEBIAN" folders are renamed to avoid
+# problems with packaging. Restore their names here.
+for d in $(find . -name DEBIAN-ptest -type d); do
+        dname=$(dirname "$d")
+        mv ${d} ${dname}/DEBIAN
+done
+
+# This allows running tests that require root access (which we have)
+export DPKG_AS_ROOT=1
+
+for test in $(grep "TESTS_PASS +=" Makefile | cut -f3 -d" "); do
+    ALL_TESTS=$((ALL_TESTS + 1))
+    make ${test}-test >> ../dpkg-test.log 2>&1
+
+    if [ $? -eq 0 ]; then
+        echo PASS: $test
+    else
+        echo FAIL: $test
+        FAILED_TESTS=$((FAILED_TESTS + 1))
+    fi
+done
+
+if [ $FAILED_TESTS -eq 0 ]; then
+    echo All $ALL_TESTS tests passed
+else
+    echo $FAILED_TESTS of $ALL_TESTS tests failed
+fi
index cc30b711095a3f3ee2336e856d6026a4995099ce..d793c26d57abe5b164bd4f8fb11d42936b9afe43 100644 (file)
@@ -6,6 +6,7 @@ SRC_URI = "git://salsa.debian.org/dpkg-team/dpkg.git;protocol=https;branch=1.22.
            file://remove-tar-no-timestamp.patch \
            file://arch_pm.patch \
            file://add_armeb_triplet_entry.patch \
+           file://run-ptest \
            file://0002-Adapt-to-linux-wrs-kernel-version-which-has-characte.patch \
            file://0001-script.c-avoid-use-of-chroot.patch \
            file://0004-The-lutimes-function-doesn-t-work-properly-for-all-s.patch \