]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: use systemd inside client test rootfs if available
authorBenjamin Drung <benjamin.drung@canonical.com>
Mon, 26 Jan 2026 15:17:45 +0000 (16:17 +0100)
committerLaszlo <laszlo.gombos@gmail.com>
Mon, 26 Jan 2026 15:41:56 +0000 (10:41 -0500)
Some tests (for example test 10 on ubuntu:devel) show this warning:

```
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to system scope bus via local transport: Host is down
```

This is caused by calling `systemctl --failed` in the client test rootfs
where systemd is not available/used.

Use systemd inside the client test rootfs if available to allow querying
the failed services from the initrd.

test/modules.d/70test-root/module-setup.sh

index ac249dba355be9a2475a6324e20acbecde33daa7..6d894ce80fcec02f2cd6412efb3131b693c15253 100755 (executable)
@@ -13,6 +13,11 @@ depends() {
         deps+=" debug"
     fi
 
+    # Use systemd if available
+    if [[ -e "$systemdutildir"/systemd ]]; then
+        deps+=" systemd"
+    fi
+
     echo "$deps"
     return 0
 }
@@ -28,6 +33,7 @@ install() {
         $SYSTEMCTL -q --root "$initdir" add-wants testsuite.target "testsuite.service"
         ln_r "${systemdsystemunitdir}/testsuite.target" "${systemdsystemunitdir}/default.target"
         inst_script "$moddir/test-init.sh" "/sbin/test-init"
+        ln -sfn ../lib/systemd/systemd "$initdir/sbin/init"
     else
         inst_script "$moddir/test-init.sh" "/sbin/init"
     fi