Skip to contentSkip to conversation

freediameter: fix buildpaths issue

PATCH New [email protected] 1 participant 1 message Aug 24, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 freediameter: fix buildpaths issue

From: Mingli Yu <[email protected]>

The pass-ptest-env.patch uses ${B}/extensions as the EXTENSIONS_DIR at build time and pass the env variable EXTENSIONS_DIR as ${libdir}/${fd_pkgname} at run time to fix the run time error. But there still exists buildpaths issue.

So rework the pass-ptest-env.patch to make sure EXTENSIONS_DIR to be ${libdir}/${fd_pkgname} both in build and run time.

Fixes:
WARNING: freediameter-1.4.0-r0 do_package_qa: QA Issue: File /usr/lib/freeDiameter/ptest/testloadext in package freediameter-ptest contains reference to TMPDIR File /usr/lib/freeDiameter/ptest/testmesg_stress in package freediameter-ptest contains reference to TMPDIR
File /usr/lib/freeDiameter/ptest/CTestTestfile.cmake in package freediameter-ptest contains reference to TMPDIR [buildpaths]
WARNING: freediameter-1.4.0-r0 do_package_qa: QA Issue: File /usr/src/debug/freediameter/1.4.0-r0/build/libfdcore/fdd.tab.c in package freediameter-src contains reference to TMPDIR

---
 .../files/0001-tests-use-EXTENSIONS_DIR.patch | 92 +++++++++++++++++++
 .../freediameter/files/pass-ptest-env.patch   | 72 ---------------
 .../freediameter/files/run-ptest              |  1 -
 .../freediameter/freediameter_1.4.0.bb        |  7 +-
 4 files changed, 97 insertions(+), 75 deletions(-)
 create mode 100644 meta-networking/recipes-protocols/freediameter/files/0001-tests-use-EXTENSIONS_DIR.patch
 delete mode 100644 meta-networking/recipes-protocols/freediameter/files/pass-ptest-env.patch
meta-networking/recipes-protocols/freediameter/files/0001-tests-use-EXTENSIONS_DIR.patch new file +92 -0
new file mode 100644
index 000000000..4cedc21ce
@@ -0,0 +1,92 @@
+From 935fcac46e2790e0e297ca855b8033895c1b8941 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <[email protected]>
+Date: Wed, 24 Aug 2022 13:45:32 +0800
+Subject: [PATCH] tests: use EXTENSIONS_DIR
+
+Use EXTENSIONS_DIR to replace BUILD_DIR as the BUILD_DIR is meanlingless
+on target and also fix buildpaths issue.
+
+Upstream-Status: Inappropriate [OE ptest specific]
+
+Signed-off-by: Mingli Yu <[email protected]>
+---
+ tests/CMakeLists.txt    |  1 +
+ tests/testloadext.c     | 12 ++++++------
+ tests/testmesg_stress.c | 12 ++++++------
+ 3 files changed, 13 insertions(+), 12 deletions(-)
+
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index 8b698ce..2c83cbb 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -37,6 +37,7 @@ SET(TEST_LIST
+ 
+ ADD_DEFINITIONS(-DTEST_DEBUG)
+ ADD_DEFINITIONS(-DBUILD_DIR="${CMAKE_BINARY_DIR}")
++ADD_DEFINITIONS(-DEXTENSIONS_DIR="${EXTENSIONS_DIR}")
+ 
+ INCLUDE_DIRECTORIES( "../libfdproto" )
+ INCLUDE_DIRECTORIES( "../libfdcore" )
+diff --git a/tests/testloadext.c b/tests/testloadext.c
+index 452737f..3fffef5 100644
+--- a/tests/testloadext.c
++++ b/tests/testloadext.c
+@@ -35,9 +35,9 @@
+ 
+ #include "tests.h"
+ 
+-#ifndef BUILD_DIR
+-#error "Missing BUILD_DIR information"
+-#endif /* BUILD_DIR */
++#ifndef EXTENSIONS_DIR
++#error "Missing EXTENSIONS_DIR information"
++#endif /* EXTENSIONS_DIR */
+ 
+ #include <sys/types.h>
+ #include <dirent.h>
+@@ -59,9 +59,9 @@ int main(int argc, char *argv[])
+ 	CHECK( 0, fd_rtdisp_init()  );
+ 	
+ 	/* Find all extensions which have been compiled along the test */
+-	TRACE_DEBUG(INFO, "Loading from: '%s'", BUILD_DIR "/extensions");
+-	CHECK( 0, (dir = opendir (BUILD_DIR "/extensions")) == NULL ? 1 : 0 );
+-	pathlen = snprintf(fullname, sizeof(fullname), BUILD_DIR "/extensions/");
++	TRACE_DEBUG(INFO, "Loading from: '%s'", EXTENSIONS_DIR);
++	CHECK( 0, (dir = opendir (EXTENSIONS_DIR)) == NULL ? 1 : 0 );
++	pathlen = snprintf(fullname, sizeof(fullname), EXTENSIONS_DIR "/");
+ 	
+ 	while ((dp = readdir (dir)) != NULL) {
+ 		char * dot = strrchr(dp->d_name, '.');
+diff --git a/tests/testmesg_stress.c b/tests/testmesg_stress.c
+index 310a9d2..97dfe07 100644
+--- a/tests/testmesg_stress.c
++++ b/tests/testmesg_stress.c
+@@ -38,9 +38,9 @@
+ #include <libgen.h>
+ #include <dlfcn.h>
+ 
+-#ifndef BUILD_DIR
+-#error "Missing BUILD_DIR information"
+-#endif /* BUILD_DIR */
++#ifndef EXTENSIONS_DIR
++#error "Missing EXTENSIONS_DIR information"
++#endif /* EXTENSIONS_DIR */
+ 
+ 
+ /* The number of times each operation is repeated to measure the average operation time */
+@@ -73,9 +73,9 @@ static void load_all_extensions(char * prefix)
+ 	struct fd_list ext_with_depends = FD_LIST_INITIALIZER(ext_with_depends);
+ 
+ 	/* Find all extensions which have been compiled along the test */
+-	LOG_D("Loading %s*.fdx from: '%s'", BUILD_DIR "/extensions", prefix ?: "");
+-	CHECK( 0, (dir = opendir (BUILD_DIR "/extensions")) == NULL ? 1 : 0 );
+-	pathlen = snprintf(fullname, sizeof(fullname), BUILD_DIR "/extensions/");
++	LOG_D("Loading %s*.fdx from: '%s'", EXTENSIONS_DIR, prefix ?: "");
++	CHECK( 0, (dir = opendir (EXTENSIONS_DIR)) == NULL ? 1 : 0 );
++	pathlen = snprintf(fullname, sizeof(fullname), EXTENSIONS_DIR "/");
+ 	
+ 	while ((dp = readdir (dir)) != NULL) {
+ 		char * dot = strrchr(dp->d_name, '.');
+-- 
+2.25.1
+
meta-networking/recipes-protocols/freediameter/files/pass-ptest-env.patch deleted +0 -72

72 lines not on this page · raw message

meta-networking/recipes-protocols/freediameter/files/run-ptest +0 -1
index d0ca8d962..3c841644b 100644
@@ -6,6 +6,5 @@ if ! lsmod | grep -q sctp && ! modprobe sctp 2>/dev/null; then
         echo
 fi
 
-export EXTENSIONS_DIR=$EXTENSIONS_DIR
 cmake  -E cmake_echo_color --cyan "Running tests..."
 ctest --force-new-ctest-process
meta-networking/recipes-protocols/freediameter/freediameter_1.4.0.bb +5 -2
index 3ec20d3ab..93a607d3c 100644
@@ -18,7 +18,7 @@ SRC_URI = "\
     file://Replace-murmurhash-algorithm-with-Robert-Jenkin-s-ha.patch \
     file://freediameter.service \
     file://freediameter.init \
-    ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'file://install_test.patch file://run-ptest file://pass-ptest-env.patch', '', d)} \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'file://install_test.patch file://run-ptest file://0001-tests-use-EXTENSIONS_DIR.patch', '', d)} \
     file://freeDiameter.conf \
     file://0001-libfdcore-sctp.c-update-the-old-sctp-api-check.patch \
     "
@@ -46,6 +46,7 @@ EXTRA_OECMAKE = " \
     -DBUILD_TEST_RT_ANY:BOOL=ON \
     -DINSTALL_LIBRARY_SUFFIX:PATH=${baselib} \
     -DINSTALL_EXTENSIONS_SUFFIX:PATH=${baselib}/${fd_pkgname} \
+    -DEXTENSIONS_DIR:PATH=${libdir}/${fd_pkgname} \
     -DINSTALL_TEST_SUFFIX:PATH=${PTEST_PATH}-tests \
     -DCMAKE_SKIP_RPATH:BOOL=ON \
 "
@@ -107,13 +108,15 @@ EOF
     openssl req -x509 -config ${STAGING_DIR_NATIVE}/etc/ssl/openssl.cnf -newkey rsa:4096 -sha256 -nodes -out ${D}${sysconfdir}/freeDiameter/${FD_PEM} -keyout ${D}${sysconfdir}/freeDiameter/${FD_KEY} -days 3650 -subj '/CN=${FD_HOSTNAME}.${FD_REALM}'
     openssl dhparam -out ${D}${sysconfdir}/freeDiameter/${FD_DH_PEM} 1024
 
+    find ${B} \( -name "*.c" -o -name "*.h" \) -exec sed -i -e 's#${WORKDIR}##g' {} \;
 }
 
 do_install_ptest() {
-    sed -i "s#\(EXTENSIONS_DIR=\).*\$#\1${libdir}/${fd_pkgname}/#" ${D}${PTEST_PATH}/run-ptest
     mv ${D}${PTEST_PATH}-tests/* ${D}${PTEST_PATH}/
     rmdir ${D}${PTEST_PATH}-tests
     install -m 0644 ${B}/tests/CTestTestfile.cmake ${D}${PTEST_PATH}/
+    sed -i -e 's#${WORKDIR}##g' ${D}${PTEST_PATH}/CTestTestfile.cmake
+    sed -i "/^set_tests_properties/d" ${D}${PTEST_PATH}/CTestTestfile.cmake
 }
 
 FILES:${PN}-dbg += "${libdir}/${fd_pkgname}/.debug/*"
Signature · 1 line
2.25.1