2022-01-06 14:12:27 +03:00
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
2022-01-09 17:00:25 +03:00
set -e
2022-01-06 14:12:27 +03:00
if [ [ -n " $1 " ] ] ; then
generator = $1
elif [ [ -x /usr/lib/systemd/system-generators/systemd-fstab-generator ] ] ; then
generator = /usr/lib/systemd/system-generators/systemd-fstab-generator
elif [ [ -x /lib/systemd/system-generators/systemd-fstab-generator ] ] ; then
generator = /lib/systemd/system-generators/systemd-fstab-generator
else
exit 1
fi
src = " $( dirname " $0 " ) /testdata/test-fstab-generator "
test: fstab-generator: adjust PATH for fsck
fsck(8) is located in /usr/sib/ on Debian sid:
stdout:
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-01-dev-nfs.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-02-dhcp.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-03-dhcp6.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-04-nfs.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-05-nfs4.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-06-ipv4.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-07-ipv6.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-08-implicit-nfs.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-09-cifs.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-10-iscsi.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-11-live.input
*** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-12-dev-sdx.input
--- /dev/fd/63 2022-11-04 15:39:13.131532174 +0100
+++ /dev/fd/62 2022-11-04 15:39:13.131532174 +0100
@@ -6,3 +6,4 @@
initrd-usr-fs.target.requires
initrd-usr-fs.target.requires/sysroot.mount
sysroot.mount
+systemd-fsck-root.service
**** Unexpected output for /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-12-dev-sdx.input
stderr:
Skipping root directory handling, as root on NFS was requested.
Skipping root directory handling, as root on NFS was requested.
Skipping root directory handling, as root on NFS was requested.
Skipping root directory handling, as root on NFS was requested.
Skipping root directory handling, as root on NFS was requested.
Skipping root directory handling, as root on NFS was requested.
Skipping root directory handling, as root on NFS was requested.
Skipping root directory handling, as root on NFS was requested.
Skipping root directory handling, as root on CIFS was requested.
Skipping root directory handling, as root on iSCSI was requested.
Skipping root directory handling, as root on live image was requested.
Found entry what=/dev/sdx1 where=/sysroot type=n/a opts=ro
Checking was requested for /dev/sdx1, but the fsck command does not exist.
2022-11-04 17:48:50 +03:00
# fsck(8) is located in /usr/sbin on Debian
PATH = $PATH :/usr/sbin
2022-01-06 14:12:27 +03:00
for f in " $src " /test-*.input; do
echo " *** Running $f "
(
out = $( mktemp --tmpdir --directory "test-fstab-generator.XXXXXXXXXX" )
# shellcheck disable=SC2064
trap " rm -rf ' $out ' " EXIT INT QUIT PIPE
# shellcheck disable=SC2046
SYSTEMD_LOG_LEVEL = debug SYSTEMD_IN_INITRD = yes SYSTEMD_PROC_CMDLINE = " fstab=no $( cat " $f " ) " $generator " $out " " $out " " $out "
if [ [ -f " $out " /systemd-fsck-root.service ] ] ; then
# For split-usr system
sed -i -e 's:ExecStart=/lib/systemd/systemd-fsck:ExecStart=/usr/lib/systemd/systemd-fsck:' " $out " /systemd-fsck-root.service
fi
2022-01-09 17:00:25 +03:00
# We store empty files rather than symlinks, so that they don't get pruned when packaged up, so compare
# the list of filenames rather than their content
if ! diff -u <( find " $out " -printf '%P\n' | sort) <( find " ${ f %.input } .expected " -printf '%P\n' | sort) ; then
2022-01-06 14:12:27 +03:00
echo " **** Unexpected output for $f "
exit 1
fi
) || exit 1
done