OSDN Git Service

tests: update tests for new disk flags output
[android-x86/external-parted.git] / tests / t5000-tags.sh
1 #!/bin/sh
2 # test bios_grub flag in gpt labels
3
4 # Copyright (C) 2007-2012 Free Software Foundation, Inc.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
20 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
21 ss=$sector_size_
22
23 dev=loop-file
24 N=4200 # number of sectors
25
26 part_sectors=2048
27 start_sector=2048
28 end_sector=$(expr $start_sector + $part_sectors - 1)
29
30 # setup: reasonable params
31 test $end_sector -lt $N || fail=1
32
33 # setup: create zeroed device
34 dd if=/dev/zero of=$dev bs=${ss}c count=$N 2> /dev/null || fail=1
35
36 # create gpt label
37 parted -s $dev mklabel gpt > empty 2>&1 || fail=1
38
39 # ensure there was no output
40 compare /dev/null empty || fail=1
41
42 # print the table (before adding a partition)
43 parted -m -s $dev unit s print > t 2>&1 || fail=1
44 sed "s,.*/$dev:,$dev:," t > out || fail=1
45
46 # check for expected output
47 printf "BYT;\n$dev:${N}s:file:$ss:$ss:gpt::;\n" > exp || fail=1
48 compare exp out || fail=1
49
50 # add a partition
51 parted -s $dev u s mkpart name1 ${start_sector} ${end_sector} >out 2>&1 \
52   || fail=1
53
54 # print the table before modification
55 parted -m -s $dev unit s print > t 2>&1 || fail=1
56 sed "s,.*/$dev:,$dev:," t >> out || fail=1
57
58 # set the new bios_grub attribute
59 parted -m -s $dev set 1 bios_grub on || fail=1
60
61 # print the table after modification
62 parted -m -s $dev unit s print > t 2>&1 || fail=1
63 sed "s,.*/$dev:,$dev:," t >> out || fail=1
64
65 gen_exp()
66 {
67   cat <<EOF
68 BYT;
69 $dev:${N}s:file:$ss:$ss:gpt::;
70 1:${start_sector}s:${end_sector}s:${part_sectors}s::name1:;
71 BYT;
72 $dev:${N}s:file:$ss:$ss:gpt::;
73 1:${start_sector}s:${end_sector}s:${part_sectors}s::name1:bios_grub;
74 EOF
75 }
76
77 # check for expected output
78 gen_exp > exp || fail=1
79 compare exp out || fail=1
80
81 Exit $fail