-
Notifications
You must be signed in to change notification settings - Fork 0
/
testhw
286 lines (254 loc) · 8.01 KB
/
testhw
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
276
277
278
279
280
281
282
283
284
285
#! /bin/bash
rm -f results* test*.txt &> /dev/null
rm -rf TempFiles* &> /dev/null
touch TestFiles/appointment.cpp TestFiles/appointment.h TestFiles/day.cpp TestFiles/day.h TestFiles/dayofweek.h TestFiles/year.cpp
touch TestFiles2/calendar.cpp TestFiles2/dayofweek.cpp TestFiles2/time.cpp TestFiles2/time.h TestFiles2/year.h
echo -n "Scores from p1 for " > results.txt
if [ -e authors.txt ]; then
dos2unix authors.txt
awk {'for (i = 2; i <= NF; ++i) printf"%s ", $i'} authors.txt >> results.txt
echo -e "\n"
awk 'NR < 3 {for (i = 2; i <= NF; ++i) printf"%s", $i; printf"\n";}' authors.txt > names.txt
awk {'printf"%s ", $1'} authors.txt > addresses
else
echo "You need to create an authors.txt file!!!! No one will receive credit for this assignment" >> results.txt
# echo "[email protected]" > addresses
# finger ${PWD##*/} | awk 'NR == 1 {printf"%s,%s", $5, $4}' > names.txt
fi
echo -en "\nAddresses used: " >> results.txt
cat addresses >> results.txt
echo " " >> results.txt
echo "Checking grepdir.sh"
echo grepdir.sh testing >> results.txt
grepdirScore=0
if [ -e grepdir.sh ]; then
echo -n "1: " >> results.txt
> test1.txt grepdir.sh first ifndef
diff test1.txt Solutions/test1.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test1.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test1.txt >> results.txt
else
echo OK >> results.txt
(( ++grepdirScore ))
fi
echo -n "2: " >> results.txt
> test2.txt grepdir.sh .
diff test2.txt Solutions/test2.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test2.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test2.txt >> results.txt
else
echo OK >> results.txt
(( ++grepdirScore ))
fi
echo -n "3: " >> results.txt
> test3.txt grepdir.sh
diff test3.txt Solutions/test3.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test3.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test3.txt >> results.txt
else
echo OK >> results.txt
(( ++grepdirScore ))
fi
echo -n "4: " >> results.txt
grepdir.sh TestFiles ifndef | sort > test4.txt
diff test4.txt Solutions/test4.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test4.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test4.txt >> results.txt
else
echo OK >> results.txt
(( ++grepdirScore ))
fi
echo -n "5: " >> results.txt
grepdir.sh TestFiles ifndef -l | sort > test5.txt
diff test5.txt Solutions/test5.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test5.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test5.txt >> results.txt
else
echo OK >> results.txt
(( ++grepdirScore ))
fi
echo -n "6: " >> results.txt
grepdir.sh TestFiles IFNDEF -l -i | sort > test6.txt
diff test6.txt Solutions/test6.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test6.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test6.txt >> results.txt
else
echo OK >> results.txt
(( ++grepdirScore ))
fi
echo -n "7: " >> results.txt
grepdir.sh TestFiles IFNDEF | sort > test7.txt
diff test7.txt Solutions/test7.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test7.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test7.txt >> results.txt
else
echo OK >> results.txt
(( ++grepdirScore ))
fi
else
echo No grepdir.sh >> results.txt
fi
echo -e "\ncpdirs.sh testing" >> results.txt
echo "Checking cpdirs.sh"
cpdirsScore=0
if [ -e cpdirs.sh ]; then
echo -n "11: " >> results.txt
cpdirs.sh TestFiles | sort > test11.txt
diff test11.txt Solutions/test11.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test11.txt >> results.txt
echo -e "\nSeans: " >> results
cat Solutions/test11.txt >> results.txt
else
echo OK >> results.txt
(( ++cpdirsScore ))
fi
echo -n "12: " >> results.txt
> test12.txt cpdirs.sh . TestFiles
diff test12.txt Solutions/test12.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test12.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test12.txt >> results.txt
else
echo OK >> results.txt
(( ++cpdirsScore ))
fi
echo -n "13: " >> results.txt
> test13.txt cpdirs.sh first TestFiles
diff test13.txt Solutions/test13.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test13.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test13.txt >> results.txt
else
echo OK >> results.txt
(( ++cpdirsScore ))
fi
echo -n "14: " >> results.txt
rm -rf tempdir &> /dev/null
mkdir tempdir
cpdirs.sh TestFiles TestFiles2 tempdir
head -1 tempdir/* | sort > test14.txt
diff test14.txt Solutions/test14.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat test14.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/test14.txt >> results.txt
else
echo OK >> results.txt
(( cpdirsScore+=5 ))
fi
else
echo No cpdirs.sh >> results.txt
fi
makemakeScore=0
echo "Checking makemake.sh"
echo -e "\nmakemake.sh testing:" >> results.txt
if [ -e makemake.sh ]; then
rm MakeFiles/makemake.sh &> /dev/null
cp makemake.sh MakeFiles
cd MakeFiles
rm *akefile temp &> /dev/null
echo -n "31: " >> ../results.txt
makemake.sh &> ../test31.txt
diff ../test31.txt ../Solutions/test31.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> ../results.txt
cat ../test31.txt >> ../results.txt
echo -e "\nSeans: " >> ../results.txt
cat ../Solutions/test31.txt >> ../results.txt
else
echo OK >> ../results.txt
(( ++makemakeScore ))
fi
echo -n "32: " >> ../results.txt
makemake.sh appt.out
mv *akefile ../test32.txt
diff -b ../test32.txt ../Solutions/test32.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> ../results.txt
cat ../test32.txt >> ../results.txt
echo -e "\nSeans: " >> ../results.txt
cat ../Solutions/test32.txt >> ../results.txt
else
echo OK >> ../results.txt
(( makemakeScore+=10 ))
fi
echo -n "33: " >> ../results.txt
rm *akefile &> /dev/null
makemake.sh appt1.out -O2 -pg
mv *akefile ../test33.txt
diff -b ../test33.txt ../Solutions/test33.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> ../results.txt
cat ../test33.txt >> ../results.txt
echo -e "\nSeans: " >> ../results.txt
cat ../Solutions/test33.txt >> ../results.txt
else
echo OK >> ../results.txt
(( makemakeScore+=10 ))
fi
cd ..
else
echo No makemake.sh >> results.txt
fi
gdbScore=0
echo "Checking gdb files"
echo -e "\ngdb files fixed?" >> results.txt
gcc main.c prime.c
if [ -e a.out ]; then
(echo '50' | a.out &> out41.txt)&
sleep 1
pkill a.out
diff -b out41.txt Solutions/out41.txt &> temp
if [ -s temp ]; then
echo -e "\nYours: " >> results.txt
cat out41.txt >> results.txt
echo -e "\nSeans: " >> results.txt
cat Solutions/out41.txt >> results.txt
else
if [ ! -s typescript ]; then
echo "No typescript so zero for gdb." >> results.txt
else
echo OK >> results.txt
echo "Note: though this script will accept any typescript as valid now," >> results.txt
echo -e "the actual script will have more insightful tests of submitted typescripts.\n" >> results.txt
gdbScore=10
fi
fi
else
echo No a.out >> results.txt
fi
totalScore=$(( $grepdirScore + $cpdirsScore + $makemakeScore + $gdbScore ))
#echo $grepdirScore,$cpdirsScore,$makemakeScore,$gdbScore > results.csv
echo grepdirScore: $grepdirScore out of 7 >> results.txt
echo cpdirsScore: $cpdirsScore out of 8 >> results.txt
echo makemakeScore: $makemakeScore out of 21 >> results.txt
echo gdbScore: $gdbScore out of 10 >> results.txt
echo totalScore: $totalScore out of 46 >> results.txt