This repository has been archived by the owner on Oct 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.sh
executable file
·132 lines (104 loc) · 2.4 KB
/
run_tests.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
#!/bin/bash
TIMEOUT_AMOUNT=10s
TIMEOUT=$(if which timeout >& /dev/null; then echo "timeout"; else echo "gtimeout"; fi)
PROVER=FO-prover
correct=0
timeout=0
total_A=0
total_B=0
total_C=0
score=0
for test in ./tests/A/t*.txt; do
[ -e "$test" ] || continue
if [[ "$test" =~ ^./tests/A/t(.*).txt ]]
then
n="${BASH_REMATCH[1]}"
else
printf "no match\n"
fi
echo -n "Running test A $n..."
# run the solver with a timeout
result=$(cat "$test" | $TIMEOUT -sHUP $TIMEOUT_AMOUNT ./"$PROVER")
if (( $? == 0 )) ; then
if (( $result == "1" )) ; then
# passing a positive test gains +1
score=$((score + 1))
echo "OK"
elif (( $result == "0" )) ; then
# failing a positive test gains -2
score=$((score - 2))
echo "FAIL"
else
# abort on unexpected output
echo "unexpected output"
return -1
fi
else
# timeout a positive test gains 0
echo "TIMEOUT"
fi
total_A=$((total_A+1))
done
for test in ./tests/B/t*.txt; do
[ -e "$test" ] || continue
if [[ "$test" =~ ^./tests/B/t(.*).txt ]]
then
n="${BASH_REMATCH[1]}"
else
printf "no match\n"
fi
echo -n "Running test B $n..."
# run the solver with a timeout
result=$(cat "$test" | $TIMEOUT -sHUP $TIMEOUT_AMOUNT ./"$PROVER")
if (( $? == 0 )) ; then
if (( $result == "1" )) ; then
score=$((score - 2))
echo "FAIL"
elif (( $result == "0" )) ; then
score=$((score + 2))
echo "WOW"
else
# abort on unexpected output
echo "unexpected output"
return -1
fi
else
# timeout a test B gains 1
score=$((score + 1))
echo "TIMEOUT (OK)"
fi
total_B=$((total_B+1))
done
for test in ./tests/C/t*.txt; do
[ -e "$test" ] || continue
if [[ "$test" =~ ^./tests/C/t(.*).txt ]]
then
n="${BASH_REMATCH[1]}"
else
printf "no match\n"
fi
echo -n "Running test C $n..."
# run the solver with a timeout
result=$(cat "$test" | $TIMEOUT -sHUP $TIMEOUT_AMOUNT ./"$PROVER")
if (( $? == 0 )) ; then
if (( $result == "1" )) ; then
score=$((score - 2))
echo "FAIL"
elif (( $result == "0" )) ; then
score=$((score + 0))
echo "OK"
else
# abort on unexpected output
echo "unexpected output"
return -1
fi
else
score=$((score - 1))
echo "TIMEOUT"
fi
total_C=$((total_C+1))
done
total=$((total_A + total_B + total_C))
echo "Score: $score/$total"
echo -e "import math\nscore = min(max($score, 0), 81)*35/81\nprint(math.ceil(score), '=', score)" | python
echo "$score" > "score.txt"