]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - test/test-functions
tests: introduce UNIFIED_CGROUP_HIERARCHY (#3419)
[thirdparty/systemd.git] / test / test-functions
index 8bbcddab590cf6dc9b4c216723fc81c24b362d68..5f95a8129efb048f79bfb6edac7e4b42e1b91364 100644 (file)
@@ -8,7 +8,9 @@ LOOKS_LIKE_DEBIAN=$(source /etc/os-release && [[ "$ID" = "debian" || "$ID_LIKE"
 KERNEL_VER=${KERNEL_VER-$(uname -r)}
 KERNEL_MODS="/lib/modules/$KERNEL_VER/"
 QEMU_TIMEOUT="${QEMU_TIMEOUT:-infinity}"
+NSPAWN_TIMEOUT="${NSPAWN_TIMEOUT:-infinity}"
 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
@@ -63,13 +65,13 @@ run_qemu() {
     find_qemu_bin || return 1
 
     KERNEL_APPEND="root=/dev/sda1 \
-systemd.log_level=debug \
 raid=noautodetect \
 loglevel=2 \
 init=$ROOTLIBDIR/systemd \
 ro \
 console=ttyS0 \
 selinux=0 \
+systemd.unified_cgroup_hierarchy=$UNIFIED_CGROUP_HIERARCHY \
 $KERNEL_APPEND \
 "
 
@@ -78,6 +80,7 @@ $KERNEL_APPEND \
 -m 512M \
 -nographic \
 -kernel $KERNEL_BIN \
+-drive format=raw,cache=unsafe,file=${TESTDIR}/rootdisk.img \
 "
 
     if [[ "$INITRD" && "$SKIP_INITRD" != "yes" ]]; then
@@ -92,12 +95,19 @@ $KERNEL_APPEND \
         QEMU_BIN="timeout --foreground $QEMU_TIMEOUT $QEMU_BIN"
     fi
     ( set -x
-      $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND" $TESTDIR/rootdisk.img ) || return 1
+      $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND" ) || return 1
 }
 
 run_nspawn() {
+    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
+
+    _nspawn_cmd="env UNIFIED_CGROUP_HIERARCHY=$UNIFIED_CGROUP_HIERARCHY $_nspawn_cmd"
+
     set -x
-    ../../systemd-nspawn --register=no --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND
+    $_nspawn_cmd
 }
 
 setup_basic_environment() {
@@ -239,6 +249,9 @@ install_systemd() {
     # we strip binaries since debug symbols increase binaries size a lot
     # and it could fill the available space
     strip_binaries
+
+    # enable debug logging in PID1
+    echo LogLevel=debug >> $initdir/etc/systemd/system.conf
 }
 
 install_missing_libraries() {
@@ -410,6 +423,9 @@ install_pam() {
 
     [[ "$LOOKS_LIKE_DEBIAN" ]] &&
         cp /etc/pam.d/systemd-user $initdir/etc/pam.d/
+
+    # set empty root password for easy debugging
+    sed -i 's/^root:x:/root::/' $initdir/etc/passwd
 }
 
 install_keymaps() {