-
Notifications
You must be signed in to change notification settings - Fork 0
/
rundemos.sh
executable file
·81 lines (75 loc) · 1.64 KB
/
rundemos.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
#!/bin/bash
verbose=0
type="sast"
while getopts v:t: flag
do
case "${flag}" in
v) verbose=${OPTARG};;
t) type=${OPTARG};;
esac
done
llvm_tests() {
cd demo/
echo "Beginning LLVM tests"
for i in *.vp; do
if [ ! -e "${i}.out" ]
then
echo "Skipping test as no file found for: ${i}.out in ${PWD}"
continue;
fi
echo "Running LLVM test on: $i"
../viper.native $i > a.ll
llc -relocation-model=pic a.ll > a.s
cc -o a.exe a.s ../src/library.o -lm
output=$(./a.exe)
expectedoutput=$(cat "${i}.out")
rm a.ll
if [ $verbose -eq 1 ];
then
echo "Output: ${output}"
echo "Expected Output: ${expectedoutput}"
fi
if [[ "$output" == "$expectedoutput" ]]
then
echo "PASSED"
else
echo "FAILURE: $i"
exit 1
fi
echo "______________________________________"
done
}
sast_tests() {
cd demo/
echo "Beginning SAST tests"
for i in *.vp; do
echo "Running SAST test on: $i"
if [ $verbose -eq 1 ];
then
../viper.native -a $i
else
../viper.native -a $i >/dev/null 2>&1
fi
if [ $? -eq 0 ]
then
echo "PASSED"
else
echo "FAILURE: $i"
exit 1
fi
echo "______________________________________"
done
}
cd src
make clean
make
mv ./viper.native ../viper.native
cd ..
echo "Test type: ${type}"
echo "Verbose enabled: ${verbose}"
if [ $type == "llvm" ]
then
llvm_tests
else
sast_tests
fi