From: Yu Watanabe Date: Thu, 24 Oct 2024 15:24:04 +0000 (+0900) Subject: TEST-13-NSPAWN: check returned machine list X-Git-Tag: v257-rc1~74^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1856ab4503a1c06994e82ff6c0dfc3a6dc41c69a;p=thirdparty%2Fsystemd.git TEST-13-NSPAWN: check returned machine list --- diff --git a/test/units/TEST-13-NSPAWN.machined.sh b/test/units/TEST-13-NSPAWN.machined.sh index 24eb673af30..d014dfe1ba0 100755 --- a/test/units/TEST-13-NSPAWN.machined.sh +++ b/test/units/TEST-13-NSPAWN.machined.sh @@ -305,6 +305,10 @@ varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Unreg # test io.systemd.Machine.List with addresses, OSRelease, and UIDShift fields create_dummy_container "/var/lib/machines/container-without-os-release" cat >>/var/lib/machines/container-without-os-release/sbin/init <<\EOF +ip link add hoge type dummy +ip link set hoge up +ip address add 192.0.2.1/24 dev hoge + PID=0 trap 'kill 0' RTMIN+3 @@ -326,7 +330,17 @@ machinectl start "container-without-os-release" timeout 30 bash -c "until test -e /var/lib/machines/container-without-os-release/ready; do sleep .5; done" rm -f /var/lib/machines/container-without-os-release/etc/os-release /var/lib/machines/container-without-os-release/usr/lib/os-release (! varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name": "container-without-os-release", "acquireMetadata": "yes"}') -varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name": "container-without-os-release", "acquireMetadata": "graceful"}' +output=$(varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name": "container-without-os-release", "acquireMetadata": "graceful"}') +assert_eq "$(echo "$output" | jq --seq .name | tr -d \\036)" '"container-without-os-release"' +assert_eq "$(echo "$output" | jq --seq .class | tr -d \\036)" '"container"' +assert_eq "$(echo "$output" | jq --seq .service | tr -d \\036)" '"systemd-nspawn"' +assert_eq "$(echo "$output" | jq --seq .rootDirectory | tr -d \\036)" '"/var/lib/machines/container-without-os-release"' +assert_eq "$(echo "$output" | jq --seq .unit | tr -d \\036)" '"systemd-nspawn@container-without-os-release.service"' +assert_eq "$(echo "$output" | jq --seq .addresses[0].family | tr -d \\036)" '2' +assert_eq "$(echo "$output" | jq --seq .addresses[0].address[0] | tr -d \\036)" '192' +assert_eq "$(echo "$output" | jq --seq .addresses[0].address[1] | tr -d \\036)" '0' +assert_eq "$(echo "$output" | jq --seq .addresses[0].address[2] | tr -d \\036)" '2' +assert_eq "$(echo "$output" | jq --seq .addresses[0].address[3] | tr -d \\036)" '1' machinectl terminate "container-without-os-release" (ip addr show lo | grep -q 192.168.1.100) || ip address add 192.168.1.100/24 dev lo