From 837d5d19d514b9e6472415d9cd421382d61a176d Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 21 Sep 2021 08:37:39 +0200 Subject: [PATCH] tests: make decode work without libcheck --- tests/Makefile.am | 33 ++++++++++++++++++++------------- tests/common.h | 20 +------------------- tests/decode.c | 5 ++--- tests/pcap-hdr.h | 25 +++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 35 deletions(-) create mode 100644 tests/pcap-hdr.h diff --git a/tests/Makefile.am b/tests/Makefile.am index 5377bbed..ab81425f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,15 +2,26 @@ AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) AM_CPPFLAGS = $(LLDP_CPPFLAGS) AM_LDFLAGS = $(LLDP_LDFLAGS) $(LLDP_BIN_LDFLAGS) -if HAVE_CHECK +check_PROGRAMS = decode + +decode_SOURCES = decode.c \ + $(top_srcdir)/src/daemon/lldpd.h \ + pcap-hdr.h -TESTS = check_marshal check_pattern check_bitmap check_fixedpoint \ - check_lldp check_cdp check_sonmp check_edp -AM_CFLAGS += @check_CFLAGS@ LDADD = $(top_builddir)/src/daemon/liblldpd.la @check_LIBS@ @libevent_LDFLAGS@ if ENABLE_SYSTEMTAP LDADD += $(top_builddir)/src/daemon/probes.o endif +if USE_SNMP +LDADD += @NETSNMP_LIBS@ +endif + +if HAVE_CHECK + +TESTS = check_marshal check_pattern check_bitmap check_fixedpoint \ + check_lldp check_cdp check_sonmp check_edp +AM_CFLAGS += @check_CFLAGS@ +LDADD += @check_LIBS@ check_marshal_SOURCES = check_marshal.c \ $(top_srcdir)/src/marshal.h \ @@ -24,19 +35,19 @@ check_bitmap_SOURCES = check_bitmap.c \ check_lldp_SOURCES = check_lldp.c \ $(top_srcdir)/src/daemon/lldpd.h \ - common.h common.c check-compat.h + common.h common.c check-compat.h pcap-hdr.h check_cdp_SOURCES = check_cdp.c \ $(top_srcdir)/src/daemon/lldpd.h \ - common.h common.c check-compat.h + common.h common.c check-compat.h pcap-hdr.h check_sonmp_SOURCES = check_sonmp.c \ $(top_srcdir)/src/daemon/lldpd.h \ - common.h common.c check-compat.h + common.h common.c check-compat.h pcap-hdr.h check_edp_SOURCES = check_edp.c \ $(top_srcdir)/src/daemon/lldpd.h \ - common.h common.c check-compat.h + common.h common.c check-compat.h pcap-hdr.h check_fixedpoint_SOURCES = check_fixedpoint.c check_fixedpoint_LDADD = $(top_builddir)/src/lib/libfixedpoint.la $(LDADD) @@ -46,13 +57,9 @@ TESTS += check_snmp check_snmp_SOURCES = check_snmp.c \ $(top_srcdir)/src/daemon/lldpd.h \ $(top_srcdir)/src/daemon/agent.h -LDADD += @NETSNMP_LIBS@ endif -check_PROGRAMS = $(TESTS) decode -decode_SOURCES = decode.c \ - $(top_srcdir)/src/daemon/lldpd.h \ - common.h common.c +check_PROGRAMS += $(TESTS) endif diff --git a/tests/common.h b/tests/common.h index a3d7e33f..03dd5fe5 100644 --- a/tests/common.h +++ b/tests/common.h @@ -19,27 +19,9 @@ #define _COMMON_H #include "check-compat.h" +#include "pcap-hdr.h" #include "../src/daemon/lldpd.h" -/* See: - * http://wiki.wireshark.org/Development/LibpcapFileFormat - */ -struct pcap_hdr { - u_int32_t magic_number; /* magic number */ - u_int16_t version_major; /* major version number */ - u_int16_t version_minor; /* minor version number */ - u_int32_t thiszone; /* GMT to local correction */ - u_int32_t sigfigs; /* accuracy of timestamps */ - u_int32_t snaplen; /* max length of captured packets, in octets */ - u_int32_t network; /* data link type */ -}; -struct pcaprec_hdr { - u_int32_t ts_sec; /* timestamp seconds */ - u_int32_t ts_usec; /* timestamp microseconds */ - u_int32_t incl_len; /* number of octets of packet saved in file */ - u_int32_t orig_len; /* actual length of packet */ -}; - struct packet { TAILQ_ENTRY(packet) next; int size; diff --git a/tests/decode.c b/tests/decode.c index aefe28fd..9f75cc65 100644 --- a/tests/decode.c +++ b/tests/decode.c @@ -22,12 +22,11 @@ #include #include #include -#include "common.h" +#include "pcap-hdr.h" +#include "../src/daemon/lldpd.h" #define BUFSIZE 2000 -char filenameprefix[] = "decode"; - static void usage(void) { diff --git a/tests/pcap-hdr.h b/tests/pcap-hdr.h new file mode 100644 index 00000000..92de0f0f --- /dev/null +++ b/tests/pcap-hdr.h @@ -0,0 +1,25 @@ +#ifndef _PCAP_HDR_H +#define _PCAP_HDR_H + +#include + +/* See: + * http://wiki.wireshark.org/Development/LibpcapFileFormat + */ +struct pcap_hdr { + uint32_t magic_number; /* magic number */ + uint16_t version_major; /* major version number */ + uint16_t version_minor; /* minor version number */ + uint32_t thiszone; /* GMT to local correction */ + uint32_t sigfigs; /* accuracy of timestamps */ + uint32_t snaplen; /* max length of captured packets, in octets */ + uint32_t network; /* data link type */ +}; +struct pcaprec_hdr { + uint32_t ts_sec; /* timestamp seconds */ + uint32_t ts_usec; /* timestamp microseconds */ + uint32_t incl_len; /* number of octets of packet saved in file */ + uint32_t orig_len; /* actual length of packet */ +}; + +#endif -- 2.39.5