-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_tests
executable file
·71 lines (59 loc) · 1.61 KB
/
run_tests
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
#!/bin/sh
PROJ="$PWD" # Project home
SRCDIR="$PROJ/src" # Sources directory (presumably the home to the Makefile)
TESTDIR="$PROJ/tests" # Tests directory (expected in here too)
RESDIR="$PROJ/results" # Results directory (test results, per target)
SUITE="" # suite prefix (all, by default)
TARGET="asm" # default target is asm
while test -n "$1"; do
case "$1" in
xml|asm)
TARGET="$1"
shift
;;
*)
SUITE="$1"
shift
;;
esac
done
mkdir -p "$RESDIR/$TARGET"
if [ $TARGET = "xml" ]; then
mkdir -p "$RESDIR/xml/img"
else
mkdir -p "$RESDIR/asm/out"
fi
# Setup
# Compile the compiler, if need be
cd "$SRCDIR"
echo -n "Compiling xpl.. "
make >/dev/null
if [ $? -ne 0 ]; then
echo "KO"
exit 1
else
echo "OK"
fi
# Run tests
for i in $(ls "$TESTDIR/$SUITE"*.xpl); do
test_name="$(basename $i)"
test_name="${test_name%.xpl}"
echo "Running $test_name.."
"$SRCDIR"/xpl --target $TARGET -o "$RESDIR/$TARGET/$test_name.$TARGET" $i
if [ $TARGET = "xml" ]; then
java -cp "$SRCDIR"/xml2dot.jar xml2dot.xml2dot "$RESDIR/xml/$test_name.xml"
ps aux | grep dotty | head -n1 | kill $(awk '{print $2}')
dot -Tpng -o "$RESDIR/xml/img/$test_name.png" "$RESDIR/xml/$test_name.xml.dot"
else
yasm -felf32 -o "$RESDIR/asm/$test_name.o" "$RESDIR/asm/$test_name.asm"
ld -melf_i386 -o "$RESDIR/asm/$test_name" "$RESDIR/asm/$test_name.o" -lrts
chmod +x "$RESDIR/asm/$test_name"
"$RESDIR/asm/"$test_name > "$RESDIR/asm/out/$test_name.out"
rm -f "$RESDIR/asm/$test_name"
fi
done
if [ $TARGET = "xml" ]; then
rm -rf "$RESDIR/xml/"*.xml.dot
else
rm -rf "$RESDIR/asm/"*.o
fi