OSDN Git Service

c24818f565fe92fc4a4f86893050897650e50e5e
[android-x86/external-parted.git] / tests / t0208-mkpart-end-in-IEC.sh
1 #!/bin/sh
2 # Make sure parted mkpart ends the partition one sector before the specified
3 # value if end is specified with IEC units.
4
5 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
21
22 require_512_byte_sector_size_
23 n_mbs=8
24 dev=dev-file
25
26 dd if=/dev/null of=$dev bs=1M seek=$n_mbs || fail=1
27 # create 1st partition
28 parted --align=none -s $dev mklabel gpt mkpart p1 1MiB 2MiB > err 2>&1 || fail=1
29 compare /dev/null err || fail=1  # expect no output
30 #parted -m -s $dev u s p > exp || fail=1
31
32 # create 2nd partition - they should not overlap
33 # this time specify default unit
34 parted --align=none -s $dev unit MiB mkpart p2 2 3 > err 2>&1 || fail=1
35 compare /dev/null err || fail=1  # expect no output
36
37 # create 3rd partition - expect no overlap
38 # specify default unit, but explicitly override it
39 parted --align=none -s $dev unit TB mkpart p3 3MiB 4MiB > err 2>&1 || fail=1
40 compare /dev/null err || fail=1  # expect no output
41
42 # Specify default unit of MiB, yet use explicit ending sector number.
43 parted --align=none -s $dev unit MiB mkpart p4 4MiB 10239s > err 2>&1 || fail=1
44 compare /dev/null err || fail=1  # expect no output
45
46 # check boundaries of the partitions
47 parted -m -s $dev u s p > out || fail=1
48
49 # prepare expected output
50 cat <<EOF > exp || framework_failure
51 1:2048s:4095s:2048s::p1:;
52 2:4096s:6143s:2048s::p2:;
53 3:6144s:8191s:2048s::p3:;
54 4:8192s:10239s:2048s::p4:;
55 EOF
56
57 # compare expected and actual outputs
58 sed -e "1,2d" out > k; mv k out
59 compare exp out || fail=1
60
61 Exit $fail