Skip to content
Snippets Groups Projects
Commit e7e187cb authored by Pierre Lalet's avatar Pierre Lalet Committed by GitHub
Browse files

Merge pull request #425 from guedou/codecov

[coverage] codecov support
parents 6d8c8089 8fc77d5e
No related branches found
No related tags found
No related merge requests found
...@@ -15,38 +15,42 @@ matrix: ...@@ -15,38 +15,42 @@ matrix:
- os: osx - os: osx
language: generic language: generic
env: env:
- TRAVIS_SUDO=false - SCAPY_SUDO=false SCAPY_USE_PCAPDNET=yes
- SCAPY_USE_PCAPDNET=yes
# Run as root # Run as root
- os: linux - os: linux
sudo: required sudo: required
python: 2.7 python: 2.7
env: env:
- TRAVIS_SUDO=sudo - SCAPY_SUDO=sudo
- os: linux - os: linux
sudo: required sudo: required
python: 2.7 python: 2.7
env: env:
- TRAVIS_SUDO=sudo TEST_COMBINED_MODES=yes - SCAPY_SUDO=sudo TEST_COMBINED_MODES=yes SCAPY_COVERAGE=yes
- os: linux - os: linux
sudo: required sudo: required
python: 2.7 python: 2.7
env: env:
- TRAVIS_SUDO=sudo SCAPY_USE_PCAPDNET=yes - SCAPY_SUDO=sudo SCAPY_USE_PCAPDNET=yes SCAPY_COVERAGE=yes
- os: osx - os: osx
language: generic language: generic
env: env:
- TRAVIS_SUDO=sudo - SCAPY_SUDO=sudo SCAPY_COVERAGE=yes
- os: osx - os: osx
language: generic language: generic
env: env:
- TRAVIS_SUDO=sudo SCAPY_USE_PCAPDNET=yes - SCAPY_SUDO=sudo SCAPY_USE_PCAPDNET=yes SCAPY_COVERAGE=yes
install: bash .travis/install.sh install: bash .travis/install.sh
script: bash .travis/test.sh script: bash .travis/test.sh
after_success:
- if [ "$SCAPY_COVERAGE" = "yes" ]; then pip install codecov; fi
# With UTScapy, the coverage dot file is located in the test directory
- if [ "$SCAPY_COVERAGE" = "yes" ]; then cd test; codecov; fi
# Install dependencies using pip # Install dependencies using pip
if [ -z "$TRAVIS_SUDO" -o "$TRAVIS_SUDO" = "false" ] if [ -z "$SCAPY_SUDO" -o "$SCAPY_SUDO" = "false" ]
then then
TRAVIS_SUDO="" SCAPY_SUDO=""
if [ "$TRAVIS_OS_NAME" = "osx" ] if [ "$TRAVIS_OS_NAME" = "osx" ]
then then
PIP_INSTALL_FLAGS="--user" PIP_INSTALL_FLAGS="--user"
fi fi
fi fi
$TRAVIS_SUDO pip install $PIP_INSTALL_FLAGS ecdsa mock $SCAPY_SUDO pip install $PIP_INSTALL_FLAGS ecdsa mock
# Pycrypto 2.7a1 isn't available on PyPi # Pycrypto 2.7a1 isn't available on PyPi
if [ "$TEST_COMBINED_MODES" = "yes" ] if [ "$TEST_COMBINED_MODES" = "yes" ]
...@@ -15,9 +15,15 @@ then ...@@ -15,9 +15,15 @@ then
curl -sL https://github.com/dlitz/pycrypto/archive/v2.7a1.tar.gz | tar xz curl -sL https://github.com/dlitz/pycrypto/archive/v2.7a1.tar.gz | tar xz
cd pycrypto-2.7a1 cd pycrypto-2.7a1
python setup.py build python setup.py build
$TRAVIS_SUDO python setup.py install $SCAPY_SUDO python setup.py install
else else
$TRAVIS_SUDO pip install $PIP_INSTALL_FLAGS pycrypto $SCAPY_SUDO pip install $PIP_INSTALL_FLAGS pycrypto
fi
# Install coverage
if [ "$SCAPY_COVERAGE" = "yes" ]
then
$SCAPY_SUDO pip install $PIP_INSTALL_FLAGS coverage
fi fi
# Install pcap & dnet # Install pcap & dnet
...@@ -25,7 +31,7 @@ if [ ! -z $SCAPY_USE_PCAPDNET ] ...@@ -25,7 +31,7 @@ if [ ! -z $SCAPY_USE_PCAPDNET ]
then then
if [ "$TRAVIS_OS_NAME" = "linux" ] if [ "$TRAVIS_OS_NAME" = "linux" ]
then then
$TRAVIS_SUDO apt-get install python-libpcap python-dumbnet $SCAPY_SUDO apt-get install python-libpcap python-dumbnet
elif [ "$TRAVIS_OS_NAME" = "osx" ] elif [ "$TRAVIS_OS_NAME" = "osx" ]
then then
mkdir -p /Users/travis/Library/Python/2.7/lib/python/site-packages mkdir -p /Users/travis/Library/Python/2.7/lib/python/site-packages
......
# Dump environment variables # Dump environment variables
echo "TRAVIS_SUDO=" $TRAVIS_SUDO echo "SCAPY_SUDO=" $SCAPY_SUDO
echo "TRAVIS_OS_NAME=" $TRAVIS_OS_NAME echo "TRAVIS_OS_NAME=" $TRAVIS_OS_NAME
# Dump Scapy config # Dump Scapy config
python -c "from scapy.all import *; print conf" python -c "from scapy.all import *; print conf"
# Don't run tests that require root privileges # Don't run tests that require root privileges
if [ -z "$TRAVIS_SUDO" -o "$TRAVIS_SUDO" = "false" ] if [ -z "$SCAPY_SUDO" -o "$SCAPY_SUDO" = "false" ]
then then
UT_FLAGS="-K netaccess -K needs_root" UT_FLAGS="-K netaccess -K needs_root"
TRAVIS_SUDO="" SCAPY_SUDO=""
fi fi
# Test AEAD modes in IPsec if available # Test AEAD modes in IPsec if available
...@@ -23,6 +23,22 @@ for _path in /sbin /usr/sbin /usr/local/sbin; do ...@@ -23,6 +23,22 @@ for _path in /sbin /usr/sbin /usr/local/sbin; do
[ -d "$_path" ] && echo "$PATH" | grep -qvE "(^|:)$_path(:|$)" && export PATH="$PATH:$_path" [ -d "$_path" ] && echo "$PATH" | grep -qvE "(^|:)$_path(:|$)" && export PATH="$PATH:$_path"
done done
# Create a fake Python executable
if [ "$SCAPY_COVERAGE" = "yes" ]
then
echo '#!/bin/bash' > test/python
echo '[ "$*" = "--version" ] && echo "Python 2 - fake version string"' >> test/python
echo '[ "$*" != "--version" ] && coverage run -a $*' >> test/python
chmod +x test/python
PATH=.:$PATH
# Copy the fake Python interpreter to bypass /etc/sudoers rules on Ubuntu
if [ "$SCAPY_SUDO" = "sudo" ]
then
$SCAPY_SUDO cp test/python /usr/local/sbin/
fi
fi
# Do we have tcpdump? # Do we have tcpdump?
which tcpdump >/dev/null 2>&1 || UT_FLAGS+=" -K tcpdump" which tcpdump >/dev/null 2>&1 || UT_FLAGS+=" -K tcpdump"
...@@ -36,7 +52,7 @@ if [ "$TRAVIS_OS_NAME" = "osx" ] ...@@ -36,7 +52,7 @@ if [ "$TRAVIS_OS_NAME" = "osx" ]
then then
if [ -z $SCAPY_USE_PCAPDNET ] if [ -z $SCAPY_USE_PCAPDNET ]
then then
$TRAVIS_SUDO ./run_tests -q -F -t bpf.uts $UT_FLAGS || exit $? $SCAPY_SUDO ./run_tests -q -F -t bpf.uts $UT_FLAGS || exit $?
fi fi
fi fi
...@@ -46,10 +62,10 @@ do ...@@ -46,10 +62,10 @@ do
then then
continue continue
fi fi
$TRAVIS_SUDO ./run_tests -q -F -t $f $UT_FLAGS || exit $? $SCAPY_SUDO ./run_tests -q -F -t $f $UT_FLAGS || exit $?
done done
for f in ../scapy/contrib/*.uts for f in ../scapy/contrib/*.uts
do do
$TRAVIS_SUDO ./run_tests -f text -t $f $UT_FLAGS -P "load_contrib('$(basename ${f/.uts})')" || exit $? $SCAPY_SUDO ./run_tests -f text -t $f $UT_FLAGS -P "load_contrib('$(basename ${f/.uts})')" || exit $?
done done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment