]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/units/testsuite-58.sh
ae177ac4286d728f9649b40cdbaf63100dbbfa57
[thirdparty/systemd.git] / test / units / testsuite-58.sh
1 #!/usr/bin/env bash
2 set -eux
3 set -o pipefail
4
5 if ! command -v systemd-repart &>/dev/null; then
6 echo "no systemd-repart" >/skipped
7 exit 0
8 fi
9
10 export SYSTEMD_LOG_LEVEL=debug
11 export PAGER=cat
12
13 rm -f /var/tmp/testsuite-58.img /var/tmp/testsuite-58.2.img /tmp/testsuite-58.dump
14 mkdir -p /tmp/testsuite-58-defs/
15
16 # First part: create a disk image and verify its in order
17
18 cat >/tmp/testsuite-58-defs/esp.conf <<EOF
19 [Partition]
20 Type=esp
21 SizeMinBytes=10M
22 Format=vfat
23 EOF
24
25 cat >/tmp/testsuite-58-defs/usr.conf <<EOF
26 [Partition]
27 Type=usr
28 SizeMinBytes=10M
29 Format=ext4
30 ReadOnly=yes
31 EOF
32
33 cat >/tmp/testsuite-58-defs/root.conf <<EOF
34 [Partition]
35 Type=root
36 SizeMinBytes=10M
37 Format=ext4
38 MakeDirectories=/usr /efi
39 EOF
40
41 systemd-repart --definitions=/tmp/testsuite-58-defs/ \
42 --empty=create \
43 --size=auto \
44 --seed=750b6cd5c4ae4012a15e7be3c29e6a47 \
45 /var/tmp/testsuite-58.img
46
47 sfdisk --dump /var/tmp/testsuite-58.img | tee /tmp/testsuite-58.dump
48
49 grep -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
50 grep -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
51 grep -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
52
53 # Second part, duplicate it with CopyBlocks=auto
54
55 cat >/tmp/testsuite-58-defs/esp.conf <<EOF
56 [Partition]
57 Type=esp
58 CopyBlocks=auto
59 EOF
60
61 cat >/tmp/testsuite-58-defs/usr.conf <<EOF
62 [Partition]
63 Type=usr
64 ReadOnly=yes
65 CopyBlocks=auto
66 EOF
67
68 cat >/tmp/testsuite-58-defs/root.conf <<EOF
69 [Partition]
70 Type=root
71 CopyBlocks=auto
72 EOF
73
74 systemd-repart --definitions=/tmp/testsuite-58-defs/ \
75 --empty=create \
76 --size=auto \
77 --seed=750b6cd5c4ae4012a15e7be3c29e6a47 \
78 --image=/var/tmp/testsuite-58.img \
79 /var/tmp/testsuite-58.2.img
80
81 cmp /var/tmp/testsuite-58.img /var/tmp/testsuite-58.2.img
82
83 rm /var/tmp/testsuite-58.img /var/tmp/testsuite-58.2.img /tmp/testsuite-58.dump
84 rm -r /tmp/testsuite-58-defs/
85
86 echo OK >/testok
87
88 exit 0