-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-demo.sh
executable file
·65 lines (55 loc) · 1.55 KB
/
test-demo.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
#!/bin/bash
# Author: Bowen (bm2734)
basedir="demo"
files="demo-*.xpp"
TOPLEVEL="./toplevel.native"
LLC="llc"
CC="gcc"
CXX="g++"
CFLAGS="-std=c99 -Wall" # Add -no-pie here for relocation error
CXXFLAGS="-std=c++11 -Wall"
HASH="shasum -a 256"
Check() {
basename=`echo $1 | sed 's/.*\\///
s/.xpp//'`
echo "Testing ${basename}..."
# Build Pixel++ program
../${TOPLEVEL} $1 > ${basename}.ll
${LLC} ${basename}.ll > ${basename}.s
${CC} ${CFLAGS} ${basename}.s stdlib.s load.o -lm -o ${basename}
./${basename} > ${basename}.xpp.out
# Build verification program
${CXX} ${CXXFLAGS} ${basename}-v.cpp xppstdlib.cpp -o ${basename}-v
./${basename}-v
# Testing
# Compare two images
hash1=`${HASH} ${basename}.png | cut -d\ -f1`
hash2=`${HASH} ${basename}-v.png | cut -d\ -f1`
if [ ${hash1} == ${hash2} ]; then
echo "Positive test passed. Images are identical."
else
echo "Positive test failed. Images are different."
${HASH} ${basename}.png ${basename}-v.png
fi
# Clean up
rm -f ${basename}-v ${basename}-v.png
# Clean up
rm -f ${basename}.ll ${basename}.s ${basename} ${basename}.xpp.out
}
cd ${basedir}
# Build built-in and C libraries
../stdlib/${TOPLEVEL} -c2 ../stdlib/stdlib.xpp > stdlib.ll
${LLC} stdlib.ll > stdlib.s
${CC} ${CFLAGS} -c ../load.c
# Start testing
for file in $files
do
case $file in
*demo-*)
Check $file
;;
*)
echo "unknown file type $file"
;;
esac
done