-
Notifications
You must be signed in to change notification settings - Fork 476
/
Copy pathtravis_test.sh
executable file
·153 lines (131 loc) · 3.82 KB
/
travis_test.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
RV=0
set -o errexit
set -o pipefail
# Launches all examples; this assumes PWD is examples/script
launch_examples() {
# concolic assumes presence of ../linux/simpleassert
echo "Running concolic.py..."
HW=../linux/helloworld
python ./concolic.py
if [ $? -ne 0 ]; then
return 1
fi
echo "Running count_instructions.py..."
python ./count_instructions.py $HW |grep -q Executed
if [ $? -ne 0 ]; then
return 1
fi
echo "Running introduce_symbolic_bytes.py..."
gcc -static -g src/state_explore.c -o state_explore
ADDRESS=0x$(objdump -S state_explore | grep -A 1 '((value & 0xff) != 0)' |
tail -n 1 | sed 's|^\s*||g' | cut -f1 -d:)
python ./introduce_symbolic_bytes.py state_explore $ADDRESS
if [ $? -ne 0 ]; then
return 1
fi
echo "Running run_simple.py..."
gcc -x c -static -o hello - <<-EOF
#include <stdio.h>
int main(){return 0;}
EOF
python ./run_simple.py hello
if [ $? -ne 0 ]; then
return 1
fi
echo "Running run_hook.py..."
MAIN_ADDR=$(nm $HW|grep 'T main' | awk '{print "0x"$1}')
python ./run_hook.py $HW $MAIN_ADDR
if [ $? -ne 0 ]; then
return 1
fi
echo "Running state_control.py..."
# Straight from the header of state_control.py
gcc -static -g src/state_explore.c -o state_explore
SE_ADDR=0x$(objdump -S state_explore | grep -A 1 'value == 0x41' |
tail -n 1 | sed 's|^\s*||g' | cut -f1 -d:)
python ./state_control.py state_explore $SE_ADDR
if [ $? -ne 0 ]; then
return 1
fi
return 0
}
make_vmtests(){
DIR=`pwd`
if [ ! -f ethereum_vm/.done ]; then
echo "Automaking VMTests" `pwd`
cd ./tests/ && mkdir -p ethereum_vm/VMTests_concrete && mkdir -p ethereum_vm/VMTests_symbolic
rm -Rf vmtests; git clone https://github.com/ethereum/tests --depth=1 vmtests
for i in ./vmtests/VMTests/*; do python ./auto_generators/make_VMTests.py $i; done
for i in ./vmtests/VMTests/*; do python ./auto_generators/make_VMTests.py $i --symbolic; done
rm -rf ./vmtests
touch ethereum_vm/.done
fi
cd $DIR
}
run_tests_from_dir() {
DIR=$1
coverage erase
coverage run -m unittest discover "tests/$DIR" 2>&1 >/dev/null | tee travis_tests.log
DID_OK=$(tail -n1 travis_tests.log)
if [[ "${DID_OK}" != OK* ]]; then
echo "Some tests failed :("
return 1
else
coverage xml
fi
}
run_examples() {
pushd examples/linux
make
for example in $(make list); do
./$example < /dev/zero > /dev/null
done
echo Built and ran Linux examples
popd
pushd examples/script
launch_examples
RESULT=$?
echo Ran example scripts
popd
return $RESULT
}
# Test type
case $1 in
ethereum_vm)
make_vmtests
echo "Running only the tests from 'tests/$1' directory"
run_tests_from_dir $1
RV=$?
;;
native) ;& # Fallthrough
ethereum) ;& # Fallthrough
other)
echo "Running only the tests from 'tests/$1' directory"
run_tests_from_dir $1
RV=$?
;;
examples)
run_examples
;;
all)
echo "Running all tests registered in travis_test.sh: examples, native, ethereum, ethereum_vm, other";
# Functions should return 0 on success and 1 on failure
RV=0
run_tests_from_dir native
RV=$(($RV + $?))
run_tests_from_dir ethereum
RV=$(($RV + $?))
make_vmtests; run_tests_from_dir ethereum_vm
RV=$(($RV + $?))
run_tests_from_dir other
RV=$(($RV + $?))
run_examples
RV=$(($RV + $?))
;;
*)
echo "Usage: $0 [examples|native|ethereum|ethereum_vm|other|all]"
exit 3;
;;
esac
exit ${RV}