summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/TEST-01-BASIC/test.sh3
-rwxr-xr-xtest/TEST-03-JOBS/test.sh3
-rwxr-xr-xtest/TEST-04-JOURNAL/test.sh3
-rwxr-xr-xtest/TEST-05-RLIMITS/test.sh3
-rwxr-xr-xtest/TEST-06-SELINUX/test.sh2
-rwxr-xr-xtest/TEST-07-ISSUE-1981/test.sh6
-rwxr-xr-xtest/TEST-08-ISSUE-2730/test.sh8
-rwxr-xr-xtest/TEST-09-ISSUE-2691/test.sh8
-rwxr-xr-xtest/TEST-10-ISSUE-2467/test.sh7
-rwxr-xr-xtest/TEST-11-ISSUE-3166/test.sh7
-rwxr-xr-xtest/TEST-12-ISSUE-3171/test.sh7
-rwxr-xr-xtest/networkd-test.py92
-rwxr-xr-xtest/test-efi-create-disk.sh4
-rw-r--r--test/test-execute/exec-personality-aarch64.service7
-rw-r--r--test/test-execute/exec-personality-ppc64.service7
-rw-r--r--test/test-execute/exec-personality-ppc64le.service7
-rw-r--r--test/test-functions44
-rwxr-xr-xtest/udev-test.pl11
18 files changed, 156 insertions, 73 deletions
diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh
index 21eed9b22a..041195dcd8 100755
--- a/test/TEST-01-BASIC/test.sh
+++ b/test/TEST-01-BASIC/test.sh
@@ -25,8 +25,7 @@ test_run() {
else
dwarn "can't run QEMU, skipping"
fi
- if check_nspawn; then
- run_nspawn
+ if run_nspawn; then
check_result_nspawn || return 1
else
dwarn "can't run systemd-nspawn, skipping"
diff --git a/test/TEST-03-JOBS/test.sh b/test/TEST-03-JOBS/test.sh
index 83393435f0..ab0de0bfd1 100755
--- a/test/TEST-03-JOBS/test.sh
+++ b/test/TEST-03-JOBS/test.sh
@@ -25,8 +25,7 @@ test_run() {
else
dwarn "can't run QEMU, skipping"
fi
- if check_nspawn; then
- run_nspawn
+ if run_nspawn; then
check_result_nspawn || return 1
else
dwarn "can't run systemd-nspawn, skipping"
diff --git a/test/TEST-04-JOURNAL/test.sh b/test/TEST-04-JOURNAL/test.sh
index 1a14f76060..3ccf113019 100755
--- a/test/TEST-04-JOURNAL/test.sh
+++ b/test/TEST-04-JOURNAL/test.sh
@@ -25,8 +25,7 @@ test_run() {
else
dwarn "can't run QEMU, skipping"
fi
- if check_nspawn; then
- run_nspawn
+ if run_nspawn; then
check_result_nspawn || return 1
else
dwarn "can't run systemd-nspawn, skipping"
diff --git a/test/TEST-05-RLIMITS/test.sh b/test/TEST-05-RLIMITS/test.sh
index 6eaa0b8f34..a5f7e8de0b 100755
--- a/test/TEST-05-RLIMITS/test.sh
+++ b/test/TEST-05-RLIMITS/test.sh
@@ -25,8 +25,7 @@ test_run() {
else
dwarn "can't run QEMU, skipping"
fi
- if check_nspawn; then
- run_nspawn
+ if run_nspawn; then
check_result_nspawn || return 1
else
dwarn "can't run systemd-nspawn, skipping"
diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh
index 4f5895be66..1ae4a7c0d9 100755
--- a/test/TEST-06-SELINUX/test.sh
+++ b/test/TEST-06-SELINUX/test.sh
@@ -10,7 +10,7 @@ TEST_DESCRIPTION="SELinux tests"
. $TEST_BASE_DIR/test-functions
SETUP_SELINUX=yes
-KERNEL_APPEND="$KERNEL_APPEND selinux=1"
+KERNEL_APPEND="$KERNEL_APPEND selinux=1 security=selinux"
check_result_qemu() {
ret=1
diff --git a/test/TEST-07-ISSUE-1981/test.sh b/test/TEST-07-ISSUE-1981/test.sh
index d97c4ec27d..2f7f01058e 100755
--- a/test/TEST-07-ISSUE-1981/test.sh
+++ b/test/TEST-07-ISSUE-1981/test.sh
@@ -5,11 +5,11 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
. $TEST_BASE_DIR/test-functions
+NSPAWN_TIMEOUT=30s
+
test_run() {
dwarn "skipping QEMU"
- if check_nspawn; then
- NSPAWN_TIMEOUT=30s
- run_nspawn
+ if run_nspawn; then
check_result_nspawn || return 1
else
dwarn "can't run systemd-nspawn, skipping"
diff --git a/test/TEST-08-ISSUE-2730/test.sh b/test/TEST-08-ISSUE-2730/test.sh
index 409140157a..44831983b3 100755
--- a/test/TEST-08-ISSUE-2730/test.sh
+++ b/test/TEST-08-ISSUE-2730/test.sh
@@ -19,12 +19,16 @@ check_result_qemu() {
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
ls -l $TESTDIR/journal/*/*.journal
test -s $TESTDIR/failed && ret=$(($ret+1))
+ [ -n "$TIMED_OUT" ] && ret=$(($ret+1))
return $ret
}
test_run() {
- run_qemu || return 1
- check_result_qemu || return 1
+ if run_qemu; then
+ check_result_qemu || return 1
+ else
+ dwarn "can't run QEMU, skipping"
+ fi
return 0
}
diff --git a/test/TEST-09-ISSUE-2691/test.sh b/test/TEST-09-ISSUE-2691/test.sh
index e247694f01..8ae02e61ac 100755
--- a/test/TEST-09-ISSUE-2691/test.sh
+++ b/test/TEST-09-ISSUE-2691/test.sh
@@ -18,12 +18,16 @@ check_result_qemu() {
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
ls -l $TESTDIR/journal/*/*.journal
test -s $TESTDIR/failed && ret=$(($ret+1))
+ [ -n "$TIMED_OUT" ] && ret=$(($ret+1))
return $ret
}
test_run() {
- run_qemu || return 1
- check_result_qemu || return 1
+ if run_qemu; then
+ check_result_qemu || return 1
+ else
+ dwarn "can't run QEMU, skipping"
+ fi
return 0
}
diff --git a/test/TEST-10-ISSUE-2467/test.sh b/test/TEST-10-ISSUE-2467/test.sh
index a652b0d812..4eca6784bc 100755
--- a/test/TEST-10-ISSUE-2467/test.sh
+++ b/test/TEST-10-ISSUE-2467/test.sh
@@ -21,8 +21,11 @@ check_result_qemu() {
}
test_run() {
- run_qemu || return 1
- check_result_qemu || return 1
+ if run_qemu; then
+ check_result_qemu || return 1
+ else
+ dwarn "can't run QEMU, skipping"
+ fi
return 0
}
diff --git a/test/TEST-11-ISSUE-3166/test.sh b/test/TEST-11-ISSUE-3166/test.sh
index 7913537e9b..0f269c8211 100755
--- a/test/TEST-11-ISSUE-3166/test.sh
+++ b/test/TEST-11-ISSUE-3166/test.sh
@@ -21,8 +21,11 @@ check_result_qemu() {
}
test_run() {
- run_qemu || return 1
- check_result_qemu || return 1
+ if run_qemu; then
+ check_result_qemu || return 1
+ else
+ dwarn "can't run QEMU, skipping"
+ fi
return 0
}
diff --git a/test/TEST-12-ISSUE-3171/test.sh b/test/TEST-12-ISSUE-3171/test.sh
index 925dcad9ea..e20f470143 100755
--- a/test/TEST-12-ISSUE-3171/test.sh
+++ b/test/TEST-12-ISSUE-3171/test.sh
@@ -6,8 +6,11 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171"
. $TEST_BASE_DIR/test-functions
test_run() {
- run_nspawn || return 1
- check_result_nspawn || return 1
+ if run_nspawn; then
+ check_result_nspawn || return 1
+ else
+ dwarn "can't run systemd-nspawn, skipping"
+ fi
return 0
}
diff --git a/test/networkd-test.py b/test/networkd-test.py
index f94224cce2..bfa1bf3580 100755
--- a/test/networkd-test.py
+++ b/test/networkd-test.py
@@ -42,6 +42,8 @@ networkd_active = subprocess.call(['systemctl', 'is-active', '--quiet',
'systemd-networkd']) == 0
have_dnsmasq = shutil.which('dnsmasq')
+RESOLV_CONF = '/run/systemd/resolve/resolv.conf'
+
@unittest.skipIf(networkd_active,
'networkd is already active')
@@ -104,6 +106,7 @@ class ClientTestBase:
def do_test(self, coldplug=True, ipv6=False, extra_opts='',
online_timeout=10, dhcp_mode='yes'):
+ subprocess.check_call(['systemctl', 'start', 'systemd-resolved'])
with open(self.config, 'w') as f:
f.write('''[Match]
Name=%s
@@ -179,20 +182,14 @@ DHCP=%s
self.print_server_log()
raise
- # verify resolv.conf if it gets dynamically managed
- if os.path.islink('/etc/resolv.conf'):
- for timeout in range(50):
- with open('/etc/resolv.conf') as f:
- contents = f.read()
- if 'nameserver 192.168.5.1\n' in contents:
- break
- # resolv.conf can have at most three nameservers; if we already
- # have three different ones, that's also okay
- if contents.count('nameserver ') >= 3:
- break
- time.sleep(0.1)
- else:
- self.fail('nameserver 192.168.5.1 not found in /etc/resolv.conf')
+ for timeout in range(50):
+ with open(RESOLV_CONF) as f:
+ contents = f.read()
+ if 'nameserver 192.168.5.1\n' in contents:
+ break
+ time.sleep(0.1)
+ else:
+ self.fail('nameserver 192.168.5.1 not found in ' + RESOLV_CONF)
if not coldplug:
# check post-down.d hook
@@ -205,7 +202,7 @@ DHCP=%s
def test_coldplug_dhcp_yes_ip4_no_ra(self):
# with disabling RA explicitly things should be fast
self.do_test(coldplug=True, ipv6=False,
- extra_opts='IPv6AcceptRouterAdvertisements=False')
+ extra_opts='IPv6AcceptRA=False')
def test_coldplug_dhcp_ip4_only(self):
# we have a 12s timeout on RA, so we need to wait longer
@@ -215,7 +212,7 @@ DHCP=%s
def test_coldplug_dhcp_ip4_only_no_ra(self):
# with disabling RA explicitly things should be fast
self.do_test(coldplug=True, ipv6=False, dhcp_mode='ipv4',
- extra_opts='IPv6AcceptRouterAdvertisements=False')
+ extra_opts='IPv6AcceptRA=False')
def test_coldplug_dhcp_ip6(self):
self.do_test(coldplug=True, ipv6=True)
@@ -227,6 +224,32 @@ DHCP=%s
def test_hotplug_dhcp_ip6(self):
self.do_test(coldplug=False, ipv6=True)
+ def test_route_only_dns(self):
+ with open('/run/systemd/network/myvpn.netdev', 'w') as f:
+ f.write('''[NetDev]
+Name=dummy0
+Kind=dummy
+MACAddress=12:34:56:78:9a:bc''')
+ with open('/run/systemd/network/myvpn.network', 'w') as f:
+ f.write('''[Match]
+Name=dummy0
+[Network]
+Address=192.168.42.100
+DNS=192.168.42.1
+Domains= ~company''')
+ self.addCleanup(os.remove, '/run/systemd/network/myvpn.netdev')
+ self.addCleanup(os.remove, '/run/systemd/network/myvpn.network')
+
+ self.do_test(coldplug=True, ipv6=False,
+ extra_opts='IPv6AcceptRouterAdvertisements=False')
+
+ with open(RESOLV_CONF) as f:
+ contents = f.read()
+ # ~company is not a search domain, only a routing domain
+ self.assertNotRegex(contents, 'search.*company')
+ # our global server should appear
+ self.assertIn('nameserver 192.168.5.1\n', contents)
+
@unittest.skipUnless(have_dnsmasq, 'dnsmasq not installed')
class DnsmasqClientTest(ClientTestBase, unittest.TestCase):
@@ -392,16 +415,15 @@ Domains= one two three four five six seven eight nine ten''')
subprocess.check_call(['systemctl', 'start', 'systemd-networkd'])
- if os.path.islink('/etc/resolv.conf'):
- for timeout in range(50):
- with open('/etc/resolv.conf') as f:
- contents = f.read()
- if 'search one\n' in contents:
- break
- time.sleep(0.1)
- self.assertIn('search one two three four five six\n'
- '# Too many search domains configured, remaining ones ignored.\n',
- contents)
+ for timeout in range(50):
+ with open(RESOLV_CONF) as f:
+ contents = f.read()
+ if ' one' in contents:
+ break
+ time.sleep(0.1)
+ self.assertRegex(contents, 'search .*one two three four')
+ self.assertNotIn('seven\n', contents)
+ self.assertIn('# Too many search domains configured, remaining ones ignored.\n', contents)
def test_search_domains_too_long(self):
@@ -430,16 +452,14 @@ Domains=''')
subprocess.check_call(['systemctl', 'start', 'systemd-networkd'])
- if os.path.islink('/etc/resolv.conf'):
- for timeout in range(50):
- with open('/etc/resolv.conf') as f:
- contents = f.read()
- if 'search one\n' in contents:
- break
- time.sleep(0.1)
- self.assertIn('search %(p)s0 %(p)s1 %(p)s2 %(p)s3\n'
- '# Total length of all search domains is too long, remaining ones ignored.' % {'p': name_prefix},
- contents)
+ for timeout in range(50):
+ with open(RESOLV_CONF) as f:
+ contents = f.read()
+ if ' one' in contents:
+ break
+ time.sleep(0.1)
+ self.assertRegex(contents, 'search .*%(p)s0 %(p)s1 %(p)s2' % {'p': name_prefix})
+ self.assertIn('# Total length of all search domains is too long, remaining ones ignored.', contents)
if __name__ == '__main__':
diff --git a/test/test-efi-create-disk.sh b/test/test-efi-create-disk.sh
index 56dd09abd7..cd4699dc18 100755
--- a/test/test-efi-create-disk.sh
+++ b/test/test-efi-create-disk.sh
@@ -11,8 +11,8 @@ mkfs.vfat -F32 ${LOOP}p1
mkdir -p mnt
mount ${LOOP}p1 mnt
-mkdir -p mnt/EFI/{Boot,systemd}
-cp systemd-bootx64.efi mnt/EFI/Boot/bootx64.efi
+mkdir -p mnt/EFI/{BOOT,systemd}
+cp systemd-bootx64.efi mnt/EFI/BOOT/BOOTX64.efi
[ -e /boot/shellx64.efi ] && cp /boot/shellx64.efi mnt/
diff --git a/test/test-execute/exec-personality-aarch64.service b/test/test-execute/exec-personality-aarch64.service
new file mode 100644
index 0000000000..40b6d95e3a
--- /dev/null
+++ b/test/test-execute/exec-personality-aarch64.service
@@ -0,0 +1,7 @@
+Unit]
+Description=Test for Personality=aarch64
+
+[Service]
+ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "aarch64")'
+Type=oneshot
+Personality=aarch64
diff --git a/test/test-execute/exec-personality-ppc64.service b/test/test-execute/exec-personality-ppc64.service
new file mode 100644
index 0000000000..ccc2c8d83d
--- /dev/null
+++ b/test/test-execute/exec-personality-ppc64.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for Personality=ppc64
+
+[Service]
+ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "ppc64")'
+Type=oneshot
+Personality=ppc64
diff --git a/test/test-execute/exec-personality-ppc64le.service b/test/test-execute/exec-personality-ppc64le.service
new file mode 100644
index 0000000000..2a7625087d
--- /dev/null
+++ b/test/test-execute/exec-personality-ppc64le.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for Personality=ppc64le
+
+[Service]
+ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "ppc64le")'
+Type=oneshot
+Personality=ppc64le
diff --git a/test/test-functions b/test/test-functions
index 5f95a8129e..567a000b8d 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -9,6 +9,7 @@ KERNEL_VER=${KERNEL_VER-$(uname -r)}
KERNEL_MODS="/lib/modules/$KERNEL_VER/"
QEMU_TIMEOUT="${QEMU_TIMEOUT:-infinity}"
NSPAWN_TIMEOUT="${NSPAWN_TIMEOUT:-infinity}"
+TIMED_OUT= # will be 1 after run_* if *_TIMEOUT is set and test timed out
FSTYPE="${FSTYPE:-ext3}"
UNIFIED_CGROUP_HIERARCHY="${UNIFIED_CGROUP_HIERARCHY:-no}"
@@ -46,6 +47,8 @@ function find_qemu_bin() {
fi
}
+# Return 0 if QEMU did run (then you must check the result state/logs for actual
+# success), or 1 if QEMU is not available.
run_qemu() {
if [ -f /etc/machine-id ]; then
read MACHINE_ID < /etc/machine-id
@@ -94,11 +97,22 @@ $KERNEL_APPEND \
if [[ "$QEMU_TIMEOUT" != "infinity" ]]; then
QEMU_BIN="timeout --foreground $QEMU_TIMEOUT $QEMU_BIN"
fi
- ( set -x
- $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND" ) || return 1
+ (set -x; $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND")
+ rc=$?
+ if [ "$rc" = 124 ] && [ "$QEMU_TIMEOUT" != "infinity" ]; then
+ derror "test timed out after $QEMU_TIMEOUT s"
+ TIMED_OUT=1
+ else
+ [ "$rc" != 0 ] && derror "QEMU failed with exit code $rc"
+ fi
+ return 0
}
+# Return 0 if nspawn did run (then you must check the result state/logs for actual
+# success), or 1 if nspawn is not available.
run_nspawn() {
+ [[ -d /run/systemd/system ]] || return 1
+
local _nspawn_cmd="../../systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND"
if [[ "$NSPAWN_TIMEOUT" != "infinity" ]]; then
_nspawn_cmd="timeout --foreground $NSPAWN_TIMEOUT $_nspawn_cmd"
@@ -106,8 +120,15 @@ run_nspawn() {
_nspawn_cmd="env UNIFIED_CGROUP_HIERARCHY=$UNIFIED_CGROUP_HIERARCHY $_nspawn_cmd"
- set -x
- $_nspawn_cmd
+ (set -x; $_nspawn_cmd)
+ rc=$?
+ if [ "$rc" = 124 ] && [ "$NSPAWN_TIMEOUT" != "infinity" ]; then
+ derror "test timed out after $NSPAWN_TIMEOUT s"
+ TIMED_OUT=1
+ else
+ [ "$rc" != 0 ] && derror "nspawn failed with exit code $rc"
+ fi
+ return 0
}
setup_basic_environment() {
@@ -254,10 +275,15 @@ install_systemd() {
echo LogLevel=debug >> $initdir/etc/systemd/system.conf
}
+get_ldpath() {
+ local _bin="$1"
+ objdump -p "$_bin" 2>/dev/null | awk "/R(UN)?PATH/ { print \"$initdir\" \$2 }" | paste -sd :
+}
+
install_missing_libraries() {
# install possible missing libraries
- for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
- inst_libs $i
+ for i in $initdir{,/usr}/{sbin,bin}/* $initdir{,/usr}/lib/systemd/*; do
+ LD_LIBRARY_PATH=$(get_ldpath $i) inst_libs $i
done
}
@@ -290,6 +316,7 @@ check_result_nspawn() {
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
ls -l $TESTDIR/journal/*/*.journal
test -s $TESTDIR/failed && ret=$(($ret+1))
+ [ -n "$TIMED_OUT" ] && ret=$(($ret+1))
return $ret
}
@@ -1266,11 +1293,6 @@ inst_libdir_file() {
fi
}
-check_nspawn() {
- [[ -d /run/systemd/system ]]
-}
-
-
do_test() {
if [[ $UID != "0" ]]; then
echo "TEST: $TEST_DESCRIPTION [SKIPPED]: not root" >&2
diff --git a/test/udev-test.pl b/test/udev-test.pl
index da0a4e1f6b..129af854f1 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -1535,11 +1535,18 @@ if (!($<==0)) {
exit($EXIT_TEST_SKIP);
}
+# skip the test when running in a chroot
+system("systemd-detect-virt", "-r", "-q");
+if ($? >> 8 == 0) {
+ print "Running in a chroot, skipping the test.\n";
+ exit($EXIT_TEST_SKIP);
+}
+
# skip the test when running in a container
system("systemd-detect-virt", "-c", "-q");
if ($? >> 8 == 0) {
- print "Running in a container, skipping the test.\n";
- exit($EXIT_TEST_SKIP);
+ print "Running in a container, skipping the test.\n";
+ exit($EXIT_TEST_SKIP);
}
udev_setup();