-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.sh
executable file
·125 lines (108 loc) · 3.35 KB
/
runtests.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
#!/bin/bash
EXEC=albatrosscc
DUMMY=test
OUTPUT=output
TEST_DIR=tests
TIMEOUT=1s
DIFF_FILE=d
MARS=Mars4_5.jar
JAVA=java
PASSING=0
RED='\033[41;37m'
GREEN='\033[42m'
RESET='\033[0m'
export ASAN_OPTIONS="detect_leaks=false"
export MallocNanoZone="0"
make clean && make
START=$(date +%s%N | cut -b1-13 | sed s/N/000/g)
for T in $(ls $TEST_DIR | grep -E "$1" | sort)
do
PASS=1
for F in $(ls $TEST_DIR/$T | grep ".albatross$" | grep pass | sort)
do
echo -n -e "Running ${GREEN}positive test${RESET} $T/$F"
echo -n $'\t'
TESTFILE="$TEST_DIR/$T/$F"
EXPECTED=$(sed 's/.albatross/.expected/g' <<<"$TESTFILE")
cp $TESTFILE $DUMMY
mv $EXEC.exe $EXEC &> /dev/null
T1=$(date +%s%N | cut -b1-13 | sed s/N/000/g)
./$EXEC $TESTFILE out.mips &> $DIFF_FILE
RET=$?
T2=$(date +%s%N | cut -b1-13 | sed s/N/000/g)
TT=$((T2-T1))
if [ $RET -eq 0 ]
then
echo -e -n "${GREEN}COMPILE OK in ${TT}ms ${RESET}\t"
else
echo -e "${RED}COMPILE FAIL in ${TT}ms ${RESET}"
cat $DIFF_FILE
PASS=0
continue
fi
T1=$(date +%s%N | cut -b1-13 | sed s/N/000/g)
$JAVA -Xmx1G -jar $MARS nc out.mips > $OUTPUT
RET=$?
T2=$(date +%s%N | cut -b1-13 | sed s/N/000/g)
TT=$((T2-T1))
if [ $RET -eq 0 ]
then
echo -e -n " ${GREEN}RUN OK in ${TT}ms${RESET}\t"
else
echo -e " ${RED}RUN FAIL in ${TT}ms${RESET}"
cat $OUTPUT
PASS=0
continue
fi
# Remove possible Windows \r from output and expected files
sed 's/\r$//' -i $OUTPUT &> /dev/null
sed 's/\r$//' -i $EXPECTED &> /dev/null
diff $EXPECTED $OUTPUT &> $DIFF_FILE
DIFF=$?
rm $DUMMY $OUTPUT &> /dev/null
if [ $DIFF -eq 0 ]
then
echo -e " ${GREEN}DIFF OK${RESET}\t"
else
echo -e " ${RED}DIFF FAIL${RESET}"
cat $DIFF_FILE
fi
if [ $RET -ne 0 ] || [ $DIFF -ne 0 ]
then
PASS=0
#continue 2
fi
done
for F in $(ls $TEST_DIR/$T | grep ".albatross$" |grep fail | sort)
do
echo -n -e "Running ${RED}negative test${RESET} $T/$F"
echo -n $'\t'
TESTFILE="$TEST_DIR/$T/$F"
cp $TESTFILE $DUMMY
$(./$EXEC $DUMMY &> /dev/null)
RET=$?
if [ $RET -eq 3 ]
then
echo -e "${GREEN}RET OK${RESET}"
else
echo -e "${RED}RET FAIL${RESET}"
#continue 2
PASS=0
fi
rm $DUMMY
done
if [ $PASS -eq 0 ]
then
echo -e "${RED} TEST ${T} FAILING ${RESET}"
echo -e "${RED} TEST ${T} FAILING ${RESET}"
echo -e "${RED} TEST ${T} FAILING ${RESET}"
else
echo -e "${GREEN} TEST ${T} PASSING ${RESET}"
echo -e "${GREEN} TEST ${T} PASSING ${RESET}"
echo -e "${GREEN} TEST ${T} PASSING ${RESET}"
fi
PASSING=$(($PASSING+$PASS))
done
END=$(date +%s%N | cut -b1-13 | sed s/N/000/g)
echo "Finished in $((END-START))ms"
echo $PASSING