]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-45-REPART/testsuite.sh
treewide: more portable bash shebangs
[thirdparty/systemd.git] / test / TEST-45-REPART / testsuite.sh
1 #!/usr/bin/env bash
2 set -ex
3
4 # Check if repart is installed, and if it isn't bail out early instead of failing
5 if ! test -x /usr/bin/systemd-repart ; then
6 echo OK > /testok
7 exit 0
8 fi
9
10 systemd-analyze log-level debug
11
12 truncate -s 1G /tmp/zzz
13
14 SEED=e2a40bf9-73f1-4278-9160-49c031e7aef8
15
16 systemd-repart /tmp/zzz --empty=force --dry-run=no --seed=$SEED
17
18 sfdisk -d /tmp/zzz | grep -v -e 'sector-size' -e '^$' > /tmp/empty
19
20 cmp /tmp/empty - <<EOF
21 label: gpt
22 label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
23 device: /tmp/zzz
24 unit: sectors
25 first-lba: 2048
26 last-lba: 2097118
27 EOF
28
29 mkdir /tmp/definitions
30
31 cat > /tmp/definitions/root.conf <<EOF
32 [Partition]
33 Type=root
34 EOF
35
36 ln -s root.conf /tmp/definitions/root2.conf
37
38 cat > /tmp/definitions/home.conf <<EOF
39 [Partition]
40 Type=home
41 EOF
42
43 cat > /tmp/definitions/swap.conf <<EOF
44 [Partition]
45 Type=swap
46 SizeMaxBytes=64M
47 PaddingMinBytes=92M
48 EOF
49
50 systemd-repart /tmp/zzz --dry-run=no --seed=$SEED --definitions=/tmp/definitions
51
52 sfdisk -d /tmp/zzz | grep -v -e 'sector-size' -e '^$' > /tmp/populated
53
54 cmp /tmp/populated - <<EOF
55 label: gpt
56 label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
57 device: /tmp/zzz
58 unit: sectors
59 first-lba: 2048
60 last-lba: 2097118
61 /tmp/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
62 /tmp/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
63 /tmp/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
64 /tmp/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
65 EOF
66
67 cat > /tmp/definitions/swap.conf <<EOF
68 [Partition]
69 Type=swap
70 SizeMaxBytes=64M
71 EOF
72
73 cat > /tmp/definitions/extra.conf <<EOF
74 [Partition]
75 Type=linux-generic
76 EOF
77
78 systemd-repart /tmp/zzz --dry-run=no --seed=$SEED --definitions=/tmp/definitions
79
80 sfdisk -d /tmp/zzz | grep -v -e 'sector-size' -e '^$' > /tmp/populated2
81
82 cmp /tmp/populated2 - <<EOF
83 label: gpt
84 label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
85 device: /tmp/zzz
86 unit: sectors
87 first-lba: 2048
88 last-lba: 2097118
89 /tmp/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
90 /tmp/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
91 /tmp/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
92 /tmp/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
93 /tmp/zzz5 : start= 1908696, size= 188416, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
94 EOF
95
96 truncate -s 2G /tmp/zzz
97
98 systemd-repart /tmp/zzz --dry-run=no --seed=$SEED --definitions=/tmp/definitions
99
100 sfdisk -d /tmp/zzz | grep -v -e 'sector-size' -e '^$' > /tmp/populated3
101
102 cmp /tmp/populated3 - <<EOF
103 label: gpt
104 label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
105 device: /tmp/zzz
106 unit: sectors
107 first-lba: 2048
108 last-lba: 4194270
109 /tmp/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
110 /tmp/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
111 /tmp/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
112 /tmp/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
113 /tmp/zzz5 : start= 1908696, size= 2285568, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
114 EOF
115
116 systemd-analyze log-level info
117
118 echo OK > /testok
119
120 exit 0