mirror of
https://github.com/systemd/systemd
synced 2024-10-14 12:04:49 +00:00
test: convert TEST-45 to a normal meson test
On my laptop, it now takes 0.23 s. We don't need the overhead of creating an image and spawning a machine to mangle a file in /tmp.
This commit is contained in:
parent
07d16f438a
commit
e29e4d5742
|
@ -2506,7 +2506,7 @@ if conf.get('ENABLE_BINFMT') == 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if conf.get('ENABLE_REPART') == 1
|
if conf.get('ENABLE_REPART') == 1
|
||||||
executable('systemd-repart',
|
exe = executable('systemd-repart',
|
||||||
systemd_repart_sources,
|
systemd_repart_sources,
|
||||||
include_directories : includes,
|
include_directories : includes,
|
||||||
link_with : [libshared],
|
link_with : [libshared],
|
||||||
|
@ -2518,6 +2518,12 @@ if conf.get('ENABLE_REPART') == 1
|
||||||
install_rpath : rootlibexecdir,
|
install_rpath : rootlibexecdir,
|
||||||
install : true,
|
install : true,
|
||||||
install_dir : rootbindir)
|
install_dir : rootbindir)
|
||||||
|
|
||||||
|
if want_tests != 'false'
|
||||||
|
test('test-repart',
|
||||||
|
test_repart_sh,
|
||||||
|
args : exe.full_path())
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if conf.get('ENABLE_VCONSOLE') == 1
|
if conf.get('ENABLE_VCONSOLE') == 1
|
||||||
|
|
|
@ -3,3 +3,5 @@
|
||||||
systemd_repart_sources = files('''
|
systemd_repart_sources = files('''
|
||||||
repart.c
|
repart.c
|
||||||
'''.split())
|
'''.split())
|
||||||
|
|
||||||
|
test_repart_sh = find_program('test-repart.sh')
|
||||||
|
|
111
src/partition/test-repart.sh
Executable file
111
src/partition/test-repart.sh
Executable file
|
@ -0,0 +1,111 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
repart=$1
|
||||||
|
test -x $repart
|
||||||
|
|
||||||
|
D=$(mktemp --directory)
|
||||||
|
trap "rm -rf '$D'" EXIT INT QUIT PIPE
|
||||||
|
mkdir -p $D/definitions
|
||||||
|
|
||||||
|
truncate -s 1G $D/zzz
|
||||||
|
|
||||||
|
SEED=e2a40bf9-73f1-4278-9160-49c031e7aef8
|
||||||
|
|
||||||
|
$repart $D/zzz --empty=force --dry-run=no --seed=$SEED
|
||||||
|
|
||||||
|
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' > $D/empty
|
||||||
|
|
||||||
|
cmp $D/empty - <<EOF
|
||||||
|
label: gpt
|
||||||
|
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||||
|
device: $D/zzz
|
||||||
|
unit: sectors
|
||||||
|
first-lba: 2048
|
||||||
|
last-lba: 2097118
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat >$D/definitions/root.conf <<EOF
|
||||||
|
[Partition]
|
||||||
|
Type=root
|
||||||
|
EOF
|
||||||
|
|
||||||
|
ln -s root.conf $D/definitions/root2.conf
|
||||||
|
|
||||||
|
cat >$D/definitions/home.conf <<EOF
|
||||||
|
[Partition]
|
||||||
|
Type=home
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > $D/definitions/swap.conf <<EOF
|
||||||
|
[Partition]
|
||||||
|
Type=swap
|
||||||
|
SizeMaxBytes=64M
|
||||||
|
PaddingMinBytes=92M
|
||||||
|
EOF
|
||||||
|
|
||||||
|
$repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||||
|
|
||||||
|
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated
|
||||||
|
|
||||||
|
cmp $D/populated - <<EOF
|
||||||
|
label: gpt
|
||||||
|
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||||
|
device: $D/zzz
|
||||||
|
unit: sectors
|
||||||
|
first-lba: 2048
|
||||||
|
last-lba: 2097118
|
||||||
|
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
||||||
|
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
||||||
|
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
||||||
|
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat >$D/definitions/swap.conf <<EOF
|
||||||
|
[Partition]
|
||||||
|
Type=swap
|
||||||
|
SizeMaxBytes=64M
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat >$D/definitions/extra.conf <<EOF
|
||||||
|
[Partition]
|
||||||
|
Type=linux-generic
|
||||||
|
EOF
|
||||||
|
|
||||||
|
$repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||||
|
|
||||||
|
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated2
|
||||||
|
|
||||||
|
cmp $D/populated2 - <<EOF
|
||||||
|
label: gpt
|
||||||
|
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||||
|
device: $D/zzz
|
||||||
|
unit: sectors
|
||||||
|
first-lba: 2048
|
||||||
|
last-lba: 2097118
|
||||||
|
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
||||||
|
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
||||||
|
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
||||||
|
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
||||||
|
$D/zzz5 : start= 1908696, size= 188416, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
truncate -s 2G $D/zzz
|
||||||
|
|
||||||
|
$repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||||
|
|
||||||
|
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated3
|
||||||
|
|
||||||
|
cmp $D/populated3 - <<EOF
|
||||||
|
label: gpt
|
||||||
|
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||||
|
device: $D/zzz
|
||||||
|
unit: sectors
|
||||||
|
first-lba: 2048
|
||||||
|
last-lba: 4194270
|
||||||
|
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
||||||
|
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
||||||
|
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
||||||
|
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
||||||
|
$D/zzz5 : start= 1908696, size= 2285568, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
|
||||||
|
EOF
|
|
@ -1 +0,0 @@
|
||||||
../TEST-01-BASIC/Makefile
|
|
|
@ -1,37 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
TEST_DESCRIPTION="test systemd-repart"
|
|
||||||
|
|
||||||
. $TEST_BASE_DIR/test-functions
|
|
||||||
|
|
||||||
test_setup() {
|
|
||||||
create_empty_image_rootdir
|
|
||||||
|
|
||||||
(
|
|
||||||
LOG_LEVEL=5
|
|
||||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
|
||||||
|
|
||||||
setup_basic_environment
|
|
||||||
|
|
||||||
mask_supporting_services
|
|
||||||
dracut_install truncate sfdisk grep
|
|
||||||
|
|
||||||
# setup the testsuite service
|
|
||||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Testsuite service
|
|
||||||
Before=getty-pre.target
|
|
||||||
Wants=getty-pre.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/testsuite.sh
|
|
||||||
Type=oneshot
|
|
||||||
EOF
|
|
||||||
cp testsuite.sh $initdir/
|
|
||||||
|
|
||||||
setup_testsuite
|
|
||||||
)
|
|
||||||
setup_nspawn_root
|
|
||||||
}
|
|
||||||
|
|
||||||
do_test "$@"
|
|
|
@ -1,120 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
# Check if repart is installed, and if it isn't bail out early instead of failing
|
|
||||||
if ! test -x /usr/bin/systemd-repart ; then
|
|
||||||
echo OK > /testok
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
systemd-analyze log-level debug
|
|
||||||
|
|
||||||
truncate -s 1G /tmp/zzz
|
|
||||||
|
|
||||||
SEED=e2a40bf9-73f1-4278-9160-49c031e7aef8
|
|
||||||
|
|
||||||
systemd-repart /tmp/zzz --empty=force --dry-run=no --seed=$SEED
|
|
||||||
|
|
||||||
sfdisk -d /tmp/zzz | grep -v -e 'sector-size' -e '^$' > /tmp/empty
|
|
||||||
|
|
||||||
cmp /tmp/empty - <<EOF
|
|
||||||
label: gpt
|
|
||||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
|
||||||
device: /tmp/zzz
|
|
||||||
unit: sectors
|
|
||||||
first-lba: 2048
|
|
||||||
last-lba: 2097118
|
|
||||||
EOF
|
|
||||||
|
|
||||||
mkdir /tmp/definitions
|
|
||||||
|
|
||||||
cat > /tmp/definitions/root.conf <<EOF
|
|
||||||
[Partition]
|
|
||||||
Type=root
|
|
||||||
EOF
|
|
||||||
|
|
||||||
ln -s root.conf /tmp/definitions/root2.conf
|
|
||||||
|
|
||||||
cat > /tmp/definitions/home.conf <<EOF
|
|
||||||
[Partition]
|
|
||||||
Type=home
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > /tmp/definitions/swap.conf <<EOF
|
|
||||||
[Partition]
|
|
||||||
Type=swap
|
|
||||||
SizeMaxBytes=64M
|
|
||||||
PaddingMinBytes=92M
|
|
||||||
EOF
|
|
||||||
|
|
||||||
systemd-repart /tmp/zzz --dry-run=no --seed=$SEED --definitions=/tmp/definitions
|
|
||||||
|
|
||||||
sfdisk -d /tmp/zzz | grep -v -e 'sector-size' -e '^$' > /tmp/populated
|
|
||||||
|
|
||||||
cmp /tmp/populated - <<EOF
|
|
||||||
label: gpt
|
|
||||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
|
||||||
device: /tmp/zzz
|
|
||||||
unit: sectors
|
|
||||||
first-lba: 2048
|
|
||||||
last-lba: 2097118
|
|
||||||
/tmp/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
|
||||||
/tmp/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
|
||||||
/tmp/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
|
||||||
/tmp/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > /tmp/definitions/swap.conf <<EOF
|
|
||||||
[Partition]
|
|
||||||
Type=swap
|
|
||||||
SizeMaxBytes=64M
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > /tmp/definitions/extra.conf <<EOF
|
|
||||||
[Partition]
|
|
||||||
Type=linux-generic
|
|
||||||
EOF
|
|
||||||
|
|
||||||
systemd-repart /tmp/zzz --dry-run=no --seed=$SEED --definitions=/tmp/definitions
|
|
||||||
|
|
||||||
sfdisk -d /tmp/zzz | grep -v -e 'sector-size' -e '^$' > /tmp/populated2
|
|
||||||
|
|
||||||
cmp /tmp/populated2 - <<EOF
|
|
||||||
label: gpt
|
|
||||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
|
||||||
device: /tmp/zzz
|
|
||||||
unit: sectors
|
|
||||||
first-lba: 2048
|
|
||||||
last-lba: 2097118
|
|
||||||
/tmp/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
|
||||||
/tmp/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
|
||||||
/tmp/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
|
||||||
/tmp/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
|
||||||
/tmp/zzz5 : start= 1908696, size= 188416, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
truncate -s 2G /tmp/zzz
|
|
||||||
|
|
||||||
systemd-repart /tmp/zzz --dry-run=no --seed=$SEED --definitions=/tmp/definitions
|
|
||||||
|
|
||||||
sfdisk -d /tmp/zzz | grep -v -e 'sector-size' -e '^$' > /tmp/populated3
|
|
||||||
|
|
||||||
cmp /tmp/populated3 - <<EOF
|
|
||||||
label: gpt
|
|
||||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
|
||||||
device: /tmp/zzz
|
|
||||||
unit: sectors
|
|
||||||
first-lba: 2048
|
|
||||||
last-lba: 4194270
|
|
||||||
/tmp/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
|
||||||
/tmp/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
|
||||||
/tmp/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
|
||||||
/tmp/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
|
||||||
/tmp/zzz5 : start= 1908696, size= 2285568, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
systemd-analyze log-level info
|
|
||||||
|
|
||||||
echo OK > /testok
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -61,6 +61,7 @@ BASICTOOLS=(
|
||||||
false
|
false
|
||||||
getent
|
getent
|
||||||
getfacl
|
getfacl
|
||||||
|
grep
|
||||||
gunzip
|
gunzip
|
||||||
gzip
|
gzip
|
||||||
head
|
head
|
||||||
|
@ -85,6 +86,7 @@ BASICTOOLS=(
|
||||||
seq
|
seq
|
||||||
setfont
|
setfont
|
||||||
setsid
|
setsid
|
||||||
|
sfdisk
|
||||||
sh
|
sh
|
||||||
sleep
|
sleep
|
||||||
socat
|
socat
|
||||||
|
@ -99,6 +101,7 @@ BASICTOOLS=(
|
||||||
touch
|
touch
|
||||||
tr
|
tr
|
||||||
true
|
true
|
||||||
|
truncate
|
||||||
umount
|
umount
|
||||||
uname
|
uname
|
||||||
unshare
|
unshare
|
||||||
|
|
Loading…
Reference in a new issue