-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_compiler_testsuite.sh
executable file
·89 lines (72 loc) · 2.18 KB
/
c_compiler_testsuite.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
#!/bin/bash
#!/bin/bash
# Try to find a portable way of getting rid of
# any stray carriage returns
if which dos2unix ; then
DOS2UNIX="dos2unix"
elif which fromdos ; then
DOS2UNIX="fromdos"
else
# This works on a GNU version of sed. I think this
# will work in OSX as well, but don't have a machine
# on which to test that. From reading the OSX docs,
# it looks compatible.
# The code \x0D is the ASCII code of carriage-return,
# so it the regex should delete any CRs at the end of
# a line (or anywhere in a line)
DOS2UNIX="sed -e s/\x0D//g -"
# Tested for combinations of:
# - Ubuntu
# - Cygwin
# and inputs formats:
# - LF
# - CRLF
fi
make clean
make all
mkdir -p running_data
external="test_deliverable/external_tests"
handin="test_deliverable/test_cases"
current="test_deliverable/current"
input_dir=$handin
if [[ "$1" != "" ]] ; then
compiler="$1"
else
compiler="bin/c_compiler"
fi
have_compiler=0
if [[ ! -f bin/c_compiler ]] ; then
>&2 echo "Warning : cannot find compiler at path ${compiler}."
have_compiler=1
fi
count=1
passnumber=0
echo ""
echo ""
echo ""
echo "================ tests start ===================="
for i in ${input_dir}/*.c ; do
if [[ ${i} != *"driver"* ]]; then
base=$(echo $i | sed -E -e "s|${input_dir}/([^.]+)[.]c|\1|g");
mkdir -p running_data/$base
path="running_data/${base}"
bin/c_compiler -S ${input_dir}/$base.c -o $path/$base.s &>>$path/${base}_log.txt
#mips-linux-gnu-gcc -S ${input_dir}/$base.c -o $path/$base.s &>>$path/${base}_log.txt
mips-linux-gnu-gcc -mfp32 -o $path/$base.o -c $path/$base.s &>>$path/${base}_log.txt
mips-linux-gnu-gcc -mfp32 -static -o $path/$base $path/$base.o ${input_dir}/${base}_driver.c &>>$path/${base}_log.txt
qemu-mips $path/$base &>>$path/${base}_log.txt
if [ $? -ne 0 ]; then
echo "test $count $base failed"
else
echo "test $count $base pass."
let "passnumber ++"
fi
let "count ++"
echo "++++++++++++++++++++++++++++++++++++++++"
echo ""
fi
done
let "count --"
echo "++++++++++++++++++++++++++++++"
echo "++ $passnumber out of $count tests passed ++"
echo "++++++++++++++++++++++++++++++"