From 6d67286fc3f4dd4e78aeb3b113d07e0d2dabfe60 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 16 Mar 2019 15:49:43 +0100 Subject: [PATCH 1/4] test: unify indentation --- test/test-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-functions b/test/test-functions index cff0693213..c98f58b278 100644 --- a/test/test-functions +++ b/test/test-functions @@ -509,7 +509,7 @@ check_asan_reports() { "dbus-daemon" => undef, ); } - print $2 if /\s(\S*)\[(\d+)\]:\s*SUMMARY:\s+\w+Sanitizer/ && !exists $services_to_ignore{$1}' + print $2 if /\s(\S*)\[(\d+)\]:\s*SUMMARY:\s+\w+Sanitizer/ && !exists $services_to_ignore{$1}' ) if [[ ! -z "$pids" ]]; then ret=$(($ret+1)) From c81a46b90465e087c38bbaf7fc9d91855a057a93 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 16 Mar 2019 17:46:08 +0100 Subject: [PATCH 2/4] test: introduce INTERACTIVE_DEBUG Make the interactive debugging of (particularly QEMU) machines less painful, by replacing the default vt220 TERM with linux one, and by not shutting down the machine after running the test itself. --- test/test-functions | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/test-functions b/test/test-functions index c98f58b278..9eafd769cc 100644 --- a/test/test-functions +++ b/test/test-functions @@ -25,7 +25,7 @@ fi PATH_TO_INIT=$ROOTLIBDIR/systemd BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo head tail cat mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs" -DEBUGTOOLS="df free ls stty ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find" +DEBUGTOOLS="df free ls stty ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find vi mv" STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))" STATEFILE="$STATEDIR/.testdir" @@ -655,6 +655,21 @@ install_basic_tools() { install_debug_tools() { [[ $DEBUGTOOLS ]] && dracut_install $DEBUGTOOLS + + if [[ $INTERACTIVE_DEBUG ]]; then + # Set default TERM from vt220 to linux, so at least basic key shortcuts work + local _getty_override="$initdir/etc/systemd/system/serial-getty@.service.d" + mkdir -p "$_getty_override" + echo -e "[Service]\nEnvironment=TERM=linux" > "$_getty_override/default-TERM.conf" + + cat > "$initdir/etc/motd" << EOF +To adjust the terminal size use: + export COLUMNS=xx + export LINES=yy +or + stty cols xx rows yy +EOF + fi } install_libnss() { @@ -761,7 +776,8 @@ setup_testsuite() { mkdir -p $initdir/etc/systemd/system/testsuite.target.wants ln -fs $TEST_BASE_DIR/testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service - ln -fs $TEST_BASE_DIR/end.service $initdir/etc/systemd/system/testsuite.target.wants/end.service + # Don't shutdown the machine after running the test when INTERACTIVE_DEBUG is set + [[ -z $INTERACTIVE_DEBUG ]] && ln -fs $TEST_BASE_DIR/end.service $initdir/etc/systemd/system/testsuite.target.wants/end.service # make the testsuite the default target ln -fs testsuite.target $initdir/etc/systemd/system/default.target From b43c2c01e979b8c9b5f2f70e8928a7e9d26ab11f Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 16 Mar 2019 18:01:01 +0100 Subject: [PATCH 3/4] test: allow overriding of the KVM detection using TEST_NO_KVM By default the run_qemu() function enables KVM automatically if it detects the /dev/kvm char device and if the machine is not already a KVM one. Let's add a TEST_NO_KVM env variable to suppress this detection. --- test/test-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-functions b/test/test-functions index 9eafd769cc..7179f70e46 100644 --- a/test/test-functions +++ b/test/test-functions @@ -60,7 +60,7 @@ function find_qemu_bin() { # SUSE and Red Hat call the binary qemu-kvm. Debian and Gentoo call it kvm. # Either way, only use this version if we aren't running in KVM, because # nested KVM is flaky still. - if [ `systemd-detect-virt -v` != kvm ] ; then + if [[ $(systemd-detect-virt -v) != kvm && -z $TEST_NO_KVM ]] ; then [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a kvm qemu-kvm 2>/dev/null | grep '^/' -m1) fi @@ -192,7 +192,7 @@ $KERNEL_APPEND \ fi # Let's use KVM if it is available, but let's avoid using nested KVM as that is still flaky - if [ -c /dev/kvm -a `systemd-detect-virt -v` != kvm ]; then + if [[ -c /dev/kvm && $(systemd-detect-virt -v) != kvm && -z $TEST_NO_KVM ]] ; then QEMU_OPTIONS="$QEMU_OPTIONS -machine accel=kvm -enable-kvm -cpu host" fi From 5a2114b60ef92ad3a30e0534b5d767a50dffd6a0 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 16 Mar 2019 18:32:38 +0100 Subject: [PATCH 4/4] test: improve testsuite configuration documentation --- test/README.testsuite | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/test/README.testsuite b/test/README.testsuite index 2edcf6a70a..7ff148e130 100644 --- a/test/README.testsuite +++ b/test/README.testsuite @@ -44,11 +44,38 @@ An absolute path may also be used in both cases. Configuration variables ======================= -TEST_NO_QEMU=1 can be used to disable qemu tests. +TEST_NO_QEMU=1 + Don't run tests under QEMU -TEST_NO_NSPAWN=1 can be used to disable nspawn tests. +TEST_NO_NSPAWN=1 + Don't run tests under systemd-nspawn -KERNEL_APPEND='...' can be used to add additional kernel parameters for the QEMU runs. +TEST_NO_KVM=1 + Disable QEMU KVM autodetection (may be necessary when you're trying to run the + *vanilla* QEMU and have both qemu and qemu-kvm installed) + +QEMU_MEM=512M + Configure amount of memory for QEMU VMs (defaults to 512M) + +QEMU_SMP=1 + Configure number of CPUs for QEMU VMs (defaults to 1) + +KERNEL_APPEND='...' + Append additional parameters to the kernel command line + +NSPAWN_ARGUMENTS='...' + Specify additional arguments for systemd-nspawn + +QEMU_TIMEOUT=infinity + Set a timeout for tests under QEMU (defaults to infinity) + +NSPAWN_TIMEOUT=infinity + Set a timeout for tests under systemd-nspawn (defaults to infinity) + +INTERACTIVE_DEBUG=1 + Configure the machine to be more *user-friendly* for interactive debuggung + (e.g. by setting a usable default terminal, suppressing the shutdown after + the test, etc.) The kernel and initramfs can be specified with $KERNEL_BIN and $INITRD. (Fedora's or Debian's default kernel path and initramfs are used by default)