1#! /bin/sh 2# 3# Run Scapy test suite. 4# 5# If ran with no arguments: 6# ./run_tests 7# this util will run the test suite using tox, with options that should work 8# regardless of the platform or the dependencies. The only dependency for this 9# to work are python3 (or python) and tox. 10# 11# If ran with arguments, this will call UTscapy.py 12# 13# ATTENTION PACKAGE MAINTAINERS: 14# If you do need to run Scapy tests, calling ./run_tests should be enough. 15# 16DIR=$(dirname "$0")/.. 17if [ -z "$PYTHON" ] 18then 19 ARGS="" 20 for arg in "$@" 21 do 22 case $arg 23 in 24 -3) PYTHON=python3;; 25 -W) PYTHONWARNINGS="-W error";; 26 *) ARGS="$ARGS $arg";; 27 esac 28 done 29 PYTHON=${PYTHON:-python3} 30else 31 ARGS="$@" 32fi 33$PYTHON --version > /dev/null 2>&1 34if [ ! $? -eq 0 ] 35then 36 echo "WARNING: '$PYTHON' not found, using 'python' instead." 37 PYTHON=python 38fi 39 40if [ -z "$ARGS" ] 41then 42 # No arguments specified: use tox 43 # We use flags to disable tests that use external non tox-installed 44 # software. 45 46 # Check tox 47 tox --version >/dev/null 2>/dev/null 48 if [ ! $? -eq 0 ] 49 then 50 echo "ERROR: tox is not installed." 51 echo "You can still run ./run_tests with arguments: see ./run_tests -h" 52 echo "e.g. ./run_tests -t tls.uts -F" 53 exit 1 54 fi 55 56 # Run tox 57 export UT_FLAGS="-K tcpdump -K wireshark -K tshark -K ci_only -K vcan_socket -K automotive_comm -K imports -K scanner" 58 export SIMPLE_TESTS="true" 59 export PYTHON 60 export DISABLE_COVERAGE=" " 61 PYVER=$($PYTHON -c "import sys; print('.'.join(sys.version.split('.')[:2]))") 62 bash ${DIR}/.config/ci/test.sh $PYVER non_root 63 exit $? 64fi 65PYTHONPATH=$DIR exec "$PYTHON" $PYTHONWARNINGS ${DIR}/scapy/tools/UTscapy.py $ARGS 66