mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
Merge pull request #27835 from keszybz/test-58-repart-modernization
Cleanup/simplifications for TEST-58-repart
This commit is contained in:
@@ -99,7 +99,7 @@ INTERACTIVE_DEBUG=1
|
||||
the test, etc.)
|
||||
|
||||
The kernel and initrd can be specified with $KERNEL_BIN and $INITRD. (Fedora's
|
||||
or Debian's default kernel path and initrd are used by default)
|
||||
or Debian's default kernel path and initrd are used by default.)
|
||||
|
||||
A script will try to find your qemu binary. If you want to specify a different
|
||||
one with $QEMU_BIN.
|
||||
@@ -107,12 +107,12 @@ one with $QEMU_BIN.
|
||||
Debugging the qemu image
|
||||
========================
|
||||
|
||||
If you want to log in the testsuite virtual machine, you can specify additional
|
||||
kernel command line parameter with $KERNEL_APPEND and then log in as root.
|
||||
If you want to log in the testsuite virtual machine, use INTERACTIVE_DEBUG=1
|
||||
and log in as root:
|
||||
|
||||
$ sudo make -C test/TEST-01-BASIC KERNEL_APPEND="systemd.unit=multi-user.target" run
|
||||
$ sudo make -C test/TEST-01-BASIC INTERACTIVE_DEBUG=1 run
|
||||
|
||||
Root password is empty.
|
||||
The root password is empty.
|
||||
|
||||
Ubuntu CI
|
||||
=========
|
||||
|
||||
@@ -95,12 +95,13 @@ testcase_basic() {
|
||||
local defs imgs output
|
||||
local loop volume
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
# 1. create an empty image
|
||||
echo "*** 1. create an empty image ***"
|
||||
|
||||
runas testuser systemd-repart --empty=create \
|
||||
--size=1G \
|
||||
@@ -116,23 +117,23 @@ unit: sectors
|
||||
first-lba: 2048
|
||||
last-lba: 2097118"
|
||||
|
||||
# 2. Testing with root, root2, home, and swap
|
||||
echo "*** 2. Testing with root, root2, home, and swap ***"
|
||||
|
||||
runas testuser tee "$defs/root.conf" <<EOF
|
||||
tee "$defs/root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root
|
||||
EOF
|
||||
|
||||
ln -s root.conf "$defs/root2.conf"
|
||||
|
||||
runas testuser tee "$defs/home.conf" <<EOF
|
||||
tee "$defs/home.conf" <<EOF
|
||||
[Partition]
|
||||
Type=home
|
||||
Label=home-first
|
||||
Label=home-always-too-long-xxxxxxxxxxxxxx-%v
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/swap.conf" <<EOF
|
||||
tee "$defs/swap.conf" <<EOF
|
||||
[Partition]
|
||||
Type=swap
|
||||
SizeMaxBytes=64M
|
||||
@@ -191,15 +192,15 @@ $imgs/zzz2 : start= 593904, size= 591856, type=${root_guid}, uuid=${ro
|
||||
$imgs/zzz3 : start= 1185760, size= 591864, type=${root_guid}, uuid=${root_uuid2}, name=\"root-${architecture}-2\", attrs=\"GUID:59\"
|
||||
$imgs/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=78C92DB8-3D2B-4823-B0DC-792B78F66F1E, name=\"swap\""
|
||||
|
||||
# 3. Testing with root, root2, home, swap, and another partition
|
||||
echo "*** 3. Testing with root, root2, home, swap, and another partition ***"
|
||||
|
||||
runas testuser tee "$defs/swap.conf" <<EOF
|
||||
tee "$defs/swap.conf" <<EOF
|
||||
[Partition]
|
||||
Type=swap
|
||||
SizeMaxBytes=64M
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/extra.conf" <<EOF
|
||||
tee "$defs/extra.conf" <<EOF
|
||||
[Partition]
|
||||
Type=linux-generic
|
||||
Label=custom_label
|
||||
@@ -228,7 +229,7 @@ $imgs/zzz3 : start= 1185760, size= 591864, type=${root_guid}, uuid=${ro
|
||||
$imgs/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=78C92DB8-3D2B-4823-B0DC-792B78F66F1E, name=\"swap\"
|
||||
$imgs/zzz5 : start= 1908696, size= 188416, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=A0A1A2A3-A4A5-A6A7-A8A9-AAABACADAEAF, name=\"custom_label\""
|
||||
|
||||
# 4. Resizing to 2G
|
||||
echo "*** 4. Resizing to 2G ***"
|
||||
|
||||
runas testuser systemd-repart --definitions="$defs" \
|
||||
--size=2G \
|
||||
@@ -250,11 +251,11 @@ $imgs/zzz3 : start= 1185760, size= 591864, type=${root_guid}, uuid=${ro
|
||||
$imgs/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=78C92DB8-3D2B-4823-B0DC-792B78F66F1E, name=\"swap\"
|
||||
$imgs/zzz5 : start= 1908696, size= 2285568, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=A0A1A2A3-A4A5-A6A7-A8A9-AAABACADAEAF, name=\"custom_label\""
|
||||
|
||||
# 5. Testing with root, root2, home, swap, another partition, and partition copy
|
||||
echo "*** 5. Testing with root, root2, home, swap, another partition, and partition copy ***"
|
||||
|
||||
dd if=/dev/urandom of="$imgs/block-copy" bs=4096 count=10240
|
||||
|
||||
runas testuser tee "$defs/extra2.conf" <<EOF
|
||||
tee "$defs/extra2.conf" <<EOF
|
||||
[Partition]
|
||||
Type=linux-generic
|
||||
Label=block-copy
|
||||
@@ -285,9 +286,9 @@ $imgs/zzz6 : start= 4194264, size= 2097152, type=0FC63DAF-8483-4772-8E79
|
||||
|
||||
cmp --bytes=$((4096*10240)) --ignore-initial=0:$((512*4194264)) "$imgs/block-copy" "$imgs/zzz"
|
||||
|
||||
# 6. Testing Format=/Encrypt=/CopyFiles=
|
||||
echo "*** 6. Testing Format=/Encrypt=/CopyFiles= ***"
|
||||
|
||||
runas testuser tee "$defs/extra3.conf" <<EOF
|
||||
tee "$defs/extra3.conf" <<EOF
|
||||
[Partition]
|
||||
Type=linux-generic
|
||||
Label=luks-format-copy
|
||||
@@ -298,6 +299,10 @@ CopyFiles=$defs:/def
|
||||
SizeMinBytes=48M
|
||||
EOF
|
||||
|
||||
# CopyFiles will fail if we try to chown the target file to root.
|
||||
# Make the files owned by the user so that the invocation below works.
|
||||
chown testuser -R "$defs"
|
||||
|
||||
runas testuser systemd-repart --definitions="$defs" \
|
||||
--size=auto \
|
||||
--dry-run=no \
|
||||
@@ -344,26 +349,27 @@ $imgs/zzz7 : start= 6291416, size= 98304, type=0FC63DAF-8483-4772-8E79
|
||||
testcase_dropin() {
|
||||
local defs imgs output
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
runas testuser tee "$defs/root.conf" <<EOF
|
||||
tee "$defs/root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=swap
|
||||
SizeMaxBytes=64M
|
||||
UUID=837c3d67-21b3-478e-be82-7e7f83bf96d3
|
||||
EOF
|
||||
|
||||
runas testuser mkdir -p "$defs/root.conf.d"
|
||||
runas testuser tee "$defs/root.conf.d/override1.conf" <<EOF
|
||||
mkdir -p "$defs/root.conf.d"
|
||||
tee "$defs/root.conf.d/override1.conf" <<EOF
|
||||
[Partition]
|
||||
Label=label1
|
||||
SizeMaxBytes=32M
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/root.conf.d/override2.conf" <<EOF
|
||||
tee "$defs/root.conf.d/override2.conf" <<EOF
|
||||
[Partition]
|
||||
Label=label2
|
||||
EOF
|
||||
@@ -402,14 +408,14 @@ EOF
|
||||
testcase_multiple_definitions() {
|
||||
local defs imgs output
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
runas testuser mkdir -p "$defs/1"
|
||||
|
||||
runas testuser tee "$defs/1/root1.conf" <<EOF
|
||||
mkdir -p "$defs/1"
|
||||
tee "$defs/1/root1.conf" <<EOF
|
||||
[Partition]
|
||||
Type=swap
|
||||
SizeMaxBytes=32M
|
||||
@@ -417,9 +423,8 @@ UUID=7b93d1f2-595d-4ce3-b0b9-837fbd9e63b0
|
||||
Label=label1
|
||||
EOF
|
||||
|
||||
runas testuser mkdir -p "$defs/2"
|
||||
|
||||
runas testuser tee "$defs/2/root2.conf" <<EOF
|
||||
mkdir -p "$defs/2"
|
||||
tee "$defs/2/root2.conf" <<EOF
|
||||
[Partition]
|
||||
Type=swap
|
||||
SizeMaxBytes=32M
|
||||
@@ -473,21 +478,22 @@ EOF
|
||||
testcase_copy_blocks() {
|
||||
local defs imgs output
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
# First, create a disk image and verify its in order
|
||||
echo "*** First, create a disk image and verify its in order ***"
|
||||
|
||||
runas testuser tee "$defs/esp.conf" <<EOF
|
||||
tee "$defs/esp.conf" <<EOF
|
||||
[Partition]
|
||||
Type=esp
|
||||
SizeMinBytes=10M
|
||||
Format=vfat
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/usr.conf" <<EOF
|
||||
tee "$defs/usr.conf" <<EOF
|
||||
[Partition]
|
||||
Type=usr-${architecture}
|
||||
SizeMinBytes=10M
|
||||
@@ -495,7 +501,7 @@ Format=ext4
|
||||
ReadOnly=yes
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/root.conf" <<EOF
|
||||
tee "$defs/root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root-${architecture}
|
||||
SizeMinBytes=10M
|
||||
@@ -520,22 +526,22 @@ EOF
|
||||
return
|
||||
fi
|
||||
|
||||
# Then, create another image with CopyBlocks=auto
|
||||
echo "*** Second, create another image with CopyBlocks=auto ***"
|
||||
|
||||
runas testuser tee "$defs/esp.conf" <<EOF
|
||||
tee "$defs/esp.conf" <<EOF
|
||||
[Partition]
|
||||
Type=esp
|
||||
CopyBlocks=auto
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/usr.conf" <<EOF
|
||||
tee "$defs/usr.conf" <<EOF
|
||||
[Partition]
|
||||
Type=usr-${architecture}
|
||||
ReadOnly=yes
|
||||
CopyBlocks=auto
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/root.conf" <<EOF
|
||||
tee "$defs/root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root-${architecture}
|
||||
CopyBlocks=auto
|
||||
@@ -555,14 +561,15 @@ EOF
|
||||
testcase_unaligned_partition() {
|
||||
local defs imgs output
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
# Operate on an image with unaligned partition.
|
||||
echo "*** Operate on an image with unaligned partition ***"
|
||||
|
||||
runas testuser tee "$defs/root.conf" <<EOF
|
||||
tee "$defs/root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root-${architecture}
|
||||
EOF
|
||||
@@ -590,14 +597,15 @@ EOF
|
||||
testcase_issue_21817() {
|
||||
local defs imgs output
|
||||
|
||||
# testcase for #21817
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
runas testuser tee "$defs/test.conf" <<EOF
|
||||
echo "*** testcase for #21817 ***"
|
||||
|
||||
tee "$defs/test.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root
|
||||
EOF
|
||||
@@ -626,21 +634,22 @@ EOF
|
||||
testcase_issue_24553() {
|
||||
local defs imgs output
|
||||
|
||||
# testcase for #24553
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
runas testuser tee "$defs/root.conf" <<EOF
|
||||
echo "*** testcase for #24553 ***"
|
||||
|
||||
tee "$defs/root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root
|
||||
SizeMinBytes=10G
|
||||
SizeMaxBytes=120G
|
||||
EOF
|
||||
|
||||
runas testuser tee "$imgs/partscript" <<EOF
|
||||
tee "$imgs/partscript" <<EOF
|
||||
label: gpt
|
||||
label-id: C9FFE979-A415-C449-B729-78C7AA664B10
|
||||
unit: sectors
|
||||
@@ -650,7 +659,7 @@ start=40, size=524288, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=F2E89C8A-
|
||||
start=524328, size=14848000, type=${root_guid}, uuid=${root_uuid}, name="root-${architecture}"
|
||||
EOF
|
||||
|
||||
# 1. Operate on a small image compared with SizeMinBytes=.
|
||||
echo "*** 1. Operate on a small image compared with SizeMinBytes= ***"
|
||||
runas testuser truncate -s 8g "$imgs/zzz"
|
||||
sfdisk "$imgs/zzz" <"$imgs/partscript"
|
||||
|
||||
@@ -663,7 +672,7 @@ EOF
|
||||
output=$(sfdisk --dump "$imgs/zzz")
|
||||
assert_in "$imgs/zzz2 : start= 524328, size= 14848000, type=${root_guid}, uuid=${root_uuid}, name=\"root-${architecture}\"" "$output"
|
||||
|
||||
# 2. Operate on an larger image compared with SizeMinBytes=.
|
||||
echo "*** 2. Operate on an larger image compared with SizeMinBytes= ***"
|
||||
rm -f "$imgs/zzz"
|
||||
runas testuser truncate -s 12g "$imgs/zzz"
|
||||
sfdisk "$imgs/zzz" <"$imgs/partscript"
|
||||
@@ -677,8 +686,8 @@ EOF
|
||||
output=$(sfdisk --dump "$imgs/zzz")
|
||||
assert_in "$imgs/zzz2 : start= 524328, size= 24641456, type=${root_guid}, uuid=${root_uuid}, name=\"root-${architecture}\"" "$output"
|
||||
|
||||
# 3. Multiple partitions with Priority= (small disk)
|
||||
runas testuser tee "$defs/root.conf" <<EOF
|
||||
echo "*** 3. Multiple partitions with Priority= (small disk) ***"
|
||||
tee "$defs/root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root
|
||||
SizeMinBytes=10G
|
||||
@@ -686,7 +695,7 @@ SizeMaxBytes=120G
|
||||
Priority=100
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/usr.conf" <<EOF
|
||||
tee "$defs/usr.conf" <<EOF
|
||||
[Partition]
|
||||
Type=usr
|
||||
SizeMinBytes=10M
|
||||
@@ -707,7 +716,7 @@ EOF
|
||||
assert_in "$imgs/zzz2 : start= 524328, size= 14848000, type=${root_guid}, uuid=${root_uuid}, name=\"root-${architecture}\"" "$output"
|
||||
assert_in "$imgs/zzz3 : start= 15372328, size= 1404848, type=${usr_guid}, uuid=${usr_uuid}, name=\"usr-${architecture}\", attrs=\"GUID:59\"" "$output"
|
||||
|
||||
# 4. Multiple partitions with Priority= (large disk)
|
||||
echo "*** 4. Multiple partitions with Priority= (large disk) ***"
|
||||
rm -f "$imgs/zzz"
|
||||
runas testuser truncate -s 12g "$imgs/zzz"
|
||||
sfdisk "$imgs/zzz" <"$imgs/partscript"
|
||||
@@ -726,14 +735,15 @@ EOF
|
||||
testcase_zero_uuid() {
|
||||
local defs imgs output
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
# Test image with zero UUID.
|
||||
echo "*** Test image with zero UUID ***"
|
||||
|
||||
runas testuser tee "$defs/root.conf" <<EOF
|
||||
tee "$defs/root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root-${architecture}
|
||||
UUID=null
|
||||
@@ -754,12 +764,15 @@ EOF
|
||||
testcase_verity() {
|
||||
local defs imgs output
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
runas testuser tee "$defs/verity-data.conf" <<EOF
|
||||
echo "*** dm-verity ***"
|
||||
|
||||
tee "$defs/verity-data.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root-${architecture}
|
||||
CopyFiles=${defs}
|
||||
@@ -768,7 +781,7 @@ VerityMatchKey=root
|
||||
Minimize=guess
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/verity-hash.conf" <<EOF
|
||||
tee "$defs/verity-hash.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root-${architecture}-verity
|
||||
Verity=hash
|
||||
@@ -776,7 +789,7 @@ VerityMatchKey=root
|
||||
Minimize=yes
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/verity-sig.conf" <<EOF
|
||||
tee "$defs/verity-sig.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root-${architecture}-verity-sig
|
||||
Verity=signature
|
||||
@@ -784,7 +797,7 @@ VerityMatchKey=root
|
||||
EOF
|
||||
|
||||
# Unfortunately OpenSSL insists on reading some config file, hence provide one with mostly placeholder contents
|
||||
runas testuser tee >"$defs/verity.openssl.cnf" <<EOF
|
||||
tee >"$defs/verity.openssl.cnf" <<EOF
|
||||
[ req ]
|
||||
prompt = no
|
||||
distinguished_name = req_distinguished_name
|
||||
@@ -799,17 +812,22 @@ CN = Common Name
|
||||
emailAddress = test@email.com
|
||||
EOF
|
||||
|
||||
runas testuser openssl req -config "$defs/verity.openssl.cnf" \
|
||||
-new -x509 \
|
||||
-newkey rsa:1024 \
|
||||
-keyout "$defs/verity.key" \
|
||||
-out "$defs/verity.crt" \
|
||||
-days 365 \
|
||||
-nodes
|
||||
openssl req \
|
||||
-config "$defs/verity.openssl.cnf" \
|
||||
-new -x509 \
|
||||
-newkey rsa:1024 \
|
||||
-keyout "$defs/verity.key" \
|
||||
-out "$defs/verity.crt" \
|
||||
-days 365 \
|
||||
-nodes
|
||||
|
||||
mkdir -p /run/verity.d
|
||||
ln -s "$defs/verity.crt" /run/verity.d/ok.crt
|
||||
|
||||
# CopyFiles will fail if we try to chown the target file to root.
|
||||
# Make the files owned by the user so that the invocation below works.
|
||||
chown testuser -R "$defs"
|
||||
|
||||
output=$(runas testuser systemd-repart --definitions="$defs" \
|
||||
--seed="$seed" \
|
||||
--dry-run=no \
|
||||
@@ -820,9 +838,9 @@ EOF
|
||||
--certificate="$defs/verity.crt" \
|
||||
"$imgs/verity")
|
||||
|
||||
drh=$(jq -r ".[] | select(.type == \"root-${architecture}\") | .roothash" <<< "$output")
|
||||
hrh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity\") | .roothash" <<< "$output")
|
||||
srh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity-sig\") | .roothash" <<< "$output")
|
||||
drh=$(jq -r ".[] | select(.type == \"root-${architecture}\") | .roothash" <<<"$output")
|
||||
hrh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity\") | .roothash" <<<"$output")
|
||||
srh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity-sig\") | .roothash" <<<"$output")
|
||||
|
||||
assert_eq "$drh" "$hrh"
|
||||
assert_eq "$hrh" "$srh"
|
||||
@@ -843,27 +861,30 @@ EOF
|
||||
testcase_exclude_files() {
|
||||
local defs imgs root output
|
||||
|
||||
defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
root="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
root="$(runas testuser mktemp --directory "/var/tmp/test-repart.root.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs' '$root'" RETURN
|
||||
chmod a+rx "$defs"
|
||||
|
||||
runas testuser touch "$root/abc"
|
||||
runas testuser mkdir "$root/usr"
|
||||
runas testuser touch "$root/usr/def"
|
||||
runas testuser touch "$root/usr/qed"
|
||||
runas testuser mkdir "$root/tmp"
|
||||
runas testuser touch "$root/tmp/prs"
|
||||
runas testuser mkdir "$root/proc"
|
||||
runas testuser touch "$root/proc/prs"
|
||||
runas testuser mkdir "$root/zzz"
|
||||
runas testuser mkdir "$root/zzz/usr"
|
||||
runas testuser touch "$root/zzz/usr/prs"
|
||||
runas testuser mkdir "$root/zzz/proc"
|
||||
runas testuser touch "$root/zzz/proc/prs"
|
||||
echo "*** file exclusion ***"
|
||||
|
||||
runas testuser tee "$defs/00-root.conf" <<EOF
|
||||
touch "$root/abc"
|
||||
mkdir "$root/usr"
|
||||
touch "$root/usr/def"
|
||||
touch "$root/usr/qed"
|
||||
mkdir "$root/tmp"
|
||||
touch "$root/tmp/prs"
|
||||
mkdir "$root/proc"
|
||||
touch "$root/proc/prs"
|
||||
mkdir "$root/zzz"
|
||||
mkdir "$root/zzz/usr"
|
||||
touch "$root/zzz/usr/prs"
|
||||
mkdir "$root/zzz/proc"
|
||||
touch "$root/zzz/proc/prs"
|
||||
|
||||
tee "$defs/00-root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root-${architecture}
|
||||
CopyFiles=/
|
||||
@@ -872,13 +893,17 @@ CopyFiles=/:/oiu
|
||||
ExcludeFilesTarget=/oiu/usr
|
||||
EOF
|
||||
|
||||
runas testuser tee "$defs/10-usr.conf" <<EOF
|
||||
tee "$defs/10-usr.conf" <<EOF
|
||||
[Partition]
|
||||
Type=usr-${architecture}
|
||||
CopyFiles=/usr:/
|
||||
ExcludeFiles=/usr/qed
|
||||
EOF
|
||||
|
||||
# CopyFiles will fail if we try to chown the target file to root.
|
||||
# Make the files owned by the user so that the invocation below works.
|
||||
chown testuser -R "$root"
|
||||
|
||||
output=$(runas testuser systemd-repart --definitions="$defs" \
|
||||
--seed="$seed" \
|
||||
--dry-run=no \
|
||||
@@ -940,8 +965,10 @@ testcase_minimize() {
|
||||
return
|
||||
fi
|
||||
|
||||
defs="$(mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
echo "*** minimization ***"
|
||||
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
|
||||
@@ -994,8 +1021,10 @@ test_sector() {
|
||||
return
|
||||
fi
|
||||
|
||||
defs="$(mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||
imgs="$(mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||
echo "*** sector sizes ***"
|
||||
|
||||
defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")"
|
||||
imgs="$(mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||
|
||||
|
||||
Reference in New Issue
Block a user