diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-16 18:27:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-16 18:27:56 +0000 |
commit | 26fde72265073b26498ce55596c0eda1bc3113b4 (patch) | |
tree | 580247f9ae59f3bb05e3b9ee52eb4fe51b63887b /test | |
parent | Adding upstream version 256.5. (diff) | |
download | systemd-26fde72265073b26498ce55596c0eda1bc3113b4.tar.xz systemd-26fde72265073b26498ce55596c0eda1bc3113b4.zip |
Adding upstream version 256.6.upstream/256.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test')
-rwxr-xr-x | test/TEST-13-NSPAWN/test.sh | 2 | ||||
-rwxr-xr-x | test/integration-test-wrapper.py | 2 | ||||
-rw-r--r-- | test/test-functions | 25 | ||||
-rw-r--r-- | test/test-systemctl-enable.sh | 2 | ||||
-rwxr-xr-x | test/units/TEST-13-NSPAWN.nspawn.sh | 60 | ||||
-rwxr-xr-x | test/units/TEST-58-REPART.sh | 45 | ||||
-rwxr-xr-x | test/units/TEST-74-AUX-UTILS.detect-virt.sh | 7 |
7 files changed, 131 insertions, 12 deletions
diff --git a/test/TEST-13-NSPAWN/test.sh b/test/TEST-13-NSPAWN/test.sh index 5c85b0c..3ab52d0 100755 --- a/test/TEST-13-NSPAWN/test.sh +++ b/test/TEST-13-NSPAWN/test.sh @@ -17,6 +17,8 @@ test_append_files() { # For virtual wlan interface. instmods mac80211_hwsim + # for IPMasquerade= + instmods "=net/netfilter" generate_module_dependencies # Create a dummy container "template" with a minimal toolset, which we can diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index 0931043..e0a4b6e 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -149,7 +149,7 @@ def main(): '--runtime-scratch=no', *args.mkosi_args, '--qemu-firmware', args.firmware, - '--qemu-kvm', "auto" if not bool(int(os.getenv("TEST_NO_KVM", "0"))) else "no", + *(['--qemu-kvm', 'no'] if int(os.getenv("TEST_NO_KVM", "0")) else []), '--kernel-command-line-extra', ' '.join([ 'systemd.hostname=H', diff --git a/test/test-functions b/test/test-functions index 04fe20f..69a0e58 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1453,10 +1453,31 @@ install_missing_libraries() { [[ -e "$libgcc_s" ]] && inst_library "$libgcc_s" done < <(ldconfig -p | awk '/\/libgcc_s.so.1$/ { print $4 }') - local lib path + local lib path libs # A number of dependencies is now optional via dlopen, so the install # script will not pick them up, since it looks at linkage. - for lib in libcryptsetup libidn libidn2 pwquality libqrencode tss2-esys tss2-rc tss2-mu tss2-tcti-device libfido2 libbpf libelf libdw xkbcommon p11-kit-1 libarchive libgcrypt libkmod; do + libs=( + libarchive + libbpf + libcryptsetup + libdw + libelf + libfido2 + libgcrypt + libidn + libidn2 + libip4tc + libkmod + libqrencode + p11-kit-1 + pwquality + tss2-esys + tss2-mu + tss2-rc + tss2-tcti-device + xkbcommon + ) + for lib in "${libs[@]}"; do ddebug "Searching for $lib via pkg-config" if pkg-config --exists "$lib"; then path="$(pkg-config --variable=libdir "$lib")" diff --git a/test/test-systemctl-enable.sh b/test/test-systemctl-enable.sh index 5615c90..3fc59f6 100644 --- a/test/test-systemctl-enable.sh +++ b/test/test-systemctl-enable.sh @@ -3,7 +3,7 @@ set -ex # Silence warning from running_in_chroot_or_offline() -export SYSTEMD_IGNORE_CHROOT=1 +export SYSTEMD_IN_CHROOT=0 systemctl=${1:-systemctl} systemd_id128=${2:-systemd-id128} diff --git a/test/units/TEST-13-NSPAWN.nspawn.sh b/test/units/TEST-13-NSPAWN.nspawn.sh index ee0fef8..ad11468 100755 --- a/test/units/TEST-13-NSPAWN.nspawn.sh +++ b/test/units/TEST-13-NSPAWN.nspawn.sh @@ -943,6 +943,17 @@ matrix_run_one() { return 0 } +testcase_api_vfs() { + local api_vfs_writable + + for api_vfs_writable in yes no network; do + matrix_run_one no no $api_vfs_writable + matrix_run_one yes no $api_vfs_writable + matrix_run_one no yes $api_vfs_writable + matrix_run_one yes yes $api_vfs_writable + done +} + testcase_check_os_release() { # https://github.com/systemd/systemd/issues/29185 local base common_opts root @@ -973,11 +984,46 @@ testcase_check_os_release() { rm -fr "$root" "$base" } -run_testcases +testcase_ip_masquerade() { + local root + + if ! command -v networkctl >/dev/null; then + echo "This test requires systemd-networkd, skipping..." + return 0 + fi + + systemctl unmask systemd-networkd.service + systemctl edit --runtime --stdin systemd-networkd.service --drop-in=debug.conf <<EOF +[Service] +Environment=SYSTEMD_LOG_LEVEL=debug +EOF + systemctl start systemd-networkd.service -for api_vfs_writable in yes no network; do - matrix_run_one no no $api_vfs_writable - matrix_run_one yes no $api_vfs_writable - matrix_run_one no yes $api_vfs_writable - matrix_run_one yes yes $api_vfs_writable -done + root="$(mktemp -d /var/lib/machines/TEST-13-NSPAWN.ip_masquerade.XXX)" + create_dummy_container "$root" + + systemd-run --unit=nspawn-hoge.service \ + systemd-nspawn \ + --register=no \ + --directory="$root" \ + --ephemeral \ + --machine=hoge \ + --network-veth \ + bash -x -c "ip link set host0 up; sleep 30s" + + /usr/lib/systemd/systemd-networkd-wait-online -i ve-hoge --timeout 30s + + # Check IPMasquerade= for ve-* and friends enabled IP forwarding. + [[ "$(cat /proc/sys/net/ipv4/conf/all/forwarding)" == "1" ]] + [[ "$(cat /proc/sys/net/ipv4/conf/default/forwarding)" == "1" ]] + [[ "$(cat /proc/sys/net/ipv6/conf/all/forwarding)" == "1" ]] + [[ "$(cat /proc/sys/net/ipv6/conf/default/forwarding)" == "1" ]] + + systemctl stop nspawn-hoge.service || : + systemctl stop systemd-networkd.service + systemctl mask systemd-networkd.service + + rm -fr "$root" +} + +run_testcases diff --git a/test/units/TEST-58-REPART.sh b/test/units/TEST-58-REPART.sh index f8c22ab..e5f9c1f 100755 --- a/test/units/TEST-58-REPART.sh +++ b/test/units/TEST-58-REPART.sh @@ -161,7 +161,7 @@ $imgs/zzz1 : start= 2048, size= 1775576, type=933AC7E1-2EB4-4F13-B844 $imgs/zzz2 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=78C92DB8-3D2B-4823-B0DC-792B78F66F1E, name=\"swap\"" systemd-repart --offline="$OFFLINE" \ - --definitions="$defs" \ + --definitions="$defs" \ --empty=create \ --size=50M \ --seed="$seed" \ @@ -1288,6 +1288,49 @@ testcase_dropped_partitions() { [[ "$(sfdisk -q -l "$image" | grep -c "$image")" -eq 2 ]] } +testcase_random_seed() { + local defs imgs output + + # For issue #34257 + + defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")" + imgs="$(mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")" + # shellcheck disable=SC2064 + trap "rm -rf '$defs' '$imgs'" RETURN + chmod 0755 "$defs" + + tee "$defs/root.conf" <<EOF +[Partition] +Type=root +EOF + + tee "$defs/home.conf" <<EOF +[Partition] +Type=home +Label=home-first +EOF + + tee "$defs/swap.conf" <<EOF +[Partition] +Type=swap +SizeMaxBytes=64M +PaddingMinBytes=92M +EOF + + systemd-repart --offline="$OFFLINE" \ + --definitions="$defs" \ + --empty=create \ + --size=1G \ + --dry-run=no \ + --seed=random \ + --offline="$OFFLINE" \ + --json=pretty \ + "$imgs/zzz" + + sfdisk -d "$imgs/zzz" + [[ "$(sfdisk -d "$imgs/zzz" | grep -F 'uuid=' | awk '{ print $8 }' | sort -u | wc -l)" == "3" ]] +} + OFFLINE="yes" run_testcases diff --git a/test/units/TEST-74-AUX-UTILS.detect-virt.sh b/test/units/TEST-74-AUX-UTILS.detect-virt.sh new file mode 100755 index 0000000..fe1db4d --- /dev/null +++ b/test/units/TEST-74-AUX-UTILS.detect-virt.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eux +set -o pipefail + +SYSTEMD_IN_CHROOT=1 systemd-detect-virt --chroot +(! SYSTEMD_IN_CHROOT=0 systemd-detect-virt --chroot) |