summaryrefslogtreecommitdiffstats
path: root/test/test-fstab-generator.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:35:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:35:18 +0000
commitb750101eb236130cf056c675997decbac904cc49 (patch)
treea5df1a06754bdd014cb975c051c83b01c9a97532 /test/test-fstab-generator.sh
parentInitial commit. (diff)
downloadsystemd-b750101eb236130cf056c675997decbac904cc49.tar.xz
systemd-b750101eb236130cf056c675997decbac904cc49.zip
Adding upstream version 252.22.upstream/252.22
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtest/test-fstab-generator.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh
new file mode 100755
index 0000000..5a166ab
--- /dev/null
+++ b/test/test-fstab-generator.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -e
+
+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"
+
+# fsck(8) is located in /usr/sbin on Debian
+PATH=$PATH:/usr/sbin
+
+# systemd-pcrfs@.service could be enabled or not, depending on the host state
+# of the host system. Override the measurement to avoid the issue.
+export SYSTEMD_FORCE_MEASURE=0
+
+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
+
+ # 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
+ echo "**** Unexpected output for $f"
+ exit 1
+ fi
+ ) || exit 1
+done