mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
test: add test cases for defining mount and swap units from kernel cmdline
This commit is contained in:
@@ -28,11 +28,14 @@ for f in "$src"/test-*.input; do
|
||||
trap "rm -rf '$out'" EXIT INT QUIT PIPE
|
||||
|
||||
exp="${f%.input}.expected"
|
||||
if [[ "${f##*/}" =~ swap ]] && systemd-detect-virt --container >/dev/null; then
|
||||
exp="${exp}.container"
|
||||
fi
|
||||
|
||||
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"
|
||||
SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out"
|
||||
fi
|
||||
|
||||
# The option x-systemd.growfs creates symlink to system's systemd-growfs@.service in .mount.wants directory.
|
||||
@@ -55,6 +58,21 @@ for f in "$src"/test-*.input; do
|
||||
done
|
||||
fi
|
||||
|
||||
# .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
|
||||
k="${i//\\/}"
|
||||
if [[ "$i" != "$k" ]]; then
|
||||
if [[ -f "$i" ]]; then
|
||||
mv "$i" "$k"
|
||||
elif [[ -L "$i" ]]; then
|
||||
dest=$(readlink "$i")
|
||||
rm "$i"
|
||||
ln -s "${dest//\\/}" "$k"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# 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 "$exp" -printf '%P\n' | sort); then
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
Before=local-fs.target
|
||||
After=blockdev@dev-sdx3.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/sdx3
|
||||
Where=/hoge/without_fstype
|
||||
@@ -0,0 +1,11 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
Before=local-fs.target
|
||||
After=blockdev@dev-sdx2.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/sdx2
|
||||
Where=/hoge/without_options
|
||||
@@ -0,0 +1,12 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
Before=remote-fs.target
|
||||
|
||||
[Mount]
|
||||
What=//foobar
|
||||
Where=/hoge/with space
|
||||
Type=cifs
|
||||
Options=rw
|
||||
@@ -0,0 +1,5 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Requires=dev-sdx1.device
|
||||
After=dev-sdx1.device
|
||||
@@ -0,0 +1 @@
|
||||
../sysroot.mount
|
||||
@@ -0,0 +1 @@
|
||||
../sysroot.mount
|
||||
@@ -0,0 +1 @@
|
||||
../hoge-without_fstype.mount
|
||||
@@ -0,0 +1 @@
|
||||
../hoge-without_options.mount
|
||||
@@ -0,0 +1 @@
|
||||
../hoge-withx20space.mount
|
||||
@@ -0,0 +1,11 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
Before=initrd-root-fs.target
|
||||
After=blockdev@dev-sdx1.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/sdx1
|
||||
Where=/sysroot
|
||||
@@ -0,0 +1,5 @@
|
||||
systemd.mount-extra=/dev/sdx1:/sysroot:auto:defaults
|
||||
systemd.mount-extra=/dev/sdx2:/hoge/without_options:auto
|
||||
systemd.mount-extra=/dev/sdx3:/hoge/without_fstype
|
||||
systemd.mount-extra=/dev/sdx4
|
||||
systemd.mount-extra=//foo\ufffebar:/hoge/with\x20space:cifs:rw,seclabel
|
||||
@@ -0,0 +1,9 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
After=blockdev@dev-sdy1.target
|
||||
|
||||
[Swap]
|
||||
What=/dev/sdy1
|
||||
@@ -0,0 +1,10 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
After=blockdev@dev-sdy2.target
|
||||
|
||||
[Swap]
|
||||
What=/dev/sdy2
|
||||
Options=x-systemd.makefs
|
||||
@@ -0,0 +1 @@
|
||||
../systemd-mkswap@dev-sdy2.service
|
||||
@@ -0,0 +1,10 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
After=blockdev@dev-sdy3.target
|
||||
|
||||
[Swap]
|
||||
What=/dev/sdy3
|
||||
Options=x-systemd.makefs
|
||||
@@ -0,0 +1 @@
|
||||
../systemd-mkswap@dev-sdy3.service
|
||||
@@ -0,0 +1,9 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
After=blockdev@dev-sdy4.target
|
||||
|
||||
[Swap]
|
||||
What=/dev/sdy4
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user