From 2063390b5c650c269918e7b2b713f8bbae6ea62d Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 25 Nov 2016 21:09:15 +0100 Subject: [PATCH] tests: use a PCAP file to do some integration tests --- tests/ci/install.sh | 3 +- tests/integration/data/sg200.pcap | Bin 0 -> 623 bytes tests/integration/fixtures/programs.py | 1 + tests/integration/test_pcap.py | 63 +++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 tests/integration/data/sg200.pcap create mode 100644 tests/integration/test_pcap.py diff --git a/tests/ci/install.sh b/tests/ci/install.sh index 070ef5f0..f6f9cf8b 100755 --- a/tests/ci/install.sh +++ b/tests/ci/install.sh @@ -19,7 +19,8 @@ case "$(uname -s)" in automake autoconf libtool pkg-config \ libsnmp-dev libxml2-dev libjansson-dev libjson-c-dev \ libevent-dev libreadline-dev libbsd-dev \ - check libc6-dbg libevent-dbg libseccomp-dev + check libc6-dbg libevent-dbg libseccomp-dev \ + libpcap-dev [ $CC != gcc ] || \ sudo apt-get -qqy install gcc-5 # For integration tests diff --git a/tests/integration/data/sg200.pcap b/tests/integration/data/sg200.pcap new file mode 100644 index 0000000000000000000000000000000000000000..619150dda011dab54b0b37660f12698cde480e57 GIT binary patch literal 623 zc-p&ic+)~A1{MYcU}0bcl9OyKB5s`EWpHO=0At36LktXj45lE^afXSV1;S)uW=%I_ zV`8ZI$H^eX&&UkY`;VPLXg4E+KFfbrAcL7noyoPGc_qY zFEu%%L^rskD6u$IlF7t~VVHt{D!^c14KpwztcuN0&p^*Y<ZdcA`{qL_|awf@81VEY%gc~};Z$K3_ HFfafB?>Rlz literal 0 Hc-jL100001 diff --git a/tests/integration/fixtures/programs.py b/tests/integration/fixtures/programs.py index d49fdbcb..8f91db58 100644 --- a/tests/integration/fixtures/programs.py +++ b/tests/integration/fixtures/programs.py @@ -78,6 +78,7 @@ def most_recent(*args): assert len(candidates) > 0 return candidates[0] + libtool_location = most_recent('../../libtool', '../../*/libtool') lldpcli_location = most_recent('../../src/client/lldpcli', diff --git a/tests/integration/test_pcap.py b/tests/integration/test_pcap.py new file mode 100644 index 00000000..1bab1434 --- /dev/null +++ b/tests/integration/test_pcap.py @@ -0,0 +1,63 @@ +import socket +import struct + + +def send_pcap(location, interface): + """Send a PCAP file to the given interface. It is assumed that all + pcap files are little-endian.""" + with open(location, 'rb') as f: + hdr = f.read(24) + magic, major, minor, _, _, _, network = struct.unpack("