import source from 3.0
[external/parted.git] / tests / t4200-partprobe.sh
1 #!/bin/sh
2 # partprobe must not examine more than 16 partitions
3
4 # Copyright (C) 2008-2011 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 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
20 require_erasable_
21 require_root_
22 require_dvhtool_
23
24 dev=$DEVICE_TO_ERASE
25
26 # setup: create a DVH partition table on $dev"
27 dd if=/dev/zero of=$dev bs=512 count=1 seek=10000 || fail=1
28 parted -s $dev mklabel dvh || fail=1
29
30 # setup: use dvhtool to create a 17th (invalid?) partition"
31 dd if=/dev/zero of=d bs=1 count=4k || fail=1
32 dvhtool -d $dev --unix-to-vh d data || fail=1
33
34 # Here's sample output from the parted...print command below:
35 # BYT;
36 # /dev/sdd:128880s:scsi:512:512:dvh: Flash Disk;
37 # 9:0s:4095s:4096s:::;
38 # 17:4s:11s:8s::data:;
39
40 # ensure that dvhtool did what we want"
41 parted -m -s $dev unit s print > out 2>&1 || fail=1
42 grep "^17:.*::data:;\$" out || fail=1
43
44 # Parted 1.8.9 and earlier would mistakenly try to access partition #17.
45 # ensure that partprobe succeeds and produces no output"
46 partprobe -s $dev > out 2>err || fail=1
47 compare err /dev/null || fail=1
48 echo "$dev: dvh partitions 9 <17>" > exp || fail=1
49 compare out exp || fail=1
50
51 Exit $fail