]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sbin/sunlabel/runtest.sh
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sbin / sunlabel / runtest.sh
1 #!/bin/sh
2 # $FreeBSD$
3
4 TMP=/tmp/$$.
5 set -e
6 MD=`mdconfig -a -t malloc -s 2m`
7 trap "exec 7</dev/null; rm -f ${TMP}* ; mdconfig -d -u ${MD}" EXIT INT TERM
8
9 ./sunlabel -r -w $MD auto
10
11 dd if=/dev/$MD of=${TMP}i0 count=16 > /dev/null 2>&1
12 ./sunlabel $MD > ${TMP}l0
13
14 sed '
15 /  c:/{
16 p
17 s/c:/a:/
18 s/3969/1024/
19 }
20 ' ${TMP}l0 > ${TMP}l1
21
22 ./sunlabel -R $MD ${TMP}l1
23 if [ -c /dev/${MD}a ] ; then
24         echo "PASS: Created a: partition" 1>&2
25 else
26         echo "FAIL: Did not create a: partition" 1>&2
27         exit 2
28 fi
29
30 # Spoil and rediscover
31
32 true > /dev/${MD}
33 if [ -c /dev/${MD}a ] ; then
34         echo "PASS: Recreated a: partition after spoilage" 1>&2
35 else
36         echo "FAIL: Did not recreate a: partition after spoilage" 1>&2
37         exit 2
38 fi
39
40 dd if=/dev/$MD of=${TMP}i1 count=16 > /dev/null 2>&1
41 sed '
42 /  c:/{
43 p
44 s/c:/a:/
45 s/3969/2048/
46 }
47 ' ${TMP}l0 > ${TMP}l2
48
49 ./sunlabel -R $MD ${TMP}l2
50 dd if=/dev/$MD of=${TMP}i2 count=16 > /dev/null 2>&1
51
52 exec 7< /dev/${MD}a
53
54 for t in a c
55 do
56         if dd if=${TMP}i2 of=/dev/${MD}$t 2>/dev/null ; then
57                 echo "PASS: Could rewrite same label to ...$t while ...a open" 1>&2
58         else
59                 echo "FAIL: Could not rewrite same label to ...$t while ...a open" 1>&2
60                 exit 2
61         fi
62
63         if dd if=${TMP}i1 of=/dev/${MD}$t 2>/dev/null ; then
64                 echo "FAIL: Could label with smaller ...a to ...$t while ...a open" 1>&2
65                 exit 2
66         else
67                 echo "PASS: Could not label with smaller ...a to ...$t while ...a open" 1>&2
68         fi
69
70         if dd if=${TMP}i0 of=/dev/${MD}$t 2>/dev/null ; then
71                 echo "FAIL: Could write label missing ...a to ...$t while ...a open" 1>&2
72                 exit 2
73         else
74                 echo "PASS: Could not write label missing ...a to ...$t while ...a open" 1>&2
75         fi
76 done
77
78 exec 7< /dev/null
79
80 if dd if=${TMP}i0 of=/dev/${MD}c 2>/dev/null ; then
81         echo "PASS: Could write missing ...a label to ...c" 1>&2
82 else
83         echo "FAIL: Could not write missing ...a label to ...c" 1>&2
84         exit 2
85 fi
86
87 if dd if=${TMP}i2 of=/dev/${MD}c 2>/dev/null ; then
88         echo "PASS: Could write large ...a label to ...c" 1>&2
89 else
90         echo "FAIL: Could not write large ...a label to ...c" 1>&2
91         exit 2
92 fi
93
94 if dd if=${TMP}i1 of=/dev/${MD}c 2>/dev/null ; then
95         echo "PASS: Could write small ...a label to ...c" 1>&2
96 else
97         echo "FAIL: Could not write small ...a label to ...c" 1>&2
98         exit 2
99 fi
100
101 if dd if=${TMP}i2 of=/dev/${MD}a 2>/dev/null ; then
102         echo "PASS: Could increase size of ...a by writing to ...a" 1>&2
103 else
104         echo "FAIL: Could not increase size of ...a by writing to ...a" 1>&2
105         exit 2
106 fi
107
108 if dd if=${TMP}i1 of=/dev/${MD}a 2>/dev/null ; then
109         echo "FAIL: Could decrease size of ...a by writing to ...a" 1>&2
110         exit 2
111 else
112         echo "PASS: Could not decrease size of ...a by writing to ...a" 1>&2
113 fi
114
115 if dd if=${TMP}i0 of=/dev/${MD}a 2>/dev/null ; then
116         echo "FAIL: Could delete ...a by writing to ...a" 1>&2
117         exit 2
118 else
119         echo "PASS: Could not delete ...a by writing to ...a" 1>&2
120 fi
121
122 if ./sunlabel -B -b ${TMP}i0 ${MD} ; then
123         if [ ! -c /dev/${MD}a ] ; then
124                 echo "FAILED: Writing bootcode killed ...a" 1>&2
125                 exit 2
126         else
127                 echo "PASS: Could write bootcode while closed" 1>&2
128         fi
129 else
130         echo "FAILED: Could not write bootcode while closed" 1>&2
131         exit 2
132 fi
133
134 exec 7> /dev/${MD}c
135 if ktrace ./sunlabel -B -b ${TMP}i0 ${MD} ; then
136         if [ ! -c /dev/${MD}a ] ; then
137                 echo "FAILED: Writing bootcode killed ...a" 1>&2
138                 exit 2
139         else
140                 echo "PASS: Could write bootcode while open" 1>&2
141         fi
142 else
143         echo "FAILED: Could not write bootcode while open" 1>&2
144         exit 2
145 fi
146 exec 7> /dev/null
147
148 if dd if=${TMP}i0 of=/dev/${MD}c 2>/dev/null ; then
149         echo "PASS: Could delete ...a by writing to ...c" 1>&2
150 else
151         echo "FAIL: Could not delete ...a by writing to ...c" 1>&2
152         exit 2
153 fi
154
155 # XXX: need to add a 'b' partition and check for overlaps.
156
157 exit 0