import source from 3.0
[external/parted.git] / tests / t0250-gpt.sh
1 #!/bin/sh
2 # very basic GPT table
3 # Copyright (C) 2008-2011 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
19
20 dev=loop-file
21 nb=512
22 n_sectors=$(expr $nb '*' 512 / $sector_size_)
23
24 # create zeroed device
25 dd if=/dev/zero bs=512 count=$nb of=$dev || fail=1
26
27 # create gpt label
28 parted -s $dev mklabel gpt > empty 2>&1 || fail=1
29
30 # ensure there was no output
31 compare /dev/null empty || fail=1
32
33 # print the empty table
34 parted -m -s $dev unit s print > t 2>&1 || fail=1
35 sed "s,.*/$dev:,$dev:," t > out || fail=1
36
37 # check for expected output
38 printf "BYT;\n$dev:${n_sectors}s:file:$sector_size_:$sector_size_:gpt:;\n" \
39   > exp || fail=1
40 compare exp out || fail=1
41
42 Exit $fail