diff mbox series

logrotate: add ptest support

Message ID 20230405143604.2769501-1-frank.wolff@smile.fr
State Accepted, archived
Commit 0bdfe34c016c8db1f18d76b59a38af280b4c70aa
Headers show
Series logrotate: add ptest support | expand

Commit Message

Frank WOLFF April 5, 2023, 2:36 p.m. UTC
Below is an extract of the test log:

root@qemux86-64:~# ptest-runner
START: ptest-runner
2023-04-05T12:20
BEGIN: /usr/lib/logrotate/ptest
make  check-TESTS
make[1]: Entering directory '/usr/lib/logrotate/ptest'
make[2]: Entering directory '/usr/lib/logrotate/ptest'
PASS: test-0001.sh
PASS: test-0002.sh
...
...
PASS: test-0107.sh
PASS: test-0108.sh
============================================================================
Testsuite summary for logrotate 3.21.0
============================================================================
 # TOTAL: 102
 # PASS:  97
 # SKIP:  5
 # XFAIL: 0
 # FAIL:  0
 # XPASS: 0
 # ERROR: 0
============================================================================
make[2]: Leaving directory '/usr/lib/logrotate/ptest'
make[1]: Leaving directory '/usr/lib/logrotate/ptest'
DURATION: 353
END: /usr/lib/logrotate/ptest
2023-04-05T12:26
STOP: ptest-runner
TOTAL: 1 FAIL: 0

Reviewed-by: Yoann CONGAL <yoann.congal@smile.fr>
Signed-off-by: Frank WOLFF <frank.wolff@smile.fr>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../logrotate/logrotate/run-ptest             |  5 ++++
 .../logrotate/logrotate_3.21.0.bb             | 30 +++++++++++++++++--
 3 files changed, 34 insertions(+), 2 deletions(-)
 create mode 100755 meta/recipes-extended/logrotate/logrotate/run-ptest
diff mbox series

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index d60ebb38fc..78750a0d98 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -46,6 +46,7 @@  PTESTS_FAST = "\
     libxml-sax-base-perl \
     libxml-simple-perl \
     libxml2 \
+    logrotate \
     lua \
     lzo \
     m4 \
diff --git a/meta/recipes-extended/logrotate/logrotate/run-ptest b/meta/recipes-extended/logrotate/logrotate/run-ptest
new file mode 100755
index 0000000000..b272def65f
--- /dev/null
+++ b/meta/recipes-extended/logrotate/logrotate/run-ptest
@@ -0,0 +1,5 @@ 
+#!/bin/sh
+
+set -u
+
+make -k check
diff --git a/meta/recipes-extended/logrotate/logrotate_3.21.0.bb b/meta/recipes-extended/logrotate/logrotate_3.21.0.bb
index 4e4ea10628..87c0d9ae60 100644
--- a/meta/recipes-extended/logrotate/logrotate_3.21.0.bb
+++ b/meta/recipes-extended/logrotate/logrotate_3.21.0.bb
@@ -10,7 +10,9 @@  DEPENDS="coreutils popt"
 
 LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
 
-SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BP}.tar.xz"
+SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BP}.tar.xz \
+           file://run-ptest \
+           "
 
 SRC_URI[sha256sum] = "8fa12015e3b8415c121fc9c0ca53aa872f7b0702f543afda7e32b6c4900f6516"
 
@@ -44,7 +46,7 @@  EXTRA_OEMAKE = "\
 # INSTALL=install and BASEDIR=/usr.
 OS_NAME = "Linux"
 
-inherit autotools systemd github-releases
+inherit autotools systemd github-releases ptest
 
 SYSTEMD_SERVICE:${PN} = "\
     ${BPN}.service \
@@ -86,3 +88,27 @@  do_install(){
         install -p -m 0755 ${S}/examples/logrotate.cron ${D}${sysconfdir}/cron.daily/logrotate
     fi
 }
+
+do_install_ptest() {
+    cp -r ${S}/test/* ${D}${PTEST_PATH}
+    cp ${S}/test-driver ${D}${PTEST_PATH}
+    cp ${B}/test/Makefile ${D}${PTEST_PATH}
+
+    # Do not rebuild Makefile
+    sed -i 's/^Makefile:/_Makefile:/' ${D}${PTEST_PATH}/Makefile
+
+    # Fix top_builddir and top_srcdir
+    sed -e 's/^top_builddir = \(.*\)/top_builddir = ./' \
+        -e 's/^top_srcdir = \(.*\)/top_srcdir = ./' \
+        -i ${D}${PTEST_PATH}/Makefile
+
+    # Replace bash with sh
+    sed -i 's,/bin/bash,/bin/sh,' ${D}${PTEST_PATH}/Makefile
+
+    # Replace gawk with awk
+    sed -i 's/gawk/awk/' ${D}${PTEST_PATH}/Makefile
+    ln -s ${sbindir}/logrotate ${D}${PTEST_PATH}
+}
+
+# coreutils is needed to have "readlink"
+RDEPENDS:${PN}-ptest += "make coreutils"