test-fstab-generator: fix inverted /mnt symlink guard
The test-18-options.fstab.input scenario was guarded by
"$(readlink /mnt)" != "/mnt", which is true on any normal system
since readlink prints nothing for a plain directory. This meant the
scenario was always skipped, and its fixtures were never actually
compared against generator output.
Fix the guard to check whether /mnt is a symlink directly, and repair
the pre-existing fixtures that had drifted while the scenario was
dead:
- mnt-wantedby-automount.mount had a stale Where= value and was
missing the escaping the generator emits for the hyphen in
/mnt/wantedby-automount.
- mnt-requires.mount had Requires=/After= in the wrong order.
Also extend the backslash-stripping workaround loop (used because the
.deb packager dislikes files named with a backslash) to cover
.automount units in addition to .mount/.swap, and fix an ordering bug
where -f was checked before -L, which could leave a dangling symlink
when both a unit and its drop-in symlink needed stripping.
This commit is contained in:
@@ -67,15 +67,15 @@ test_one() (
|
||||
|
||||
# .deb packager seems to dislike files named with backslash. So, as a workaround, we store files
|
||||
# without backslash in .expected.
|
||||
for i in "$out"/**/*\\*.{mount,swap}; do
|
||||
for i in "$out"/**/*\\*.{mount,swap,automount}; do
|
||||
k="${i//\\/}"
|
||||
if [[ "$i" != "$k" ]]; then
|
||||
if [[ -f "$i" ]]; then
|
||||
mv "$i" "$k"
|
||||
elif [[ -L "$i" ]]; then
|
||||
if [[ -L "$i" ]]; then
|
||||
dest=$(readlink "$i")
|
||||
rm "$i"
|
||||
ln -s "${dest//\\/}" "$k"
|
||||
elif [[ -f "$i" ]]; then
|
||||
mv "$i" "$k"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -130,8 +130,7 @@ test_one() (
|
||||
for f in "$src"/test-*.input; do
|
||||
# If /mnt is a symlink, then the expected output from this
|
||||
# test scenario will not match the actual output
|
||||
if test "$f" = "$src/test-18-options.fstab.input" -a "$(readlink /mnt)" != "/mnt"
|
||||
then
|
||||
if [[ "$f" == "$src/test-18-options.fstab.input" && -L /mnt ]]; then
|
||||
echo "Skip $f because /mnt is a symlink"
|
||||
continue
|
||||
fi
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
../mnt-wantedby-automount.automount
|
||||
+1
@@ -0,0 +1 @@
|
||||
../mnt-wantedbyx2dautomount.automount
|
||||
@@ -3,8 +3,8 @@
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/etc/fstab
|
||||
After=foo.service
|
||||
Requires=foo.service
|
||||
After=foo.service
|
||||
Before=local-fs.target
|
||||
After=blockdev@dev-sdx5.target
|
||||
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ After=blockdev@dev-sdx17.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/sdx17
|
||||
Where=/mnt/wantedby
|
||||
Where=/mnt/wantedby-automount
|
||||
Options=x-systemd.wanted-by=foo.service,x-systemd.automount
|
||||
-1
@@ -1 +0,0 @@
|
||||
../mnt-wantedby-automount.automount
|
||||
+1
@@ -0,0 +1 @@
|
||||
../mnt-wantedbyx2dautomount.automount
|
||||
@@ -3,8 +3,8 @@
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/etc/fstab
|
||||
After=foo.service
|
||||
Requires=foo.service
|
||||
After=foo.service
|
||||
Before=local-fs.target
|
||||
After=blockdev@dev-sdx5.target
|
||||
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ After=blockdev@dev-sdx17.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/sdx17
|
||||
Where=/mnt/wantedby
|
||||
Where=/mnt/wantedby-automount
|
||||
Options=x-systemd.wanted-by=foo.service,x-systemd.automount
|
||||
Reference in New Issue
Block a user