summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile175
-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.py123
-rw-r--r--test/test-functions49
14 files changed, 273 insertions, 131 deletions
diff --git a/test/Makefile b/test/Makefile
index 48c8debc3c..d2b873ac33 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -253,7 +253,7 @@ test_device_nodes_SOURCES = \
src/test/test-device-nodes.c
test_device_nodes_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_engine_SOURCES = \
src/test/test-engine.c
@@ -304,7 +304,7 @@ test_dns_domain_SOURCES = \
test_dns_domain_LDADD = \
libsystemd-network.la \
- libshared.la
+ libsystemd-shared.la
ifneq ($(ENABLE_EFI),)
tests += \
@@ -314,7 +314,7 @@ test_boot_timestamps_SOURCES = \
src/test/test-boot-timestamps.c
test_boot_timestamps_LDADD = \
- libshared.la
+ libsystemd-shared.la
endif # ENABLE_EFI
test_unit_name_SOURCES = \
@@ -343,29 +343,35 @@ test_utf8_SOURCES = \
src/test/test-utf8.c
test_utf8_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_capability_SOURCES = \
src/test/test-capability.c
+test_capability_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(CAP_CFLAGS)
+
test_capability_LDADD = \
- libshared.la
+ libsystemd-shared.la \
+ $(CAP_LIBS)
test_async_SOURCES = \
src/test/test-async.c
test_async_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_locale_util_SOURCES = \
src/test/test-locale-util.c
test_locale_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_copy_SOURCES = \
src/test/test-copy.c
+# Link statically to ensure file is large
test_copy_LDADD = \
libshared.la
@@ -373,187 +379,192 @@ test_sigbus_SOURCES = \
src/test/test-sigbus.c
test_sigbus_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_condition_SOURCES = \
src/test/test-condition.c
test_condition_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_fdset_SOURCES = \
src/test/test-fdset.c
test_fdset_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_fstab_util_SOURCES = \
src/test/test-fstab-util.c
test_fstab_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_ratelimit_SOURCES = \
src/test/test-ratelimit.c
test_ratelimit_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_util_SOURCES = \
src/test/test-util.c
test_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_hexdecoct_SOURCES = \
src/test/test-hexdecoct.c
test_hexdecoct_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_alloc_util_SOURCES = \
src/test/test-alloc-util.c
test_alloc_util_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_xattr_util_SOURCES = \
src/test/test-xattr-util.c
test_xattr_util_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_io_util_SOURCES = \
src/test/test-io-util.c
test_io_util_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_glob_util_SOURCES = \
src/test/test-glob-util.c
test_glob_util_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_fs_util_SOURCES = \
src/test/test-fs-util.c
test_fs_util_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_proc_cmdline_SOURCES = \
src/test/test-proc-cmdline.c
test_proc_cmdline_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_fd_util_SOURCES = \
src/test/test-fd-util.c
test_fd_util_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_web_util_SOURCES = \
src/test/test-web-util.c
test_web_util_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_cpu_set_util_SOURCES = \
src/test/test-cpu-set-util.c
test_cpu_set_util_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_stat_util_SOURCES = \
src/test/test-stat-util.c
test_stat_util_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_escape_SOURCES = \
src/test/test-escape.c
test_escape_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_string_util_SOURCES = \
src/test/test-string-util.c
test_string_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_extract_word_SOURCES = \
src/test/test-extract-word.c
test_extract_word_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_parse_util_SOURCES = \
src/test/test-parse-util.c
test_parse_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_user_util_SOURCES = \
src/test/test-user-util.c
test_user_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_hostname_util_SOURCES = \
src/test/test-hostname-util.c
test_hostname_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_process_util_SOURCES = \
src/test/test-process-util.c
test_process_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_terminal_util_SOURCES = \
src/test/test-terminal-util.c
test_terminal_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_path_lookup_SOURCES = \
src/test/test-path-lookup.c
test_path_lookup_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_uid_range_SOURCES = \
src/test/test-uid-range.c
test_uid_range_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_cap_list_SOURCES = \
src/test/test-cap-list.c
+test_cap_list_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(CAP_CFLAGS)
+
test_cap_list_LDADD = \
- libshared.la
+ libsystemd-shared.la \
+ $(CAP_LIBS)
test_socket_util_SOURCES = \
src/test/test-socket-util.c
test_socket_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_barrier_SOURCES = \
src/test/test-barrier.c
test_barrier_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_tmpfiles_SOURCES = \
src/test/test-tmpfiles.c
test_tmpfiles_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_namespace_SOURCES = \
src/test/test-namespace.c
@@ -562,19 +573,19 @@ test_verbs_SOURCES = \
src/test/test-verbs.c
test_verbs_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_install_root_SOURCES = \
src/test/test-install-root.c
test_install_root_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_acl_util_SOURCES = \
src/test/test-acl-util.c
test_acl_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_namespace_LDADD = \
libcore.la
@@ -583,31 +594,31 @@ test_rlimit_util_SOURCES = \
src/test/test-rlimit-util.c
test_rlimit_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_ask_password_api_SOURCES = \
src/test/test-ask-password-api.c
test_ask_password_api_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_signal_util_SOURCES = \
src/test/test-signal-util.c
test_signal_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_selinux_SOURCES = \
src/test/test-selinux.c
test_selinux_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_sizeof_SOURCES = \
src/test/test-sizeof.c
test_sizeof_LDADD = \
- libshared.la
+ libsystemd-shared.la
BUILT_SOURCES += \
src/test/test-hashmap-ordered.c
@@ -629,34 +640,34 @@ test_hashmap_SOURCES = \
src/test/test-hashmap-plain.c
test_hashmap_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_set_SOURCES = \
src/test/test-set.c
test_set_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_bitmap_SOURCES = \
src/test/test-bitmap.c
test_bitmap_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_xml_SOURCES = \
src/test/test-xml.c
test_xml_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_list_SOURCES = \
src/test/test-list.c
test_list_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_unaligned_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_unaligned_SOURCES = \
src/test/test-unaligned.c
@@ -684,49 +695,49 @@ test_prioq_SOURCES = \
src/test/test-prioq.c
test_prioq_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_fileio_SOURCES = \
src/test/test-fileio.c
test_fileio_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_time_SOURCES = \
src/test/test-time.c
test_time_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_clock_SOURCES = \
src/test/test-clock.c
test_clock_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_architecture_SOURCES = \
src/test/test-architecture.c
test_architecture_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_log_SOURCES = \
src/test/test-log.c
test_log_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_ipcrm_SOURCES = \
src/test/test-ipcrm.c
test_ipcrm_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_btrfs_SOURCES = \
src/test/test-btrfs.c
test_btrfs_LDADD = \
- libshared.la
+ libsystemd-shared.la
ifneq ($(HAVE_LIBIPTC),)
test_firewall_util_SOURCES = \
@@ -738,7 +749,7 @@ test_firewall_util_CFLAGS = \
test_firewall_util_LDADD = \
libfirewall.la \
- libshared.la \
+ libsystemd-shared.la \
$(LIBIPTC_LIBS)
endif # HAVE_LIBIPTC
@@ -750,20 +761,20 @@ test_netlink_manual_CFLAGS = \
$(KMOD_CFLAGS)
test_netlink_manual_LDADD = \
- libshared.la \
+ libsystemd-shared.la \
$(KMOD_LIBS)
test_ellipsize_SOURCES = \
src/test/test-ellipsize.c
test_ellipsize_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_date_SOURCES = \
src/test/test-date.c
test_date_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_sleep_SOURCES = \
src/test/test-sleep.c
@@ -775,31 +786,31 @@ test_replace_var_SOURCES = \
src/test/test-replace-var.c
test_replace_var_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_calendarspec_SOURCES = \
src/test/test-calendarspec.c
test_calendarspec_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_strip_tab_ansi_SOURCES = \
src/test/test-strip-tab-ansi.c
test_strip_tab_ansi_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_daemon_SOURCES = \
src/test/test-daemon.c
test_daemon_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_cgroup_SOURCES = \
src/test/test-cgroup.c
test_cgroup_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_cgroup_mask_SOURCES = \
src/test/test-cgroup-mask.c
@@ -819,31 +830,31 @@ test_cgroup_util_SOURCES = \
src/test/test-cgroup-util.c
test_cgroup_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_env_util_SOURCES = \
src/test/test-env-util.c
test_env_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_strbuf_SOURCES = \
src/test/test-strbuf.c
test_strbuf_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_strv_SOURCES = \
src/test/test-strv.c
test_strv_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_path_util_SOURCES = \
src/test/test-path-util.c
test_path_util_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_path_SOURCES = \
src/test/test-path.c
@@ -869,25 +880,25 @@ test_siphash24_SOURCES = \
src/test/test-siphash24.c
test_siphash24_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_strxcpyx_SOURCES = \
src/test/test-strxcpyx.c
test_strxcpyx_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_install_SOURCES = \
src/test/test-install.c
test_install_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_watchdog_SOURCES = \
src/test/test-watchdog.c
test_watchdog_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_sched_prio_SOURCES = \
src/test/test-sched-prio.c
@@ -907,24 +918,24 @@ test_conf_files_SOURCES = \
src/test/test-conf-files.c
test_conf_files_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_conf_parser_SOURCES = \
src/test/test-conf-parser.c
test_conf_parser_LDADD = \
- libshared.la
+ libsystemd-shared.la
test_af_list_SOURCES = \
src/test/test-af-list.c
test_af_list_LDADD = \
- libbasic.la
+ libsystemd-shared.la
test_arphrd_list_SOURCES = \
src/test/test-arphrd-list.c
test_arphrd_list_LDADD = \
- libbasic.la
+ libsystemd-shared.la
include $(topsrcdir)/build-aux/Makefile.tail.mk
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 d4de5adf1a..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):
@@ -370,6 +393,74 @@ exec $(systemctl cat systemd-networkd.service | sed -n '/^ExecStart=/ { s/^.*=//
def test_coldplug_dhcp_ip6(self):
pass
+ def test_search_domains(self):
+
+ # we don't use this interface for this test
+ self.if_router = None
+
+ with open('/run/systemd/network/test.netdev', 'w') as f:
+ f.write('''[NetDev]
+Name=dummy0
+Kind=dummy
+MACAddress=12:34:56:78:9a:bc''')
+ with open('/run/systemd/network/test.network', 'w') as f:
+ f.write('''[Match]
+Name=dummy0
+[Network]
+Address=192.168.42.100
+DNS=192.168.42.1
+Domains= one two three four five six seven eight nine ten''')
+ self.addCleanup(os.remove, '/run/systemd/network/test.netdev')
+ self.addCleanup(os.remove, '/run/systemd/network/test.network')
+
+ subprocess.check_call(['systemctl', 'start', 'systemd-networkd'])
+
+ 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):
+
+ # we don't use this interface for this test
+ self.if_router = None
+
+ name_prefix = 'a' * 60
+
+ with open('/run/systemd/network/test.netdev', 'w') as f:
+ f.write('''[NetDev]
+Name=dummy0
+Kind=dummy
+MACAddress=12:34:56:78:9a:bc''')
+ with open('/run/systemd/network/test.network', 'w') as f:
+ f.write('''[Match]
+Name=dummy0
+[Network]
+Address=192.168.42.100
+DNS=192.168.42.1
+Domains=''')
+ for i in range(5):
+ f.write('%s%i ' % (name_prefix, i))
+
+ self.addCleanup(os.remove, '/run/systemd/network/test.netdev')
+ self.addCleanup(os.remove, '/run/systemd/network/test.network')
+
+ subprocess.check_call(['systemctl', 'start', 'systemd-networkd'])
+
+ 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__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
diff --git a/test/test-functions b/test/test-functions
index e2e07a833c..567a000b8d 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -9,7 +9,9 @@ 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}"
if ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then
echo "WARNING! Cannot determine rootlibdir from pkg-config, assuming /usr/lib/systemd" >&2
@@ -45,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
@@ -70,6 +74,7 @@ init=$ROOTLIBDIR/systemd \
ro \
console=ttyS0 \
selinux=0 \
+systemd.unified_cgroup_hierarchy=$UNIFIED_CGROUP_HIERARCHY \
$KERNEL_APPEND \
"
@@ -92,17 +97,38 @@ $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"
fi
- set -x
- $_nspawn_cmd
+
+ _nspawn_cmd="env UNIFIED_CGROUP_HIERARCHY=$UNIFIED_CGROUP_HIERARCHY $_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() {
@@ -249,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
}
@@ -285,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
}
@@ -1261,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