OSDN Git Service

91a9f63293c468d07ec46d14146267bd915b5af3
[android-x86/external-parted.git] / tests / t4000-sun-raid-type.sh
1 #!/bin/sh
2 # RAID support on sun disk type
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 # Written by Tom "spot" Callaway <tcallawa@redhat.com>
20 # Derived from an example by Jim Meyering <jim@meyering.net>
21
22 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
23 ss=$sector_size_
24
25 N=2000 # number of sectors
26 dev=sun-disk-file
27 exp="BYT;\n---:${N}s:file:$ss:$ss:sun:;\n1:0s:127s:128s"
28 # create an empty file as a test disk
29 dd if=/dev/zero of=$dev bs=${ss}c count=$N 2> /dev/null || fail=1
30
31 # label the test disk as a sun disk
32 parted -s $dev mklabel sun > out 2>&1 || fail=1
33 compare out /dev/null || fail=1
34
35 # create a single partition
36 parted -s $dev unit s mkpart ext2 0s 127s > out 2>&1 || fail=1
37 compare out /dev/null || fail=1
38
39 # print the partition data in machine readable format
40 parted -m -s $dev unit s p > out 2>&1 || fail=1
41 sed "s,^.*/$dev:,---:," out > k && mv k out
42
43 # check for expected values for the partition
44 printf "$exp:::;\n" > exp || fail=1
45 compare out exp || fail=1
46
47 # set the raid flag
48 parted -s $dev set 1 raid >out 2>&1 || fail=1
49 compare out /dev/null || fail=1
50
51 # print the partition data in machine readable format again
52 parted -m -s $dev unit s p > out 2>&1 || fail=1
53 sed "s,^.*/$dev:,---:," out > k && mv k out || fail=1
54
55 # check for expected values (including raid flag) for the partition
56 printf "$exp:::raid;\n" > exp || fail=1
57 compare out exp || fail=1
58
59 Exit $fail