openvpn: add ptest support

All test cases PASS.
Add openvpn to PTESTS_SLOW because test duration longer than 30s Below is parts of the run log:
[==========] xkey provider tests: Running 3 test(s).
[ RUN      ] xkey_provider_test_fetch
[       OK ] xkey_provider_test_fetch
[ RUN      ] xkey_provider_test_mgmt_sign_cb
[       OK ] xkey_provider_test_mgmt_sign_cb
[ RUN      ] xkey_provider_test_generic_sign_cb
[       OK ] xkey_provider_test_generic_sign_cb
[==========] xkey provider tests: 3 test(s) run.
[  PASSED  ] 3 test(s).
PASS: provider_testdriver

The files t_client.sh.in and t_cltsrv.sh were not added because they
require specific environment configuration files. It is recommended that
users configure these based on their environment before testing.

Since the recipe enables iproute2, the condition for t_net.sh based on
HAVE_SITNL is not met, so t_net.sh will not be included in the build.

Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Jiaying Song 2024-11-20 13:29:33 +08:00 committed by Khem Raj
parent afd7277542
commit bea74f838b
No known key found for this signature in database
GPG Key ID: BB053355919D3314
3 changed files with 52 additions and 2 deletions

View File

@ -25,6 +25,7 @@ PTESTS_FAST_META_NETWORKING = "\
# firewalld
PTESTS_SLOW_META_NETWORKING = "\
net-snmp \
openvpn \
"
PTESTS_PROBLEMS_META_NETWORKING = "\

View File

@ -0,0 +1,5 @@
#!/bin/sh
for x in `find ./ -name Makefile`;
do
make -C `dirname ${x}` -k runtest-TESTS
done

View File

@ -3,13 +3,14 @@ HOMEPAGE = "https://openvpn.net/"
SECTION = "net"
LICENSE = "GPL-2.0-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=89196bacc47ed37a5b242a535661a049"
DEPENDS = "lzo lz4 openssl iproute2 libcap-ng ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
DEPENDS = "lzo lz4 openssl iproute2 libcap-ng ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)} ${@bb.utils.contains('PTEST_ENABLED', '1', 'cmocka', '', d)} "
inherit autotools systemd update-rc.d pkgconfig
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://openvpn \
file://run-ptest \
"
UPSTREAM_CHECK_URI = "https://openvpn.net/community-downloads"
@ -42,6 +43,8 @@ PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
PACKAGECONFIG[systemd] = "--enable-systemd,--disable-systemd,systemd"
PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux,libselinux"
RDEPENDS:${PN}-ptest:append = " make bash"
do_install:append() {
install -d ${D}/${sysconfdir}/init.d
install -m 755 ${UNPACKDIR}/openvpn ${D}/${sysconfdir}/init.d
@ -63,6 +66,47 @@ do_install:append() {
install -d -m 710 ${D}/${localstatedir}/lib/openvpn
}
do_compile_ptest () {
for x in `find ${B}/tests/unit_tests -name Makefile -exec grep -l buildtest-TESTS {} \;`; do
dir=`dirname ${x}`
case $dir in
*example*)
echo "Skipping directory: $dir"
;;
*)
oe_runmake -C ${dir} buildtest-TESTS
;;
esac
done
}
do_install_ptest() {
for x in $(find ${B}/tests/unit_tests -name Makefile -exec grep -l buildtest-TESTS {} \;); do
dir=$(dirname ${x})
if [[ "$dir" == *example* ]]; then
continue
fi
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
cp -rf ${testfile} ${target_dir}/
done
done
sed -i 's|find ./|find ${PTEST_PATH}|g' ${D}${PTEST_PATH}/run-ptest
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 "
RRECOMMENDS:${PN} = "kernel-module-tun"