-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrade.sh
executable file
·275 lines (229 loc) · 4.73 KB
/
grade.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#!/bin/bash
./stop.sh >/dev/null 2>&1
./stop.sh >/dev/null 2>&1
./stop.sh >/dev/null 2>&1
./stop.sh >/dev/null 2>&1
./stop.sh >/dev/null 2>&1
score=0
mkdir yfs1 >/dev/null 2>&1
mkdir yfs2 >/dev/null 2>&1
./start.sh
test_if_has_mount(){
mount | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: Your YFS client has failed to mount its filesystem!"
exit
fi;
yfs_count=$(ps -e | grep -o "yfs_client" | wc -l)
extent_count=$(ps -e | grep -o "extent_server" | wc -l)
if [ $yfs_count -ne 2 ];
then
echo "error: yfs_client not found (expecting 2)"
exit
fi;
if [ $extent_count -ne 1 ];
then
echo "error: extent_server not found"
exit
fi;
}
test_if_has_mount
##################################################
# run test 1
./test-lab2-part1-a.pl yfs1 | grep -q "Passed all"
if [ $? -ne 0 ];
then
echo "Failed test-part1-A"
#exit
else
ps -e | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: yfs_client DIED!"
exit
else
score=$((score+10))
#echo $score
echo "Passed part1 A"
fi
fi
test_if_has_mount
##################################################
./test-lab2-part1-b.pl yfs1 | grep -q "Passed all"
if [ $? -ne 0 ];
then
echo "Failed test-part1-B"
#exit
else
ps -e | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: yfs_client DIED!"
exit
else
score=$((score+10))
#echo $score
echo "Passed part1 B"
fi
fi
test_if_has_mount
##################################################
./test-lab2-part1-c.pl yfs1 | grep -q "Passed all"
if [ $? -ne 0 ];
then
echo "Failed test-part1-c"
#exit
else
ps -e | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: yfs_client DIED!"
exit
else
score=$((score+10))
#echo $score
echo "Passed part1 C"
fi
fi
test_if_has_mount
##################################################
./test-lab2-part1-d.sh yfs1 >tmp.1
./test-lab2-part1-d.sh yfs2 >tmp.2
lcnt=$(cat tmp.1 tmp.2 | grep -o "Passed SYMLINK" | wc -l)
if [ $lcnt -ne 2 ];
then
echo "Failed test-part1-d"
#exit
else
ps -e | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: yfs_client DIED!"
exit
else
score=$((score+10))
echo "Passed part1 D"
#echo $score
fi
fi
test_if_has_mount
rm tmp.1 tmp.2
##################################################################################
./test-lab2-part1-e.sh yfs1 >tmp.1
./test-lab2-part1-e.sh yfs2 >tmp.2
lcnt=$(cat tmp.1 tmp.2 | grep -o "Passed BLOB" | wc -l)
if [ $lcnt -ne 2 ];
then
echo "Failed test-part1-e"
else
#exit
ps -e | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: yfs_client DIED!"
exit
else
score=$((score+10))
echo "Passed part1 E"
#echo $score
fi
fi
test_if_has_mount
rm tmp.1 tmp.2
##################################################################################
robust(){
./test-lab2-part1-f.sh yfs1 | grep -q "Passed ROBUSTNESS test"
if [ $? -ne 0 ];
then
echo "Failed test-part1-f"
else
#exit
ps -e | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: yfs_client DIED!"
exit
else
score=$((score+10))
echo "Passed part1 F -- Robustness"
#echo $score
fi
fi
test_if_has_mount
}
##################################################################################
consis_test(){
./test-lab2-part1-g yfs1 yfs2 | grep -q "test-lab2-part1-g: Passed all tests."
if [ $? -ne 0 ];
then
echo "Failed test-part1-g"
else
#exit
ps -e | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: yfs_client DIED!"
exit
else
score=$((score+10))
echo "Passed part1 G (consistency)"
#echo $score
fi
fi
}
consis_test
if [ $score -eq 60 ];
then
echo "Lab2 part 1 passed"
else
echo "Lab2 part 1 failed"
fi
test_if_has_mount
##################################################################################
./test-lab2-part2-a yfs1 yfs2 | tee tmp.0
lcnt=$(cat tmp.0 | grep -o "OK" | wc -l)
if [ $lcnt -ne 5 ];
then
echo "Failed test-part2-a: pass "$lcnt"/5"
score=$((score+$lcnt*10))
else
#exit
ps -e | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: yfs_client DIED!"
exit
else
score=$((score+50))
echo "Passed part2 A"
#echo $score
fi
fi
rm tmp.0
test_if_has_mount
##################################################################################
./test-lab2-part2-b yfs1 yfs2 | tee tmp.0
lcnt=$(cat tmp.0 | grep -o "OK" | wc -l)
if [ $lcnt -ne 1 ];
then
echo "Failed test-part2-b"
else
#exit
ps -e | grep -q "yfs_client"
if [ $? -ne 0 ];
then
echo "FATAL: yfs_client DIED!"
exit
else
score=$((score+10))
echo "Passed part2 B"
#echo $score
fi
fi
rm tmp.0
# finally reaches here!
#echo "Passed all tests!"
./stop.sh
echo ""
echo "Score: "$score"/120"