From b378596b1424caf6b2d3c268d0a6f675065e05d2 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 18 Nov 2024 19:04:10 +0100 Subject: [PATCH] test/system: Try to handle /etc/resolv.conf on host as absolute symlink Some Arch Linux hosts have /etc/resolv.conf as an absolute symbolic link to /run/systemd/resolve/stub-resolv.conf, instead of being a relative symbolic link to ../run/systemd/resolve/stub-resolv.conf or a regular file. eg., the images built by arch-boxes [1]. This changes the target that the Toolbx container's /etc/resolv.conf points at and confuses the tests [2]. Ideally, these host operating systems should be fixed to use relative symbolic links. This is highlighted by skipping the tests, because there's no point in failing them until that happens. This is a step towards running the CI on Arch Linux. [1] https://gitlab.archlinux.org/archlinux/arch-boxes https://geo.mirror.pkgbuild.com/images/latest/ [2] Commit 88a95b07af335be2 https://github.com/containers/toolbox/commit/88a95b07af335be2 https://github.com/containers/toolbox/issues/187 https://github.com/containers/toolbox/issues/1438 --- test/system/203-network.bats | 56 +++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/test/system/203-network.bats b/test/system/203-network.bats index 4f484f52d..e29cdeab4 100644 --- a/test/system/203-network.bats +++ b/test/system/203-network.bats @@ -69,7 +69,13 @@ teardown() { run --keep-empty-lines --separate-stderr "$TOOLBX" run readlink /etc/resolv.conf assert_success - assert_line --index 0 "/run/host/etc/resolv.conf" + + if [ "${lines[0]}" = "/run/host/run/systemd/resolve/stub-resolv.conf" ]; then + skip "host has absolute symlink" + else + assert_line --index 0 "/run/host/etc/resolv.conf" + fi + assert [ ${#lines[@]} -eq 1 ] # shellcheck disable=SC2154 @@ -83,7 +89,13 @@ teardown() { run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro arch readlink /etc/resolv.conf assert_success - assert_line --index 0 "/run/host/etc/resolv.conf" + + if [ "${lines[0]}" = "/run/host/run/systemd/resolve/stub-resolv.conf" ]; then + skip "host has absolute symlink" + else + assert_line --index 0 "/run/host/etc/resolv.conf" + fi + assert [ ${#lines[@]} -eq 1 ] # shellcheck disable=SC2154 @@ -97,7 +109,13 @@ teardown() { run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro fedora --release 34 readlink /etc/resolv.conf assert_success - assert_line --index 0 "/run/host/etc/resolv.conf" + + if [ "${lines[0]}" = "/run/host/run/systemd/resolve/stub-resolv.conf" ]; then + skip "host has absolute symlink" + else + assert_line --index 0 "/run/host/etc/resolv.conf" + fi + assert [ ${#lines[@]} -eq 1 ] # shellcheck disable=SC2154 @@ -111,7 +129,13 @@ teardown() { run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro rhel --release 8.10 readlink /etc/resolv.conf assert_success - assert_line --index 0 "/run/host/etc/resolv.conf" + + if [ "${lines[0]}" = "/run/host/run/systemd/resolve/stub-resolv.conf" ]; then + skip "host has absolute symlink" + else + assert_line --index 0 "/run/host/etc/resolv.conf" + fi + assert [ ${#lines[@]} -eq 1 ] # shellcheck disable=SC2154 @@ -125,7 +149,13 @@ teardown() { run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 16.04 readlink /etc/resolv.conf assert_success - assert_line --index 0 "/run/host/etc/resolv.conf" + + if [ "${lines[0]}" = "/run/host/run/systemd/resolve/stub-resolv.conf" ]; then + skip "host has absolute symlink" + else + assert_line --index 0 "/run/host/etc/resolv.conf" + fi + assert [ ${#lines[@]} -eq 1 ] # shellcheck disable=SC2154 @@ -139,7 +169,13 @@ teardown() { run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 18.04 readlink /etc/resolv.conf assert_success - assert_line --index 0 "/run/host/etc/resolv.conf" + + if [ "${lines[0]}" = "/run/host/run/systemd/resolve/stub-resolv.conf" ]; then + skip "host has absolute symlink" + else + assert_line --index 0 "/run/host/etc/resolv.conf" + fi + assert [ ${#lines[@]} -eq 1 ] # shellcheck disable=SC2154 @@ -153,7 +189,13 @@ teardown() { run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 20.04 readlink /etc/resolv.conf assert_success - assert_line --index 0 "/run/host/etc/resolv.conf" + + if [ "${lines[0]}" = "/run/host/run/systemd/resolve/stub-resolv.conf" ]; then + skip "host has absolute symlink" + else + assert_line --index 0 "/run/host/etc/resolv.conf" + fi + assert [ ${#lines[@]} -eq 1 ] # shellcheck disable=SC2154