blob: a44808dfc562654170084ca5c986d6258419ca01 [file] [log] [blame]
#! /bin/sh
#
# Run Scapy test suite.
#
# If ran with no arguments:
# ./run_tests
# this util will run the test suite using tox, with options that should work
# regardless of the platform or the dependencies. The only dependency for this
# to work are python3 (or python) and tox.
#
# If ran with arguments, this will call UTscapy.py
#
# ATTENTION PACKAGE MAINTAINERS:
# If you do need to run Scapy tests, calling ./run_tests should be enough.
#
DIR=$(dirname "$0")/..
if [ -z "$PYTHON" ]
then
ARGS=""
for arg in "$@"
do
case $arg
in
-3) PYTHON=python3;;
-W) PYTHONWARNINGS="-W error";;
*) ARGS="$ARGS $arg";;
esac
done
PYTHON=${PYTHON:-python3}
else
ARGS="$@"
fi
$PYTHON --version > /dev/null 2>&1
if [ ! $? -eq 0 ]
then
echo "WARNING: '$PYTHON' not found, using 'python' instead."
PYTHON=python
fi
if [ -z "$ARGS" ]
then
# No arguments specified: use tox
# We use flags to disable tests that use external non tox-installed
# software.
# Check tox
tox --version >/dev/null 2>/dev/null
if [ ! $? -eq 0 ]
then
echo "ERROR: tox is not installed."
echo "You can still run ./run_tests with arguments: see ./run_tests -h"
echo "e.g. ./run_tests -t tls.uts -F"
exit 1
fi
# Run tox
export UT_FLAGS="-K tcpdump -K wireshark -K tshark -K ci_only -K vcan_socket -K automotive_comm -K imports -K scanner"
export SIMPLE_TESTS="true"
export PYTHON
export DISABLE_COVERAGE=" "
PYVER=$($PYTHON -c "import sys; print('.'.join(sys.version.split('.')[:2]))")
bash ${DIR}/.config/ci/test.sh $PYVER non_root
exit $?
fi
PYTHONPATH=$DIR exec "$PYTHON" $PYTHONWARNINGS ${DIR}/scapy/tools/UTscapy.py $ARGS