]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/units/testsuite-58.sh
tests: add spdx headers to scripts and Makefiles
[thirdparty/systemd.git] / test / units / testsuite-58.sh
CommitLineData
5a3b8640 1#!/usr/bin/env bash
7b3cec95 2# SPDX-License-Identifier: LGPL-2.1-or-later
5a3b8640 3set -eux
30f56248 4set -o pipefail
5a3b8640 5
f89a20f1
ZJS
6if ! command -v systemd-repart &>/dev/null; then
7 echo "no systemd-repart" >/skipped
8 exit 0
9fi
10
5a3b8640
LP
11export SYSTEMD_LOG_LEVEL=debug
12export PAGER=cat
13
b0f04baf 14rm -f /var/tmp/testsuite-58.img /var/tmp/testsuite-58.2.img /tmp/testsuite-58.dump
5a3b8640
LP
15mkdir -p /tmp/testsuite-58-defs/
16
17# First part: create a disk image and verify its in order
18
30f56248 19cat >/tmp/testsuite-58-defs/esp.conf <<EOF
5a3b8640
LP
20[Partition]
21Type=esp
22SizeMinBytes=10M
23Format=vfat
24EOF
25
30f56248 26cat >/tmp/testsuite-58-defs/usr.conf <<EOF
5a3b8640
LP
27[Partition]
28Type=usr
29SizeMinBytes=10M
30Format=ext4
31ReadOnly=yes
32EOF
33
30f56248 34cat >/tmp/testsuite-58-defs/root.conf <<EOF
5a3b8640
LP
35[Partition]
36Type=root
37SizeMinBytes=10M
38Format=ext4
39MakeDirectories=/usr /efi
40EOF
41
30f56248
ZJS
42systemd-repart --definitions=/tmp/testsuite-58-defs/ \
43 --empty=create \
44 --size=auto \
45 --seed=750b6cd5c4ae4012a15e7be3c29e6a47 \
46 /var/tmp/testsuite-58.img
5a3b8640 47
f2ef6d98 48sfdisk --dump /var/tmp/testsuite-58.img | tee /tmp/testsuite-58.dump
5a3b8640
LP
49
50grep -qxF '/var/tmp/testsuite-58.img1 : start= 2048, size= 20480, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=39107B09-615D-48FB-BA37-C663885FCE67, name="esp"' /tmp/testsuite-58.dump
f2ef6d98 51grep -qxF '/var/tmp/testsuite-58.img2 : start= 22528, size= 20480, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=60F33797-1D71-4DCB-AA6F-20564F036CD0, name="root-x86-64", attrs="GUID:59"' /tmp/testsuite-58.dump
5a3b8640
LP
52grep -qxF '/var/tmp/testsuite-58.img3 : start= 43008, size= 20480, type=8484680C-9521-48C6-9C11-B0720656F69E, uuid=7E3369DD-D653-4513-ADF5-B993A9F20C16, name="usr-x86-64", attrs="GUID:60"' /tmp/testsuite-58.dump
53
54# Second part, duplicate it with CopyBlocks=auto
55
30f56248 56cat >/tmp/testsuite-58-defs/esp.conf <<EOF
5a3b8640
LP
57[Partition]
58Type=esp
59CopyBlocks=auto
60EOF
61
30f56248 62cat >/tmp/testsuite-58-defs/usr.conf <<EOF
5a3b8640
LP
63[Partition]
64Type=usr
65ReadOnly=yes
66CopyBlocks=auto
67EOF
68
30f56248 69cat >/tmp/testsuite-58-defs/root.conf <<EOF
5a3b8640
LP
70[Partition]
71Type=root
72CopyBlocks=auto
73EOF
74
30f56248
ZJS
75systemd-repart --definitions=/tmp/testsuite-58-defs/ \
76 --empty=create \
77 --size=auto \
78 --seed=750b6cd5c4ae4012a15e7be3c29e6a47 \
79 --image=/var/tmp/testsuite-58.img \
80 /var/tmp/testsuite-58.2.img
5a3b8640
LP
81
82cmp /var/tmp/testsuite-58.img /var/tmp/testsuite-58.2.img
83
b0f04baf
ZJS
84rm /var/tmp/testsuite-58.img /var/tmp/testsuite-58.2.img /tmp/testsuite-58.dump
85rm -r /tmp/testsuite-58-defs/
5a3b8640
LP
86
87echo OK >/testok
88
89exit 0