From: Vincent Bernat Date: Fri, 25 Nov 2016 20:09:15 +0000 (+0100) Subject: tests: use a PCAP file to do some integration tests X-Git-Tag: 0.9.6~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2063390b5c650c269918e7b2b713f8bbae6ea62d;p=thirdparty%2Flldpd.git tests: use a PCAP file to do some integration tests --- 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 00000000..619150dd Binary files /dev/null and b/tests/integration/data/sg200.pcap differ 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("