openvpn: fix ptest

The openvpn 2.7.0 upgrade refactored
tests/unit_tests/openvpn/Makefile.am, changing how test_binaries is
defined. This caused autoreconf to generate Makefiles where
buildtest-TESTS and runtest-TESTS no longer have rule bodies, breaking
the existing ptest recipe which relied on these targets for compilation
and execution. The fix replaces these internal automake targets with
stable interfaces: check-am for compilation and direct binary execution
on target.

Signed-off-by: Haixiao Yan <haixiao.yan.cn@windriver.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Haixiao Yan 2026-03-27 10:12:43 +08:00 committed by Khem Raj
parent f9a520a6bc
commit 79201ef95e
No known key found for this signature in database
GPG Key ID: BB053355919D3314
3 changed files with 65 additions and 15 deletions

View File

@ -0,0 +1,34 @@
From 93f7f6ca0c916427d28610d3e263fa556587532d Mon Sep 17 00:00:00 2001
From: Haixiao Yan <haixiao.yan.cn@windriver.com>
Date: Thu, 26 Mar 2026 13:43:50 +0800
Subject: [PATCH] tests: skip test execution when cross-compiling
The auth-pam unit test Makefile.am unconditionally assigns the TESTS variable,
causing test execution to fail during cross-compilation because the target
binaries are not executable on the build host.
Upstream-Status: Pending
Signed-off-by: Haixiao Yan <haixiao.yan.cn@windriver.com>
---
tests/unit_tests/plugins/auth-pam/Makefile.am | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/unit_tests/plugins/auth-pam/Makefile.am b/tests/unit_tests/plugins/auth-pam/Makefile.am
index ba32013ac920..7da299ccde92 100644
--- a/tests/unit_tests/plugins/auth-pam/Makefile.am
+++ b/tests/unit_tests/plugins/auth-pam/Makefile.am
@@ -4,8 +4,10 @@ AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) auth_pam Plugin Unit-Tests
if ENABLE_PLUGIN_AUTH_PAM
check_PROGRAMS = auth_pam_testdriver
+if !CROSS_COMPILING
TESTS = $(check_PROGRAMS)
endif
+endif
auth_pam_testdriver_SOURCES = test_search_and_replace.c $(top_srcdir)/src/plugins/auth-pam/utils.h $(top_srcdir)/src/plugins/auth-pam/utils.c
auth_pam_testdriver_CFLAGS = @TEST_CFLAGS@ -I$(top_srcdir)/src/plugins/auth-pam
--
2.43.0

View File

@ -1,8 +1,20 @@
#!/bin/sh
find ./ -name Makefile | while read -r x; do
make -C "$(dirname "${x}")" -k runtest-TESTS | sed \
# Run unit tests directly
find ./ -name "*testdriver" -type f -executable | while read -r t; do
dir=$(dirname "${t}")
srcdir="${dir}" "${t}" 2>&1 | sed \
-e 's/^\(\[ OK \].*\)$/PASS: \1/' \
-e 's/^\(\[ FAILED \].*\)$/FAIL: \1/' \
-e 's/^\(\[ SKIPPED \].*\)$/SKIP: \1/'
done
# Run crypto loopback integration test
if [ -f ./t_lpback.sh ]; then
sh ./t_lpback.sh 2>&1
if [ $? -eq 0 ]; then
echo "PASS: t_lpback"
else
echo "FAIL: t_lpback"
fi
fi

View File

@ -9,6 +9,7 @@ inherit autotools systemd update-rc.d pkgconfig ptest
SRC_URI = "http://swupdate.openvpn.org/community/releases/${BP}.tar.gz \
file://0001-configure.ac-eliminate-build-path-from-openvpn-versi.patch \
file://0001-tests-skip-test-execution-when-cross-compiling.patch \
file://openvpn \
file://run-ptest \
"
@ -47,7 +48,7 @@ PACKAGECONFIG[systemd] = "--enable-systemd,--disable-systemd,systemd"
PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux,libselinux"
RDEPENDS:${PN}:append = " bash"
RDEPENDS:${PN}-ptest:append = " make bash"
RDEPENDS:${PN}-ptest:append = " bash"
do_install:append() {
install -d ${D}/${sysconfdir}/init.d
@ -71,21 +72,21 @@ do_install:append() {
}
do_compile_ptest () {
for x in `find ${B}/tests/unit_tests -name Makefile -exec grep -l buildtest-TESTS {} \;`; do
for x in `find ${B}/tests/unit_tests -name Makefile -exec grep -l check_PROGRAMS {} \;`; do
dir=`dirname ${x}`
case $dir in
*example*)
echo "Skipping directory: $dir"
;;
*)
oe_runmake -C ${dir} buildtest-TESTS
oe_runmake -C ${dir} check-am
;;
esac
done
}
do_install_ptest() {
for x in $(find ${B}/tests/unit_tests -name Makefile -exec grep -l buildtest-TESTS {} \;); do
for x in $(find ${B}/tests/unit_tests -name Makefile -exec grep -l check_PROGRAMS {} \;); do
dir=$(dirname ${x})
if [[ "$dir" == *example* ]]; then
@ -94,21 +95,23 @@ do_install_ptest() {
target_dir="${D}/${PTEST_PATH}/unit_tests/$(basename ${dir})"
mkdir -p ${target_dir}
cp -f ${dir}/Makefile ${target_dir}/
sed -i "s/^Makefile:/MM:/g" ${target_dir}/Makefile
sed -i 's/^#TESTS = $(am__EXEEXT_4)/TESTS = $(am__EXEEXT_4)/' ${target_dir}/Makefile
for testfile in $(find ${dir} -name "*testdriver"); do
for testfile in $(find ${dir} -name "*testdriver" -type f -executable); do
cp -rf ${testfile} ${target_dir}/
done
done
sed -i 's|find ./|find ${PTEST_PATH}|g' ${D}${PTEST_PATH}/run-ptest
# Install test input data files needed by user_pass and misc tests
cp -rf ${S}/tests/unit_tests/openvpn/input ${D}/${PTEST_PATH}/unit_tests/openvpn/
# Install COPYRIGHT.GPL needed by test_list
# test_list references srcdir/../../../COPYRIGHT.GPL
# srcdir=./unit_tests/openvpn -> resolves to ../COPYRIGHT.GPL from ptest cwd
# which is ${libdir}/openvpn/COPYRIGHT.GPL
cp -f ${S}/COPYRIGHT.GPL ${D}/${libdir}/openvpn/
sed -i 's|${top_builddir}/src/openvpn|${sbindir}|g' ${S}/tests/t_lpback.sh
cp -f ${S}/tests/t_lpback.sh ${D}/${PTEST_PATH}
cp -f ${B}/tests/Makefile ${D}/${PTEST_PATH}
sed -i "s/^Makefile:/MM:/g" ${D}/${PTEST_PATH}/Makefile
sed -i "s/^test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh/test_scripts = t_lpback.sh/g" ${D}/${PTEST_PATH}/Makefile
}
PACKAGES =+ " ${PN}-sample "
@ -116,6 +119,7 @@ PACKAGES =+ " ${PN}-sample "
RRECOMMENDS:${PN} = "kernel-module-tun"
FILES:${PN}-dbg += "${libdir}/openvpn/plugins/.debug"
FILES:${PN}-ptest += "${libdir}/openvpn/COPYRIGHT.GPL"
FILES:${PN} += "${systemd_system_unitdir}/openvpn-server@.service \
${systemd_system_unitdir}/openvpn-client@.service \
${nonarch_libdir}/tmpfiles.d \