-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.sh
executable file
·149 lines (125 loc) · 3.26 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
# Isto foi feito para ajudar o pessoal a correr testes de compiladores automaticamente
# Qualquer coisa agradeçam ao Miguel Ventura, ou então deixem lá isso
# Mudar o caminho da variavel DIR para o directorio onde estao os testes
#dailies
DIR="tests-zu/tests/"
EXPECTED="tests-zu/expected/"
#simple
# DIR="tests-zu-daily-201604071153/auto-tests/"
# EXPECTED="tests-zu-daily-201604071153/expected/"
#--------------------------------------------------------------------------------------#
COUNTER=1
FAILED=0
COMPILERFAIL=()
YASMFAIL=()
LDFAIL=()
DIFFFAIL=()
echo
echo ">> Ah e tal vamos lá correr os testes:"
echo
#--------------------------------------------------------------------------------------#
for file in ${DIR}*.zu
do
# detecta numero do teste
FILENAME=$(basename $file)
NUM=`echo "$FILENAME" | cut -d'-' -f3`
# Se foi fornecido um intervalo
if [[ -n "$1" && -n "$2" ]]; then
# limite inferior
if [ "$NUM" -lt "$1" ]; then
continue
fi
#limite superior
if [ "$NUM" -gt "$2" ]; then
break
fi
fi
# apenas 1 argumento, numero de testes a correr
if [[ -n "$1" && -z "$2" ]]; then
if [ "$COUNTER" -gt "$1" ]; then
break
fi
fi
# comando a ser executado
NAME=`echo "$file" | cut -d'.' -f1`
N=`echo "$FILENAME" | cut -d'.' -f1`
if [[ "$COUNTER" -eq "1" ]]; then
echo "-----------------------------------------------------"
fi
# executar o compilador
printf "%s : %s " "$COUNTER" "$N"
{ ./zu "$file"; } >& "$NAME.output";
if [[ "$?" -eq "0" ]]; then
printf "..... Compiler: OK, "
else
printf "..... Compiler: Failed, ";
COMPILERFAIL+=("$N")
let FAILED=FAILED+1
fi
# produzir o ficheiro binario
cd $DIR;
{ yasm -felf32 "$N.asm"; } >& /dev/null
if [[ "$?" -eq "0" ]]; then
printf "YASM: OK, "
else
printf "YASM: Failed, ";
YASMFAIL+=("$N")
fi
# gerar o executavel linkando a biblioteca RTS
{ ld -m elf_i386 -o "$N"exec "$N.o" -lrts; } >& /dev/null
if [[ "$?" -eq "0" ]]; then
echo "LD: OK."
else
echo "LD: Failed.";
fi
{ ./"$N"exec > "$N.out"; } >& /dev/null
{ cd ../..; } >& /dev/null
echo
echo "<<<<< Esperado: >>>>>"
echo "$(cat $EXPECTED$N.out)"
echo
echo "««««« Obtido: »»»»»"
echo "$(cat $NAME.out)"
echo
DIFF=$(diff -w -E -B "$NAME.out" "$EXPECTED$N.out")
if [ "$DIFF" != "" ];
then
let FAILEDTESTS=FAILEDTESTS+1
echo "#ERRODIFF"
DIFFFAIL+=("$N")
fi
echo "-----------------------------------------------------"
let COUNTER=COUNTER+1
done
#--------------------------------------------------------------------------------------#
echo
echo
echo $(($COUNTER - 1)) " testes efectuados, falhas abaixo:"
echo
echo "COMPILADOR ZU:"
for i in "${COMPILERFAIL[@]}"
do
echo " !falha : " $i
done
echo "YASM:"
for i in "${YASMFAIL[@]}"
do
echo " !falha : " $i
done
echo "LD:"
for i in "${LDFAIL[@]}"
do
echo " !falha : " $i
done
echo "DIFF:"
for i in "${DIFFFAIL[@]}"
do
echo " !falha : " $i
done
echo
echo "Passam " $(($(($COUNTER - 1)) - $FAILED)) "/" $(($COUNTER - 1))
echo
echo "Nota: Se precisares podes ver os .output gerados para ver o que aconteceu durante o ./zu file.zu"
echo "Está tudo despachado, até à próxima!"
echo