Run linux examples in Travis (#668)

* Update makefile; add a list target for testing

* simplify nostdlib example

* Make sendmail example return success

* Add tests to run all examples

* Add some targets to exclude

* Run example scripts; temporarily add a workspace accsesor to mcore

* Optionally read end of main from argv

* Make concolic test more robust

* Clean up Makefile

* Be better with phony targets

* Add run_simple and state_control tests

* verbosity++

* Make sure we fail when we intend to

* Simplify travis_test.sh

* Remove multi_arch_sym
This commit is contained in:
Yan Ivnitskiy
2018-01-18 15:50:13 -05:00
committed by GitHub
parent 7907d0179d
commit 60d2b61fb3
7 changed files with 121 additions and 103 deletions
+78 -12
View File
@@ -1,13 +1,79 @@
#!/bin/bash
RV=0
cd examples/linux
if make; then
echo "Successfully built Linux examples"
else
echo "Failed to build Linux examples"
RV=1
fi
cd ../..
set -o errexit
set -o pipefail
# Run all examples; this assumes PWD is examples/script
run_examples() {
# concolic assumes presence of ../linux/simpleassert
echo "Running concolic.py..."
HW=../linux/helloworld
SA=../linux/simpleassert
END_OF_MAIN=$(objdump -d $SA|awk -v RS= '/^[[:xdigit:]].*<main>/'|grep ret|tr -d ' ' | awk -F: '{print "0x" $1}')
python ./concolic.py $END_OF_MAIN
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
}
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
run_examples
echo Ran example scripts
popd
coverage erase
coverage run -m unittest discover tests/ 2>&1 >/dev/null | tee travis_tests.log
@@ -17,7 +83,7 @@ then
echo "All functionality tests passed :)"
else
echo "Some functionality tests failed :("
RV=1
exit 2
fi
measure_cov() {
@@ -27,8 +93,7 @@ measure_cov() {
if [ "${HAS_COV}" = "No data to report" ]
then
echo " FAIL: No coverage for ${PYFILE}"
RV=1
return
return 1
fi
local COV_AMT=$(coverage report --include=${PYFILE} | tail -n1 | sed "s/.* \([0-9]*\)%/\1/g")
@@ -37,8 +102,9 @@ measure_cov() {
echo " PASS: coverage for ${PYFILE} at ${COV_AMT}%"
else
echo " FAIL: coverage for ${PYFILE} at ${COV_AMT}%"
RV=1
return 1
fi
return 0
}
#coverage report