]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
tests: make decode work without libcheck
authorVincent Bernat <vincent@bernat.ch>
Tue, 21 Sep 2021 06:37:39 +0000 (08:37 +0200)
committerVincent Bernat <vincent@bernat.ch>
Tue, 21 Sep 2021 07:47:00 +0000 (09:47 +0200)
tests/Makefile.am
tests/common.h
tests/decode.c
tests/pcap-hdr.h [new file with mode: 0644]

index 5377bbed46cd86fabc1306524fccadd3ce8c1243..ab81425f285bac3058056253a1642c0d9fabdfea 100644 (file)
@@ -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
 
index a3d7e33f0dfc134d1f6a49dd7e7f3f83b87fabf6..03dd5fe5043b3e85716ebc9a9df3f40f60ca7ead 100644 (file)
 #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;
index aefe28fde7a41d1d4b470543916b80c569b486dd..9f75cc65b2ef8853701afaa65af2f5ec35e94768 100644 (file)
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <arpa/inet.h>
-#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 (file)
index 0000000..92de0f0
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef _PCAP_HDR_H
+#define _PCAP_HDR_H
+
+#include <stdint.h>
+
+/* 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