mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-08 21:17:47 +03:00
test: add test cases for fstab-generator
This commit is contained in:
parent
b322e683ac
commit
8cc8a073a8
@ -2149,7 +2149,7 @@ executable(
|
||||
install : true,
|
||||
install_dir : systemgeneratordir)
|
||||
|
||||
executable(
|
||||
exe = executable(
|
||||
'systemd-fstab-generator',
|
||||
'src/fstab-generator/fstab-generator.c',
|
||||
include_directories : includes,
|
||||
@ -2158,6 +2158,13 @@ executable(
|
||||
install : true,
|
||||
install_dir : systemgeneratordir)
|
||||
|
||||
if want_tests != 'false'
|
||||
test('test-fstab-generator',
|
||||
test_fstab_generator_sh,
|
||||
# https://github.com/mesonbuild/meson/issues/2681
|
||||
args : exe.full_path())
|
||||
endif
|
||||
|
||||
if conf.get('ENABLE_ENVIRONMENT_D') == 1
|
||||
executable(
|
||||
'30-systemd-environment-d-generator',
|
||||
|
@ -12,6 +12,9 @@ if install_tests
|
||||
install_subdir('test-execute',
|
||||
exclude_files : '.gitattributes',
|
||||
install_dir : testdata_dir)
|
||||
install_subdir('test-fstab-generator',
|
||||
exclude_files : '.gitattributes',
|
||||
install_dir : testdata_dir)
|
||||
install_subdir('test-path',
|
||||
exclude_files : '.gitattributes',
|
||||
install_dir : testdata_dir)
|
||||
@ -83,6 +86,7 @@ if install_tests
|
||||
install_dir : testdata_dir)
|
||||
endif
|
||||
|
||||
test_fstab_generator_sh = find_program('test-fstab-generator.sh')
|
||||
test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh')
|
||||
test_systemd_tmpfiles_py = find_program('test-systemd-tmpfiles.py')
|
||||
hwdb_test_sh = find_program('hwdb-test.sh')
|
||||
@ -127,6 +131,10 @@ if install_tests
|
||||
install_mode : 'rwxr-xr-x',
|
||||
install_dir : testsdir)
|
||||
|
||||
install_data('test-fstab-generator.sh',
|
||||
install_mode : 'rwxr-xr-x',
|
||||
install_dir : testsdir)
|
||||
|
||||
install_data('test-network-generator-conversion.sh',
|
||||
install_mode : 'rwxr-xr-x',
|
||||
install_dir : testsdir)
|
||||
|
38
test/test-fstab-generator.sh
Executable file
38
test/test-fstab-generator.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -ex
|
||||
|
||||
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"
|
||||
|
||||
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
|
||||
|
||||
if ! diff -u "$out" "${f%.input}.expected"; then
|
||||
echo "**** Unexpected output for $f"
|
||||
exit 1
|
||||
fi
|
||||
) || exit 1
|
||||
done
|
1
test/test-fstab-generator/.gitattributes
vendored
Normal file
1
test/test-fstab-generator/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
* generated
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-01-dev-nfs.input
Normal file
1
test/test-fstab-generator/test-01-dev-nfs.input
Normal file
@ -0,0 +1 @@
|
||||
root=/dev/nfs nfsroot=192.168.0.1:/nfsroot/root1:rw
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-02-dhcp.input
Normal file
1
test/test-fstab-generator/test-02-dhcp.input
Normal file
@ -0,0 +1 @@
|
||||
root=dhcp
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-03-dhcp6.input
Normal file
1
test/test-fstab-generator/test-03-dhcp6.input
Normal file
@ -0,0 +1 @@
|
||||
root=dhcp6
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-04-nfs.input
Normal file
1
test/test-fstab-generator/test-04-nfs.input
Normal file
@ -0,0 +1 @@
|
||||
root=nfs:/nfsroot/root1:rw
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-05-nfs4.input
Normal file
1
test/test-fstab-generator/test-05-nfs4.input
Normal file
@ -0,0 +1 @@
|
||||
root=nfs4:/nfsroot/root1:rw
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-06-ipv4.input
Normal file
1
test/test-fstab-generator/test-06-ipv4.input
Normal file
@ -0,0 +1 @@
|
||||
root=192.168.0.1:/nfsroot/root1:rw
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-07-ipv6.input
Normal file
1
test/test-fstab-generator/test-07-ipv6.input
Normal file
@ -0,0 +1 @@
|
||||
root=[2001:db8::1]:/nfsroot/root1:rw
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-08-implicit-nfs.input
Normal file
1
test/test-fstab-generator/test-08-implicit-nfs.input
Normal file
@ -0,0 +1 @@
|
||||
root=/nfsroot/root1:rw
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-09-cifs.input
Normal file
1
test/test-fstab-generator/test-09-cifs.input
Normal file
@ -0,0 +1 @@
|
||||
root=cifs://username:password@192.168.0.1:/cifsroot
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-10-iscsi.input
Normal file
1
test/test-fstab-generator/test-10-iscsi.input
Normal file
@ -0,0 +1 @@
|
||||
root=iscsi:username:password@servername::::tgt
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
1
test/test-fstab-generator/test-11-live.input
Normal file
1
test/test-fstab-generator/test-11-live.input
Normal file
@ -0,0 +1 @@
|
||||
root=live:http://example.com/liveboot.img
|
@ -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,14 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
Before=initrd-root-fs.target
|
||||
Requires=systemd-fsck-root.service
|
||||
After=systemd-fsck-root.service
|
||||
After=blockdev@dev-sdx1.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/sdx1
|
||||
Where=/sysroot
|
||||
Options=ro
|
@ -0,0 +1,16 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Description=File System Check on /dev/sdx1
|
||||
Documentation=man:systemd-fsck-root.service(8)
|
||||
DefaultDependencies=no
|
||||
BindsTo=dev-sdx1.device
|
||||
Conflicts=shutdown.target
|
||||
After=initrd-root-device.target local-fs-pre.target dev-sdx1.device
|
||||
Before=shutdown.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/lib/systemd/systemd-fsck /dev/sdx1
|
||||
TimeoutSec=0
|
1
test/test-fstab-generator/test-12-dev-sdx.input
Normal file
1
test/test-fstab-generator/test-12-dev-sdx.input
Normal file
@ -0,0 +1 @@
|
||||
root=/dev/sdx1
|
@ -0,0 +1,5 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Requires=dev-disk-by\x2dlabel-Root.device
|
||||
After=dev-disk-by\x2dlabel-Root.device
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
@ -0,0 +1,14 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
Before=initrd-root-fs.target
|
||||
Requires=systemd-fsck-root.service
|
||||
After=systemd-fsck-root.service
|
||||
After=blockdev@dev-disk-by\x2dlabel-Root.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/disk/by-label/Root
|
||||
Where=/sysroot
|
||||
Options=ro
|
@ -0,0 +1,16 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Description=File System Check on /dev/disk/by-label/Root
|
||||
Documentation=man:systemd-fsck-root.service(8)
|
||||
DefaultDependencies=no
|
||||
BindsTo=dev-disk-by\x2dlabel-Root.device
|
||||
Conflicts=shutdown.target
|
||||
After=initrd-root-device.target local-fs-pre.target dev-disk-by\x2dlabel-Root.device
|
||||
Before=shutdown.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/lib/systemd/systemd-fsck /dev/disk/by-label/Root
|
||||
TimeoutSec=0
|
1
test/test-fstab-generator/test-13-label.input
Normal file
1
test/test-fstab-generator/test-13-label.input
Normal file
@ -0,0 +1 @@
|
||||
root=LABEL=Root
|
@ -0,0 +1,5 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Requires=dev-disk-by\x2duuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device
|
||||
After=dev-disk-by\x2duuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
@ -0,0 +1,14 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
Before=initrd-root-fs.target
|
||||
Requires=systemd-fsck-root.service
|
||||
After=systemd-fsck-root.service
|
||||
After=blockdev@dev-disk-by\x2duuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
Where=/sysroot
|
||||
Options=ro
|
@ -0,0 +1,16 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Description=File System Check on /dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
Documentation=man:systemd-fsck-root.service(8)
|
||||
DefaultDependencies=no
|
||||
BindsTo=dev-disk-by\x2duuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device
|
||||
Conflicts=shutdown.target
|
||||
After=initrd-root-device.target local-fs-pre.target dev-disk-by\x2duuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device
|
||||
Before=shutdown.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/lib/systemd/systemd-fsck /dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
TimeoutSec=0
|
1
test/test-fstab-generator/test-14-uuid.input
Normal file
1
test/test-fstab-generator/test-14-uuid.input
Normal file
@ -0,0 +1 @@
|
||||
root=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
@ -0,0 +1,5 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Requires=dev-disk-by\x2dpartuuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device
|
||||
After=dev-disk-by\x2dpartuuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
@ -0,0 +1,14 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
Before=initrd-root-fs.target
|
||||
Requires=systemd-fsck-root.service
|
||||
After=systemd-fsck-root.service
|
||||
After=blockdev@dev-disk-by\x2dpartuuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/disk/by-partuuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
Where=/sysroot
|
||||
Options=ro
|
@ -0,0 +1,16 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Description=File System Check on /dev/disk/by-partuuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
Documentation=man:systemd-fsck-root.service(8)
|
||||
DefaultDependencies=no
|
||||
BindsTo=dev-disk-by\x2dpartuuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device
|
||||
Conflicts=shutdown.target
|
||||
After=initrd-root-device.target local-fs-pre.target dev-disk-by\x2dpartuuid-3f5ad593\x2d4546\x2d4a94\x2da374\x2dbcfb68aa11f7.device
|
||||
Before=shutdown.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/lib/systemd/systemd-fsck /dev/disk/by-partuuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
TimeoutSec=0
|
1
test/test-fstab-generator/test-15-partuuid.input
Normal file
1
test/test-fstab-generator/test-15-partuuid.input
Normal file
@ -0,0 +1 @@
|
||||
root=PARTUUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
@ -0,0 +1 @@
|
||||
../sysroot.mount
|
@ -0,0 +1,12 @@
|
||||
# Automatically generated by systemd-fstab-generator
|
||||
|
||||
[Unit]
|
||||
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
|
||||
SourcePath=/proc/cmdline
|
||||
Before=initrd-root-fs.target
|
||||
|
||||
[Mount]
|
||||
What=rootfs
|
||||
Where=/sysroot
|
||||
Type=tmpfs
|
||||
Options=rw
|
1
test/test-fstab-generator/test-16-tmpfs.input
Normal file
1
test/test-fstab-generator/test-16-tmpfs.input
Normal file
@ -0,0 +1 @@
|
||||
root=tmpfs
|
Loading…
Reference in New Issue
Block a user