diff mbox series

curl: build and install unit tests for ptest

Message ID 20261124102305.1094501-1-dkelaiya@cisco.com
State New
Headers show
Series curl: build and install unit tests for ptest | expand

Commit Message

From: Darsh Kelaiya <dkelaiya@cisco.com>

curl disables unit tests when cross-compiling with shared libcurl, and
ptest does not install their runner. Configure a separate static build
for the private unit-test library and runner, and install the runner so
test1304 and the other library unit tests can execute. Keep production
libcurl's configuration unchanged.

Checked an isolated cross build and staged unit-test execution using an
existing OE toolchain/sysroot.

Signed-off-by: Darsh Kelaiya <dkelaiya@cisco.com>
---
 meta/recipes-support/curl/curl_8.23.0.bb | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-support/curl/curl_8.23.0.bb b/meta/recipes-support/curl/curl_8.23.0.bb
index ad0ad408a16..bb9044a8894 100644
--- a/meta/recipes-support/curl/curl_8.23.0.bb
+++ b/meta/recipes-support/curl/curl_8.23.0.bb
@@ -113,8 +113,23 @@  do_install:append:class-nativesdk() {
 	install -m 644 ${UNPACKDIR}/environment.d-curl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/curl.sh
 }
 
+PTEST_UNIT_BUILD = "${B}/ptest-unit"
+
+# Shared cross builds disable unit tests. Build their private static
+# library separately, keeping the production libcurl configuration.
+do_configure_ptest_base[prefuncs] += "autotools_sitefiles"
+do_configure_ptest_base[cleandirs] += "${PTEST_UNIT_BUILD}"
+
+do_configure_ptest() {
+	install -d ${PTEST_UNIT_BUILD}
+	cd ${PTEST_UNIT_BUILD}
+	oe_runconf --disable-shared --enable-static
+}
+
 do_compile_ptest() {
 	oe_runmake -C ${B}/tests
+	oe_runmake -C ${PTEST_UNIT_BUILD}/lib libcurlu.la
+	oe_runmake -C ${PTEST_UNIT_BUILD}/tests/unit units
 }
 
 do_install_ptest() {
@@ -127,6 +142,11 @@  do_install_ptest() {
 	done
 	rm -f ${D}${PTEST_PATH}/tests/libtest/libhostname.la
 
+	install -d ${D}${PTEST_PATH}/tests/unit
+	${PTEST_UNIT_BUILD}/libtool --mode=install install -m 0755 \
+		${PTEST_UNIT_BUILD}/tests/unit/units \
+		${D}${PTEST_PATH}/tests/unit/
+
 	install -d ${D}${PTEST_PATH}/tests/server
 	for name in $(makefile-getvar ${B}/tests/server/Makefile noinst_PROGRAMS); do
 		${B}/libtool --mode=install install ${B}/tests/server/$name ${D}${PTEST_PATH}/tests/server