tests/net/bpf: hexdump(3) the packets if compare fails

This commit is contained in:
Gleb Smirnoff
2026-03-04 19:57:59 -08:00
parent 776604651e
commit d4083fb836
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ LIBADD+= nv
PROGS= bpf_multi_read pcap-test
LIBADD.bpf_multi_read+= pcap
CFLAGS.pcap-test.c+= -Wno-cast-align
LIBADD.pcap-test+= pcap
LIBADD.pcap-test+= pcap util
ATF_TESTS_SH= bpf
+5 -1
View File
@@ -31,6 +31,7 @@
#include <netinet/ip.h>
#include <pcap/pcap.h>
#include <fcntl.h>
#include <libutil.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -219,8 +220,11 @@ compare(int argc __unused, char *argv[])
if (p1->caplen != p2->caplen)
errx(1, "packet #%u capture length %u != %u",
cnt, p1->caplen, p2->caplen);
if (memcmp(p1->data, p2->data, p1->caplen) != 0)
if (memcmp(p1->data, p2->data, p1->caplen) != 0) {
hexdump(p1->data, p1->caplen, argv[0], 0);
hexdump(p2->data, p2->caplen, argv[1], 0);
errx(1, "packet #%u payload different", cnt);
}
}
if (p1 != NULL || p2 != NULL)
errx(1, "packet count different");