From 3a2b4ffd0ab344736c9c3674b816e7102cc7a578 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 22 Dec 2020 22:39:35 +0100 Subject: [PATCH 1/7] core/tests: skip test for nm_wildcard_match_check() on non-glibc It seems musl's fnmatch() does not support ranges and fails the test. Skip it. Seen on musl-1.1.24-r10. --- src/tests/test-core.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tests/test-core.c b/src/tests/test-core.c index 39c5ad46d2..b2b6612c3c 100644 --- a/src/tests/test-core.c +++ b/src/tests/test-core.c @@ -980,10 +980,11 @@ test_connection_match_ip6_routes(void) g_assert(matched == copy); } -#define do_test_wildcard_match(str, result, ...) \ - g_assert( \ - nm_wildcard_match_check(str, (const char *const[]){__VA_ARGS__}, NM_NARG(__VA_ARGS__)) \ - == result); +#define do_test_wildcard_match_eval(str, ...) \ + nm_wildcard_match_check(str, (const char *const[]){__VA_ARGS__}, NM_NARG(__VA_ARGS__)) + +#define do_test_wildcard_match(str, result, ...) \ + g_assert(do_test_wildcard_match_eval(str, __VA_ARGS__) == result) static void test_wildcard_match(void) @@ -1056,7 +1057,14 @@ test_wildcard_match(void) do_test_wildcard_match("name3", TRUE, "name[123]"); do_test_wildcard_match("name4", FALSE, "name[123]"); - do_test_wildcard_match("[a]", TRUE, "\\[a\\]"); + if (do_test_wildcard_match_eval("[a]", "\\[a\\]") != TRUE) { +#if defined(__GLIBC__) + do_test_wildcard_match("[a]", TRUE, "\\[a\\]"); + g_assert_not_reached(); +#endif + /* It seems musl's fnmatch() does not like such ranges. */ + g_test_skip("libc does not support ranges with fnmatch()!!"); + } do_test_wildcard_match("aa", FALSE, "!a*"); do_test_wildcard_match("aa", FALSE, "&!a*"); From 710e3d98138d96736b036ee55d5e3ebf3d7f9c6f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 22 Dec 2020 23:05:15 +0100 Subject: [PATCH 2/7] core/tests: relax checks in do_test_nm_utils_kill_child() for libmusl We were asserting against error messages from strerror(), and on libmusl these are different. Relax the checks. We still assert against parts of the text, where possible. So a similar problem could happen in the future or with another libc library. --- src/tests/test-core-with-expect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/test-core-with-expect.c b/src/tests/test-core-with-expect.c index 547c659480..35d6bf95bf 100644 --- a/src/tests/test-core-with-expect.c +++ b/src/tests/test-core-with-expect.c @@ -334,7 +334,7 @@ do_test_nm_utils_kill_child(void) * is a race here. */ NMTST_EXPECT_NM_ERROR( "kill child process 'test-s-3-2' (*): failed due to unexpected return value -1 by waitpid " - "(No child processes, 10) after sending no signal (0)"); + "(No child process*, 10) after sending no signal (0)"); test_nm_utils_kill_child_sync_do("test-s-3-2", pid3s, 0, 0, FALSE, NULL); NMTST_EXPECT_NM_DEBUG("kill child process 'test-s-4' (*): waiting up to 1 milliseconds for " @@ -397,7 +397,7 @@ do_test_nm_utils_kill_child(void) * is a race here. */ NMTST_EXPECT_NM_ERROR( "kill child process 'test-a-3-2' (*): failed due to unexpected return value -1 by waitpid " - "(No child processes, 10) after sending no signal (0)"); + "(No child process*, 10) after sending no signal (0)"); NMTST_EXPECT_NM_DEBUG( "kill child process 'test-a-3-2' (*): invoke callback: killing child failed"); test_nm_utils_kill_child_async_do("test-a-3-2", pid3a, 0, 0, FALSE, NULL); From 2f9238b987756f101134e35c44bc54b69e0392d7 Mon Sep 17 00:00:00 2001 From: Rasmus Thomsen Date: Thu, 9 Jul 2020 17:25:28 +0200 Subject: [PATCH 3/7] systemd: fix include for on musl Due to mixing includes of userspace network headers (net/*) and kernelspace onces (linux/if*) symbol redefinitions happen on musl. [thaller@redhat.com: modified original patch] --- src/systemd/src/libsystemd-network/sd-dhcp6-client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c index ec7f1be2e0..42cde93b08 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c @@ -7,7 +7,11 @@ #include #include +#if 0 /* NM_IGNORED */ #include +#else /* NM_IGNORED */ +#include +#endif /* NM_IGNORED */ #include #include "sd-dhcp6-client.h" From 44e25bbb961d17508c91fd195563ec670a8e337c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 10 Dec 2020 22:11:07 +0100 Subject: [PATCH 4/7] systemd: use pthread instead of internal glibc functionality on non glibc platform --- shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h b/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h index 919f8264a1..e829532566 100644 --- a/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h +++ b/shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h @@ -127,6 +127,7 @@ _nm_log_get_max_level_realm(void) #include #include + #include #define ENABLE_GSHADOW FALSE @@ -202,6 +203,17 @@ typedef __compar_fn_t comparison_fn_t; typedef int (*__compar_d_fn_t)(const void *, const void *, void *); #endif + #ifndef __GLIBC__ +static inline int +__register_atfork(void (*prepare)(void), + void (*parent)(void), + void (*child)(void), + void *dso_handle) +{ + return pthread_atfork(prepare, parent, child); +} + #endif + #endif /* (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD */ /*****************************************************************************/ From c50da167bc8a70f18edc786591131e77bcfd8468 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 22 Dec 2020 16:47:51 +0100 Subject: [PATCH 5/7] all: adjust imports to fix libc/linux headers Linux headers and some libc headers have overlapping defines for network types and functions. In the past years, glibc and linux headers were improved to cooperate so you could include either one, in any order. With musl and possibly some older glibc versions that doesn't work so well. Reorder and change includes to make it work better. Yes, this looks pretty random and unmotivated. The includes are changed in order to successfully build on various libc/kernel versions, with the goal of not using #if. --- src/devices/nm-device.c | 5 +++-- src/devices/tests/test-lldp.c | 1 + src/platform/nm-linux-platform.c | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 2341ffe527..cd2101a521 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -8,7 +8,6 @@ #include "nm-device.h" -#include #include #include #include @@ -16,8 +15,10 @@ #include #include #include +#include +#include +#include #include -#include #include #include #include diff --git a/src/devices/tests/test-lldp.c b/src/devices/tests/test-lldp.c index 5c912b7d2e..6da4a7697f 100644 --- a/src/devices/tests/test-lldp.c +++ b/src/devices/tests/test-lldp.c @@ -6,6 +6,7 @@ #include "nm-default.h" #include +#include #include #include #include diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 28e6df1c6b..505cf82cb6 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -12,9 +12,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include #include From 81e0837678156f1c578d1092e7b3d5e25c3c5cee Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 22 Dec 2020 22:27:15 +0100 Subject: [PATCH 6/7] gitlab-ci: install missing packages on Alpine Linux The "contrib/alpine/REQUIRED_PACKAGES" script is also used by gitlab-ci to setup the test container. These packages are required for unit tests. --- .gitlab-ci.yml | 2 +- contrib/alpine/REQUIRED_PACKAGES | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a35f64199..f738c6f889 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,7 @@ variables: UBUNTU_TAG: '2020-11-17.0-45915bd6e380' DEBIAN_TAG: '2020-11-17.0-45915bd6e380' CENTOS_TAG: '2020-11-17.0-cbb87607d569' - ALPINE_TAG: '2020-11-17.0-8309a34970a3' + ALPINE_TAG: '2020-11-17.0-eafb903b544b' FEDORA_EXEC: 'bash .gitlab-ci/fedora-install.sh' UBUNTU_EXEC: 'bash .gitlab-ci/debian-install.sh' diff --git a/contrib/alpine/REQUIRED_PACKAGES b/contrib/alpine/REQUIRED_PACKAGES index 6c9ad8deba..9e2fd779fd 100755 --- a/contrib/alpine/REQUIRED_PACKAGES +++ b/contrib/alpine/REQUIRED_PACKAGES @@ -21,6 +21,7 @@ apk add \ 'gobject-introspection-dev' \ 'gtk-doc' \ 'intltool' \ + 'iproute2' \ 'iptables' \ 'jansson-dev' \ 'libgudev-dev' \ @@ -41,9 +42,11 @@ apk add \ 'polkit-dev' \ 'ppp' \ 'ppp-dev' \ + 'py3-dbus' \ 'py3-gobject3' \ 'python3' \ 'readline-dev' \ 'util-linux-dev' \ 'vala' \ + 'valgrind' \ 'vim' From 826f2083192fce3d0d3d21317a8c9fc63b8c323e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 22 Dec 2020 23:36:49 +0100 Subject: [PATCH 7/7] gitlab-ci: skip valgrind tests on Alpine Linux We don't have debug symbols, so valgrind suppressions don't work. Skip those checks. --- contrib/scripts/nm-ci-run.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/scripts/nm-ci-run.sh b/contrib/scripts/nm-ci-run.sh index 0a87beaa5f..03eb955148 100755 --- a/contrib/scripts/nm-ci-run.sh +++ b/contrib/scripts/nm-ci-run.sh @@ -101,6 +101,12 @@ _with_valgrind() { test "$_WITH_VALGRIND_CHECKED" == "1" && return 0 _WITH_VALGRIND_CHECKED=1 + if [ "$IS_ALPINE" = 1 ]; then + # on Alpine we have no debug symbols and the suppressions + # don't work. Skip valgrind tests. + WITH_VALGRIND=0 + fi + # Certain glib2 versions are known to report *lots* of leaks. Disable # valgrind tests in this case. # https://bugzilla.redhat.com/show_bug.cgi?id=1710417