From 8f7c876bdcde0de1a90b525c216ee6ae6c13e879 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 14 Dec 2023 11:36:52 +0100 Subject: [PATCH 1/5] test: forward journal messages to console during sd-bsod tests Since we nuke the journal multiple times during that, which makes potential fails undebugable. --- test/units/testsuite-04.bsod.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/units/testsuite-04.bsod.sh b/test/units/testsuite-04.bsod.sh index 8f5ff5f35c..1de446bc12 100755 --- a/test/units/testsuite-04.bsod.sh +++ b/test/units/testsuite-04.bsod.sh @@ -22,6 +22,9 @@ at_exit() { journalctl --flush fi + rm -f /run/systemd/journald.conf.d/99-forward-to-console.conf + systemctl restart systemd-journald + return 0 } @@ -49,7 +52,12 @@ vcs_dump_and_check() { # current boot, let's temporarily overmount /var/log/journal with a tmpfs, # as we're going to wipe it multiple times, but we need to keep the original # journal intact for the other tests to work correctly. +# +# Also, since we'll eventually lose the journal from this test, let's temporarily +# forward everything to console, to make potential fails debug-able. trap at_exit EXIT +mkdir -p /run/systemd/journald.conf.d/ +echo -ne '[Journal]\nForwardToConsole=yes' >/run/systemd/journald.conf.d/99-forward-to-console.conf mount -t tmpfs tmpfs /var/log/journal systemctl restart systemd-journald From c15e51bde23e54895cb4f3aa00399fa5e7bef0e8 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 14 Dec 2023 11:40:13 +0100 Subject: [PATCH 2/5] test: update comment style & drop one extraneous newline Follow-up to 9fb2a61830. --- src/test/test-bootspec.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/test-bootspec.c b/src/test/test-bootspec.c index 18611fc051..86d7702bf8 100644 --- a/src/test/test-bootspec.c +++ b/src/test/test-bootspec.c @@ -188,23 +188,22 @@ TEST_RET(bootspec_boot_config_find_entry) { assert_se(boot_config_load(&config, d, NULL) >= 0); assert_se(config.n_entries == 2); - // Test finding the first entry + /* Test finding the first entry */ BootEntry *entry = boot_config_find_entry(&config, "a-10.conf"); assert_se(entry && streq(entry->id, "a-10.conf")); - // Test finding the second entry + /* Test finding the second entry */ entry = boot_config_find_entry(&config, "a-05.conf"); assert_se(entry && streq(entry->id, "a-05.conf")); - // Test finding a non-existent entry + /* Test finding a non-existent entry */ entry = boot_config_find_entry(&config, "nonexistent.conf"); assert_se(entry == NULL); - // Test case-insensitivity + /* Test case-insensitivity */ entry = boot_config_find_entry(&config, "A-10.CONF"); assert_se(entry && streq(entry->id, "a-10.conf")); - return 0; } From fdd380dde2ec2cbcecbd20b91cf6b819ef3dc0db Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 14 Dec 2023 15:06:12 +0100 Subject: [PATCH 3/5] test: install empty directories with NO_BUILD=1 Resolves: #30478 --- test/test-functions | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/test/test-functions b/test/test-functions index 4606745f10..6a6f624d4c 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1310,19 +1310,35 @@ install_compiled_systemd() { fi } +install_package_file() { + local file="${1:?}" + + # Skip missing files (like /etc/machine-info) + [[ ! -e "$file" ]] && return 0 + # Skip python unit tests, since the image_install machinery will try to pull + # in the whole python stack in a very questionable state, making the tests fail. + # And given we're trying to transition to mkosi-based images anyway I'm not even + # going to bother + [[ "$file" =~ /tests/unit-tests/.*.py$ ]] && return 0 + # If the current file is a directory, create it with the original + # mode; if it's a symlink to a directory, copy it as-is + if [[ -d "$file" ]]; then + inst_dir "$file" + else + inst "$file" + fi +} + install_debian_systemd() { dinfo "Install debian systemd" - local files + local deb file while read -r deb; do - files="$(dpkg-query -L "$deb" 2>/dev/null)" || continue ddebug "Install debian files from package $deb" - for file in $files; do - [ -e "$file" ] || continue - [ ! -L "$file" ] && [ -d "$file" ] && continue - inst "$file" - done + while read -r file; do + install_package_file "$file" + done < <(dpkg-query -L "$deb" 2>/dev/null) done < <(grep -E '^Package:' "${SOURCE_DIR}/debian/control" | cut -d ':' -f 2) } @@ -1337,17 +1353,7 @@ install_rpm() { dinfo "Installing contents of RPM $rpm" while read -r file; do - # Skip missing files (like /etc/machine-info) - [[ ! -e "$file" ]] && continue - # Skip directories unless they are a symlink (both -L and -d pass in this case) - [[ -d "$file" && ! -L "$file" ]] && continue - # Skip python unit tests, since the image_install machinery will try to pull - # in the whole python stack in a very questionable state, making the tests fail. - # And given we're trying to transition to mkosi-based images anyway I'm not even - # going to bother - [[ "$file" =~ /tests/unit-tests/.*.py$ ]] && continue - - image_install "$file" + install_package_file "$file" done < <(rpm -ql "$rpm") } From 58bcbad86cc910e007fae3c66c3a5cfc17046801 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 14 Dec 2023 15:06:46 +0100 Subject: [PATCH 4/5] test: don't check for -Dinstall-tests=true with NO_BUILD=1 --- test/test-functions | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test-functions b/test/test-functions index 6a6f624d4c..f887346b34 100644 --- a/test/test-functions +++ b/test/test-functions @@ -3309,9 +3309,10 @@ test_create_image() { } test_setup() { - if get_bool "${TEST_REQUIRE_INSTALL_TESTS:?}" && \ - command -v meson >/dev/null && \ - [[ "$(meson configure "${BUILD_DIR:?}" | grep install-tests | awk '{ print $2 }')" != "true" ]]; then + if ! get_bool "$NO_BUILD" && \ + get_bool "${TEST_REQUIRE_INSTALL_TESTS:?}" && \ + command -v meson >/dev/null && \ + [[ "$(meson configure "${BUILD_DIR:?}" | grep install-tests | awk '{ print $2 }')" != "true" ]]; then dfatal "$BUILD_DIR needs to be built with -Dinstall-tests=true" exit 1 fi From 438c7cb20e83a3b88f6accc3e78d3da5e21f6db2 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 14 Dec 2023 16:59:21 +0100 Subject: [PATCH 5/5] test: tell delv to load anchors from /etc/bind.keys explicitly Since [0] delv no longer does that automagically, so we have to that explicitly with each delv invocation. Resolves: #30477 [0] https://github.com/isc-projects/bind9/commit/c144fd2871206d209ccdb916f5959a3ceab1d44c --- test/units/testsuite-75.sh | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/test/units/testsuite-75.sh b/test/units/testsuite-75.sh index 5dc31f8baa..093fdf94da 100755 --- a/test/units/testsuite-75.sh +++ b/test/units/testsuite-75.sh @@ -20,6 +20,12 @@ run() { "$@" |& tee "$RUN_OUT" } +run_delv() { + # Since [0] delv no longer loads /etc/(bind/)bind.keys by default, so we + # have to do that explicitly for each invocation + run delv -a /etc/bind.keys "$@" +} + disable_ipv6() { sysctl -w net.ipv6.conf.all.disable_ipv6=1 } @@ -356,15 +362,15 @@ grep -qF "unsigned.test IN MX 15 mail.unsigned.test" "$RUN_OUT" # Check the trust chain (with and without systemd-resolved in between # Issue: https://github.com/systemd/systemd/issues/22002 # PR: https://github.com/systemd/systemd/pull/23289 -run delv @ns1.unsigned.test signed.test +run_delv @ns1.unsigned.test signed.test grep -qF "; fully validated" "$RUN_OUT" -run delv signed.test +run_delv signed.test grep -qF "; fully validated" "$RUN_OUT" for addr in "${DNS_ADDRESSES[@]}"; do - run delv "@$addr" -t A mail.signed.test + run_delv "@$addr" -t A mail.signed.test grep -qF "; fully validated" "$RUN_OUT" - run delv "@$addr" -t AAAA mail.signed.test + run_delv "@$addr" -t AAAA mail.signed.test grep -qF "; fully validated" "$RUN_OUT" done run resolvectl query mail.signed.test @@ -402,7 +408,7 @@ grep -qF "10.0.0.123" "$RUN_OUT" grep -qF "fd00:dead:beef:cafe::123" "$RUN_OUT" grep -qF "authenticated: yes" "$RUN_OUT" # Check OPENPGPKEY support -run delv -t OPENPGPKEY 5a786cdc59c161cdafd818143705026636962198c66ed4c5b3da321e._openpgpkey.signed.test +run_delv -t OPENPGPKEY 5a786cdc59c161cdafd818143705026636962198c66ed4c5b3da321e._openpgpkey.signed.test grep -qF "; fully validated" "$RUN_OUT" run resolvectl openpgp mr.smith@signed.test grep -qF "5a786cdc59c161cdafd818143705026636962198c66ed4c5b3da321e._openpgpkey.signed.test" "$RUN_OUT" @@ -418,11 +424,11 @@ check_domain() { local addr for addr in "${DNS_ADDRESSES[@]}"; do - run delv "@$addr" -t "$record" "$domain" + run_delv "@$addr" -t "$record" "$domain" grep -qF "$message" "$RUN_OUT" done - run delv -t "$record" "$domain" + run_delv -t "$record" "$domain" grep -qF "$message" "$RUN_OUT" run resolvectl query "$domain" @@ -458,9 +464,9 @@ grep -qE "^follow14\.final\.signed\.test\..+IN\s+NSEC\s+" "$RUN_OUT" # Check the trust chain (with and without systemd-resolved in between # Issue: https://github.com/systemd/systemd/issues/22002 # PR: https://github.com/systemd/systemd/pull/23289 -run delv @ns1.unsigned.test sub.onlinesign.test +run_delv @ns1.unsigned.test sub.onlinesign.test grep -qF "; fully validated" "$RUN_OUT" -run delv sub.onlinesign.test +run_delv sub.onlinesign.test grep -qF "; fully validated" "$RUN_OUT" run dig +short sub.onlinesign.test @@ -474,11 +480,11 @@ run resolvectl query --legend=no -t TXT onlinesign.test grep -qF 'onlinesign.test IN TXT "hello from onlinesign"' "$RUN_OUT" for addr in "${DNS_ADDRESSES[@]}"; do - run delv "@$addr" -t A dual.onlinesign.test + run_delv "@$addr" -t A dual.onlinesign.test grep -qF "10.0.0.135" "$RUN_OUT" - run delv "@$addr" -t AAAA dual.onlinesign.test + run_delv "@$addr" -t AAAA dual.onlinesign.test grep -qF "fd00:dead:beef:cafe::135" "$RUN_OUT" - run delv "@$addr" -t ANY ipv6.onlinesign.test + run_delv "@$addr" -t ANY ipv6.onlinesign.test grep -qF "fd00:dead:beef:cafe::136" "$RUN_OUT" done run resolvectl query dual.onlinesign.test