-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_driver_compiler.sh
executable file
·58 lines (46 loc) · 1.71 KB
/
test_driver_compiler.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
blk=$'\x1b[90m' # Sets text to black
red=$'\x1b[31m' # Sets text to red
grn=$'\x1b[92m' # Sets text to green
ylw=$'\x1b[93m' # Sets text to yellow
blu=$'\x1b[94m' # Sets text to blue
pur=$'\x1b[95m' # Sets text to purple
cyn=$'\x1b[96m' # Sets text to cyan
wht=$'\x1b[97m' # Sets text to white
if [[ -z "$1" ]]; then
COMPILER=bin/c_compiler
else
COMPILER=$1
fi
workingin="test/mips_test/testin"
workingout="test/mips_test/output"
mkdir -p $workingout
for DRIVER in $workingin/*_driver.c ; do
NAME=$(basename $DRIVER _driver.c)
TESTCODE=$workingin/$NAME.c
# Generate assembly for driver
mips-linux-gnu-gcc -S -w -march=mips1 -mfp32 -O0 $DRIVER -o $workingout/${NAME}_driver.s
if [[ $? -ne 0 ]]; then
>&2 echo "ERROR : Couldn't compile driver program using GCC."
continue
fi
# Generate assembly for slave
$COMPILER -S $workingin/${NAME}.c -o $workingout/${NAME}.s
if [[ $? -ne 0 ]]; then
>&2 echo "ERROR : Compiler returned error message."
continue
fi
# Generate GOT_EXIT_CODE
mips-linux-gnu-gcc -w -static $workingout/${NAME}_driver.s $workingout/${NAME}.s -o $workingout/${NAME}_result
qemu-mips $workingout/${NAME}_result
GOT_EXIT_CODE=$?
# Generate EXP_EXIT_CODE
mips-linux-gnu-gcc -w -static -march=mips1 -mfp32 -O0 $workingin/${NAME}.c $workingin/${NAME}_driver.c -o $workingout/${NAME}_gcc_result
qemu-mips $workingout/${NAME}_gcc_result
EXP_EXIT_CODE=$?
if [[ $GOT_EXIT_CODE -ne $EXP_EXIT_CODE ]]; then
echo -e ${wht}$NAME.c ${red}"[FAIL]" ${wht}"Expected" $EXP_EXIT_CODE ", got" $GOT_EXIT_CODE
else
echo -e ${wht}$NAME.c ${grn}"[PASS]"
fi
done