File: run_tests

package info (click to toggle)
scapy 2.6.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,956 kB
  • sloc: python: 163,618; sh: 90; makefile: 10
file content (65 lines) | stat: -rwxr-xr-x 1,681 bytes parent folder | download | duplicates (2)
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
#! /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