-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_c_translate.sh
executable file
·60 lines (51 loc) · 1.56 KB
/
test_c_translate.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
#!/bin/bash
if which dos2unix ; then
DOCS2UNIX="docs2unix"
elif which fromdos ; then
DOCS2UNIX="fromdos"
else
DOCS2UNIX="sed -e s/\x0D//g -"
fi
echo "===================================="
echo " Cleaning temporaries and outputs"
make clean
echo " Force building bin/c_compiler"
make all -B
if [[ "$?" -ne 0 ]]; then
echo "Build failed.";
fi
echo""
mkdir -p test/c_translate/out
echo "===================================="
PASSED=0
CHECKED=0
for i in test/c_translate/in/*.txt; do
echo "=================================="
echo "Input file : ${i}"
BASENAME=$(basename $i .txt)
cat $i | ${DOCS2UNIX} | ./bin/c_compiler > test/c_translate/out/$BASENAME.stdout.txt 2> test/c_translate/out/$BASENAME.stderr.txt
diff <(cat test/c_translate/ref/$BASENAME.stdout.txt | ${DOCS2UNIX}) <(cat test/c_translate/out/$BASENAME.stdout.txt) > test/c_translate/out/$BASENAME.diff.txt
if [[ "$?" -ne "0" ]]; then
echo -e "\nERROR"
else
PASSED=$(( ${PASSED}+1 ));
fi
CHECKED=$(( ${CHECKED}+1 ));
done
echo "###############################################"
echo "Passed ${PASSED} out of ${CHECKED}".
echo ""
RELEASE=$(lsb_release -d)
if [[ $? -ne 0 ]]; then
echo ""
echo "Warning: This appears not to be a Linux environment"
echo " Make sure you do a final run on a lab machine or an Ubuntu VM"
else
grep -q "Ubuntu 16.04" <(echo $RELEASE)
FOUND=$?
if [[ $FOUND -ne 0 ]]; then
echo ""
echo "Warning: This appears not to be the target environment"
echo " Make sure you do a final run on a lab machine or an Ubuntu VM"
fi
fi