diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-05-11 20:54:13 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-05-24 01:23:22 +0200 |
commit | 70bf9f62b9f3c46bb7d111342889bfac7c9ca45e (patch) | |
tree | fcabf07f42eab65bffa35fb69994ee5462431ade /test/test-fstab-generator.sh | |
parent | elf2efi: Do not emit an empty relocation section (diff) | |
download | systemd-70bf9f62b9f3c46bb7d111342889bfac7c9ca45e.tar.xz systemd-70bf9f62b9f3c46bb7d111342889bfac7c9ca45e.zip |
test-fstab-generator: also check file contents
Since e683878c0f03a4ffa123e37b27933fbf7e144901, only filenames are
checked. Let's check contents of generated unit files.
Diffstat (limited to 'test/test-fstab-generator.sh')
-rwxr-xr-x | test/test-fstab-generator.sh | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh index c86914a107..c844d0dae1 100755 --- a/test/test-fstab-generator.sh +++ b/test/test-fstab-generator.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash # SPDX-License-Identifier: LGPL-2.1-or-later set -e +shopt -s nullglob +shopt -s globstar if [[ -n "$1" ]]; then generator=$1 @@ -25,23 +27,62 @@ for f in "$src"/test-*.input; do # shellcheck disable=SC2064 trap "rm -rf '$out'" EXIT INT QUIT PIPE - # shellcheck disable=SC2046 - if [[ "$f" == *.fstab.input ]]; then + exp="${f%.input}.expected" + + if [[ "${f##*/}" =~ \.fstab\.input ]]; then SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$f" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" else SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out" fi - 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 + # For split-usr system + for i in "$out"/systemd-*.service; do + sed -i -e 's:ExecStart=/lib/systemd/:ExecStart=/usr/lib/systemd/:' "$i" + done + + if [[ "${f##*/}" =~ \.fstab\.input ]]; then + for i in "$out"/*.{automount,mount,swap}; do + sed -i -e 's:SourcePath=.*$:SourcePath=/etc/fstab:' "$i" + done fi - # We store empty files rather than symlinks, so that they don't get pruned when packaged up, so compare + # We store empty files rather than dead 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 + if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "$exp" -printf '%P\n' | sort); then + echo "**** Unexpected output for $f" + exit 1 + fi + + # Check the main units. + if ! diff -u "$out" "$exp"; then echo "**** Unexpected output for $f" exit 1 fi + + # Also check drop-ins. + for i in "$out"/*; do + [[ -d "$i" ]] || continue + + dir="${i##*/}" + + for j in "$i"/*; do + fname="${j##*/}" + expf="$exp/$dir/$fname" + + if [[ -L "$j" && ! -e "$j" ]]; then + # For dead symlink, we store an empty file. + if [[ ! -e "$expf" || -n "$(cat "$expf")" ]]; then + echo "**** Unexpected symlink $j created by $f" + exit 1 + fi + continue + fi + + if ! diff -u "$j" "$expf"; then + echo "**** Unexpected output in $j for $f" + exit 1 + fi + done + done ) || exit 1 done |