From 6317ba089afff3546617d69747c740a5aa6f20b9 Mon Sep 17 00:00:00 2001 From: Guillaume Valadon Date: Mon, 23 May 2016 16:19:25 +0200 Subject: [PATCH] Run unit tests on Linux and OS X - root and non-root --- .travis.yml | 47 +++++++++++++++++++++++++++++++++++--------- .travis/install.sh | 23 ++++++++++++++++++++++ .travis/pylibpcap.rb | 10 ++++++++++ .travis/test.sh | 18 +++++++++++++++++ 4 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 .travis/install.sh create mode 100644 .travis/pylibpcap.rb create mode 100644 .travis/test.sh diff --git a/.travis.yml b/.travis.yml index a7e2c3449..ef6dc9ee2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,42 @@ -sudo: false - language: python -python: - - 2.6 - - 2.7 - - pypy +matrix: + include: + # Run as a regular user + - os: linux + python: 2.6 -install: - - pip install pycrypto + - os: linux + python: 2.7 -script: cd test/; for f in *.uts; do ./run_tests -q -F -t $f -K netaccess || exit $?; done; for f in ../scapy/contrib/*.uts ; do ./run_tests -q -F -t $f -K netaccess -P "load_contrib('$(basename ${f/.uts})')" || exit $?; done + - os: linux + python: pypy + + - os: osx + language: generic + env: + - SCAPY_USE_PCAPDNET=true + + # Run as root + - os: linux + sudo: required + python: 2.7 + env: + - TRAVIS_SUDO=sudo + + - os: linux + sudo: required + python: 2.7 + env: + - TRAVIS_SUDO=sudo + - SCAPY_USE_PCAPDNET=true + + - os: osx + language: generic + env: + - TRAVIS_SUDO=sudo + - SCAPY_USE_PCAPDNET=true + +install: bash .travis/install.sh + +script: bash .travis/test.sh diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100644 index 000000000..447603ba7 --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,23 @@ +# Install dependencies using pip +if [ -z $TRAVIS_SUDO ] && [ "$TRAVIS_OS_NAME" = "osx" ] +then + PIP_INSTALL_FLAGS="--user" +fi +$TRAVIS_SUDO pip install $PIP_INSTALL_FLAGS pycrypto mock + +# Install pcap & dnet +if [ ! -z $SCAPY_USE_PCAPDNET ] +then + if [ "$TRAVIS_OS_NAME" = "linux" ] + then + $TRAVIS_SUDO apt-get install python-pcapy python-dumbnet + elif [ "$TRAVIS_OS_NAME" = "osx" ] + then + mkdir -p /Users/travis/Library/Python/2.7/lib/python/site-packages + echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/travis/Library/Python/2.7/lib/python/site-packages/homebrew.pth + + brew update + brew install --with-python libdnet + brew install .travis/pylibpcap.rb + fi +fi diff --git a/.travis/pylibpcap.rb b/.travis/pylibpcap.rb new file mode 100644 index 000000000..c1104c84c --- /dev/null +++ b/.travis/pylibpcap.rb @@ -0,0 +1,10 @@ +class Pylibpcap