-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.sh
58 lines (53 loc) · 1.09 KB
/
check.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
#!/bin/bash
points=(5 5 5 5 5 10 15 20 20)
function check_task() {
# @params: $TASK_NUMBER $OUTPUT $REFERENCE
grep "^-$1" $2 > .tmp.out
grep "^-$1" $3 > .tmp.ref
diff -iwBu .tmp.out .tmp.ref &> /dev/null
return $?
}
function check_test() {
# @params: $INPUT $OUTPUT $REFERENCE
INPUT=input/$1
OUTPUT=output/$(basename $INPUT .in).out
REFERENCE=ref/$(basename $INPUT .in).out
echo "=========================="
echo "Test file "$INPUT
echo "=========================="
./$EXE < $INPUT > $OUTPUT
test_points=0
for iter in $(seq 0 8); do
check_task $iter $OUTPUT $REFERENCE
if [ $? -eq 0 ]; then
echo -e "\ttask $iter: ok"
test_points=$(($test_points + ${points[$iter]}))
else
echo -e "\ttask $iter: failed"
fi
done
return $test_points
}
EXE=ip
TESTING=checker
make clean
if [ $? -ne 0 ]; then
exit 1
fi
make build
if [ $? -ne 0 ]; then
exit 1
fi
if [ ! -f $EXE ]; then
echo "The executable name must be $EXE."
exit 1
fi
TOTAL=0
mkdir -p output
for i in $(ls input); do
check_test $i
TOTAL=$(($TOTAL+$?))
done
echo "=============="
echo "TOTAL: "$TOTAL"/900"
echo "=============="