commit: e983cfce2136969eb55b4f444a15819387c1d3bf Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Sat May 24 01:32:52 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Sat May 24 01:34:00 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e983cfce
net-libs/rtrlib: test fixes * Wire up more tests (unittests w/ CMocka) * Drop filter-lto by backporting fix to tests for -Wstrict-aliasing * Skip 2 tests that require network * Skip 2 tests with LTO that use CMocka (uses --Wl,--wrap) Bug: https://bugs.gentoo.org/861581 Closes: https://bugs.gentoo.org/758392 Signed-off-by: Sam James <sam <AT> gentoo.org> .../files/rtrlib-0.8.0-no-network-tests.patch | 29 ++++++++++ .../files/rtrlib-0.8.0-tests-strict-aliasing.patch | 67 ++++++++++++++++++++++ net-libs/rtrlib/rtrlib-0.8.0.ebuild | 35 +++++++---- 3 files changed, 119 insertions(+), 12 deletions(-) diff --git a/net-libs/rtrlib/files/rtrlib-0.8.0-no-network-tests.patch b/net-libs/rtrlib/files/rtrlib-0.8.0-no-network-tests.patch new file mode 100644 index 000000000000..d1509e61f143 --- /dev/null +++ b/net-libs/rtrlib/files/rtrlib-0.8.0-no-network-tests.patch @@ -0,0 +1,29 @@ +https://bugs.gentoo.org/758392 +https://sources.debian.org/data/main/libr/librtr/0.8.0-1.1/debian/patches/Disable-tests-requiring-Internet-access.patch + +From: Lukas Schwaighofer <[email protected]> +Date: Sun, 11 Nov 2018 10:09:35 +0100 +Subject: Disable tests requiring Internet access. + +Tests requiring Internet access will fail on Debian's autobuilding +machines. + +Forwarded: not-needed +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -112,13 +112,13 @@ ADD_TEST(test_trie tests/test_trie) + ADD_TEST(test_ht_spkitable tests/test_ht_spkitable) + ADD_TEST(test_ht_spkitable_locks tests/test_ht_spkitable_locks) + +-ADD_TEST(test_live_validation tests/test_live_validation) ++#ADD_TEST(test_live_validation tests/test_live_validation) + + ADD_TEST(test_ipaddr tests/test_ipaddr) + + ADD_TEST(test_getbits tests/test_getbits) + +-ADD_TEST(test_dynamic_groups tests/test_dynamic_groups) ++#ADD_TEST(test_dynamic_groups tests/test_dynamic_groups) + + #install lib + set (RTRLIB_VERSION_MAJOR 0) diff --git a/net-libs/rtrlib/files/rtrlib-0.8.0-tests-strict-aliasing.patch b/net-libs/rtrlib/files/rtrlib-0.8.0-tests-strict-aliasing.patch new file mode 100644 index 000000000000..f003ea4f8b9d --- /dev/null +++ b/net-libs/rtrlib/files/rtrlib-0.8.0-tests-strict-aliasing.patch @@ -0,0 +1,67 @@ +https://bugs.gentoo.org/861581 +https://github.com/rtrlib/rtrlib/issues/287 +https://github.com/rtrlib/rtrlib/pull/289 + +From 928a00a617d232be086515ddc22428d6f76faa5d Mon Sep 17 00:00:00 2001 +From: maurim <[email protected]> +Date: Mon, 6 May 2024 15:30:15 +0200 +Subject: [PATCH] [FIX] Building with strict aliasing + +Motivation + - building with strict aliasing flags fails + - used flags shown below + +``` +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=3 -fdiagnostics-color=always -frecord-gcc-switches") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-clash-protection -march=native -O2 -pipe -U_FORTIFY_SOURCE") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format-security -Werror=implicit-int -Werror=int-conversion -Wformat") +``` + +How: + - modify casted variable type in test case to initialized type + +Related: + - fixes #287 +--- + tests/test_pfx.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/tests/test_pfx.c b/tests/test_pfx.c +index e7f26512..cb5a2873 100644 +--- a/tests/test_pfx.c ++++ b/tests/test_pfx.c +@@ -128,8 +128,8 @@ static void mass_test(void) + pfx.min_len = 128; + pfx.max_len = 128; + pfx.prefix.ver = LRTR_IPV6; +- ((uint64_t *)pfx.prefix.u.addr6.addr)[1] = max_i; +- ((uint64_t *)pfx.prefix.u.addr6.addr)[0] = min_i + i; ++ ((uint32_t *)pfx.prefix.u.addr6.addr)[2] = max_i; ++ ((uint32_t *)pfx.prefix.u.addr6.addr)[0] = min_i + i; + assert(pfx_table_add(&pfxt, &pfx) == PFX_SUCCESS); + } + +@@ -148,8 +148,8 @@ static void mass_test(void) + pfx.min_len = 128; + pfx.max_len = 128; + pfx.prefix.ver = LRTR_IPV6; +- ((uint64_t *)pfx.prefix.u.addr6.addr)[1] = max_i; +- ((uint64_t *)pfx.prefix.u.addr6.addr)[0] = min_i + i; ++ ((uint32_t *)pfx.prefix.u.addr6.addr)[2] = max_i; ++ ((uint32_t *)pfx.prefix.u.addr6.addr)[0] = min_i + i; + + assert(pfx_table_validate(&pfxt, i + 1, &pfx.prefix, pfx.min_len, &res) == PFX_SUCCESS); + assert(res == BGP_PFXV_STATE_VALID); +@@ -172,8 +172,8 @@ static void mass_test(void) + pfx.prefix.ver = LRTR_IPV6; + pfx.min_len = 128; + pfx.max_len = 128; +- ((uint64_t *)pfx.prefix.u.addr6.addr)[1] = max_i; +- ((uint64_t *)pfx.prefix.u.addr6.addr)[0] = min_i + i; ++ ((uint32_t *)pfx.prefix.u.addr6.addr)[2] = max_i; ++ ((uint32_t *)pfx.prefix.u.addr6.addr)[0] = min_i + i; + assert(pfx_table_remove(&pfxt, &pfx) == PFX_SUCCESS); + } + + diff --git a/net-libs/rtrlib/rtrlib-0.8.0.ebuild b/net-libs/rtrlib/rtrlib-0.8.0.ebuild index 50d2d94eb403..e476a075d585 100644 --- a/net-libs/rtrlib/rtrlib-0.8.0.ebuild +++ b/net-libs/rtrlib/rtrlib-0.8.0.ebuild @@ -1,9 +1,9 @@ -# Copyright 1999-2024 Gentoo Authors +# Copyright 1999-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 -inherit cmake flag-o-matic +inherit cmake toolchain-funcs DESCRIPTION="An open-source C implementation of the RPKI/Router Protocol client" HOMEPAGE="https://rtrlib.realmv6.org/" @@ -12,15 +12,21 @@ SRC_URI="https://github.com/rtrlib/rtrlib/archive/v${PV}.tar.gz -> ${P}.tar.gz" LICENSE="MIT" SLOT="0" KEYWORDS="amd64 ~arm64 x86" - -IUSE="doc ssh" +IUSE="doc ssh test" +RESTRICT="!test? ( test )" RDEPEND="ssh? ( net-libs/libssh:0= )" DEPEND=" ${RDEPEND} doc? ( app-text/doxygen[dot] ) + test? ( dev-util/cmocka ) " +PATCHES=( + "${FILESDIR}"/${PN}-0.8.0-no-network-tests.patch + "${FILESDIR}"/${PN}-0.8.0-tests-strict-aliasing.patch +) + src_prepare() { # Fix automagic dependency on doxygen, fix path for installing docs if use doc; then @@ -32,20 +38,25 @@ src_prepare() { } src_configure() { - # -Werror=strict-aliasing - # https://bugs.gentoo.org/861581 - # https://github.com/rtrlib/rtrlib/issues/287 - # - # Do not trust LTO either. - append-flags -fno-strict-aliasing - filter-lto - local mycmakeargs=( -DRTRLIB_TRANSPORT_SSH=$(usex ssh) + -DUNIT_TESTING=$(usex test) ) + cmake_src_configure } +src_test() { + tc-is-lto && CMAKE_SKIP_TESTS+=( + # These tests use cmocka (so --wrap) which goes wrong + # with LTO: bug #951662. + test_packets + test_packets_static + ) + + cmake_src_test +} + src_install() { cmake_src_install find "${D}" -name '*.la' -delete || die
