]> git.proxmox.com Git - grub2.git/blame - tests/partmap_test.in
added new partmaps test
[grub2.git] / tests / partmap_test.in
CommitLineData
56672f4a 1#! /bin/sh -e
2
3parted=/sbin/parted
4grubshell=@builddir@/grub-shell
5
6create_disk_image () {
7 name=$1
8 size=$2
9 qemu-img create ${name} ${size} >/dev/null
10}
11
12check_output () {
13 outfile=$1
14 shift
15
16 for disk in $@; do
17 if ! grep "($disk)" ${outfile} >/dev/null
18 then
19 echo "($disk): disk/partiton not found"
20 exit 1
21 fi
22 done
23}
24
25list_parts () {
26 mod=$1;
27 shift;
28 imgfile=$1
29 shift
30 outfile=$1
31 shift
32
33 echo ls | ${grubshell} --boot=cd --qemu-opts="-hda ${imgfile}" \
34 --modules=$mod | tr -d "\n\r" > ${outfile}
35 cat ${outfile}
36 echo
37}
38
39imgfile=`mktemp`
40outfile=`mktemp`
41
42#
43# MSDOS partition types
44#
45
46echo "Checking MSDOS partition types..."
47
48# 0 primary
49create_disk_image ${imgfile} 64M
50${parted} -a none -s ${imgfile} mklabel msdos
51list_parts part_msdos ${imgfile} ${outfile}
52check_output ${outfile} hd0
53
54# 1 primary
55create_disk_image ${imgfile} 64M
56${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M
57list_parts part_msdos ${imgfile} ${outfile}
58check_output ${outfile} hd0 hd0,msdos1
59
60# 2 primary
61create_disk_image ${imgfile} 128M
62${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M
63list_parts part_msdos ${imgfile} ${outfile}
64check_output ${outfile} hd0 hd0,msdos1 hd0,msdos2
65
66# 3 primary
67create_disk_image ${imgfile} 128M
68${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart primary 20M 30M
69list_parts part_msdos ${imgfile} ${outfile}
70check_output ${outfile} hd0 hd0,msdos1 hd0,msdos2 hd0,msdos3
71
72# 4 primary
73create_disk_image ${imgfile} 128M
74${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M
75list_parts part_msdos ${imgfile} ${outfile}
76check_output ${outfile} hd0 hd0,msdos1 hd0,msdos2 hd0,msdos3 hd0,msdos4
77
78# 1 primary, 1 extended
79create_disk_image ${imgfile} 128M
80${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100%
81list_parts part_msdos ${imgfile} ${outfile}
82check_output ${outfile} hd0 hd0,msdos1
83
84# 1 primary, 1 extended, 1 logical
85create_disk_image ${imgfile} 128M
86${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M
87list_parts part_msdos ${imgfile} ${outfile}
88check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5
89
90# 1 primary, 1 extended, 2 logical
91create_disk_image ${imgfile} 128M
92${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M mkpart logical 30M 40M
93list_parts part_msdos ${imgfile} ${outfile}
94check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 hd0,msdos6
95
96# 1 primary, 1 extended, 3 logical
97create_disk_image ${imgfile} 128M
98${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M mkpart logical 30M 40M mkpart logical 40M 50M
99list_parts part_msdos ${imgfile} ${outfile}
100check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 hd0,msdos6 hd0,msdos7
101
102# 1 primary, 1 extended, 4 logical
103create_disk_image ${imgfile} 128M
104${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M mkpart logical 30M 40M mkpart logical 40M 50M mkpart logical 50M 60M
105list_parts part_msdos ${imgfile} ${outfile}
106check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 hd0,msdos6 hd0,msdos7 hd0,msdos8
107
108
109#
110# GPT partition types
111#
112
113echo "Checking GPT partition types..."
114
115# 0 parts
116create_disk_image ${imgfile} 64M
117${parted} -a none -s ${imgfile} mklabel gpt
118list_parts part_gpt ${imgfile} ${outfile}
119check_output ${outfile} hd0
120
121# 1 parts
122create_disk_image ${imgfile} 64M
123${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M
124list_parts part_gpt ${imgfile} ${outfile}
125check_output ${outfile} hd0 hd0,gpt1
126
127# 2 parts
128create_disk_image ${imgfile} 128M
129${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M
130list_parts part_gpt ${imgfile} ${outfile}
131check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2
132
133# 3 parts
134create_disk_image ${imgfile} 128M
135${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M
136list_parts part_gpt ${imgfile} ${outfile}
137check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3
138
139# 4 parts
140create_disk_image ${imgfile} 128M
141${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 4 20M 30M mkpart 5 30M 40M
142list_parts part_gpt ${imgfile} ${outfile}
143check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 hd0,gpt4
144
145# 5 parts
146create_disk_image ${imgfile} 128M
147${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M mkpart 4 30M 40M mkpart 5 40M 50M
148list_parts part_gpt ${imgfile} ${outfile}
149check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 hd0,gpt4 hd0,gpt5
150
151# 6 parts
152create_disk_image ${imgfile} 128M
153${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M mkpart 4 30M 40M mkpart 5 40M 50M mkpart 6 50M 60M
154list_parts part_gpt ${imgfile} ${outfile}
155check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 hd0,gpt4 hd0,gpt5 hd0,gpt6
156
157
158#
159# SUN partition types
160#
161# It seems partition #3 is reserved for whole disk by parted.
162#
163
164echo "Checking SUN partition types..."
165
166# 0 parts
167create_disk_image ${imgfile} 64M
168${parted} -a none -s ${imgfile} mklabel sun
169list_parts part_sun ${imgfile} ${outfile}
170check_output ${outfile} hd0
171
172# 1 parts
173create_disk_image ${imgfile} 64M
174${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M
175list_parts part_sun ${imgfile} ${outfile}
176check_output ${outfile} hd0 hd0,sun1
177
178# 2 parts
179create_disk_image ${imgfile} 128M
180${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M
181list_parts part_sun ${imgfile} ${outfile}
182check_output ${outfile} hd0 hd0,sun1 hd0,sun2
183
184# 3 parts
185create_disk_image ${imgfile} 128M
186${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M
187list_parts part_sun ${imgfile} ${outfile}
188check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4
189
190# 4 parts
191create_disk_image ${imgfile} 128M
192${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M
193list_parts part_sun ${imgfile} ${outfile}
194check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 hd0,sun5
195
196# 5 parts
197create_disk_image ${imgfile} 128M
198${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M mkpart 40M 50M
199list_parts part_sun ${imgfile} ${outfile}
200check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 hd0,sun5 hd0,sun6
201
202# 6 parts
203create_disk_image ${imgfile} 128M
204${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M mkpart 40M 50M mkpart 50M 60M
205list_parts part_sun ${imgfile} ${outfile}
206check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 hd0,sun5 hd0,sun6 hd0,sun7
207
208
209#
210# Apple partition types
211#
212# Partition table itself is part of some partition, so there is always
213# a partition by default. But I don't understand why GRUB displays
214# two partitions by default :-(
215#
216
217echo "Checking APPLE partition types..."
218
219# 0 parts
220create_disk_image ${imgfile} 64M
221${parted} -a none -s ${imgfile} mklabel mac
222list_parts part_apple ${imgfile} ${outfile}
223check_output ${outfile} hd0 hd0,apple1 hd0,apple2
224
225# 1 parts
226create_disk_image ${imgfile} 64M
227${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M
228list_parts part_apple ${imgfile} ${outfile}
229check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple3
230
231# 2 parts
232create_disk_image ${imgfile} 128M
233${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M
234list_parts part_apple ${imgfile} ${outfile}
235check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple3 hd0,apple4
236
237# 3 parts
238create_disk_image ${imgfile} 128M
239${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M
240list_parts part_apple ${imgfile} ${outfile}
241check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5
242
243# 4 parts
244create_disk_image ${imgfile} 128M
245${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M
246list_parts part_apple ${imgfile} ${outfile}
247check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 hd0,apple6
248
249# 5 parts
250create_disk_image ${imgfile} 128M
251${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M mkpart e 40M 50M
252list_parts part_apple ${imgfile} ${outfile}
253check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 hd0,apple6 hd0,apple7
254
255# 6 parts
256create_disk_image ${imgfile} 128M
257${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M mkpart e 40M 50M mkpart f 50M 60M
258list_parts part_apple ${imgfile} ${outfile}
259check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 hd0,apple6 hd0,apple7 hd0,apple8