Skip to content

Commit

Permalink
tests: make decode work without libcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentbernat committed Sep 21, 2021
1 parent 29203ab commit 837d5d1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 35 deletions.
33 changes: 20 additions & 13 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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)
Expand All @@ -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

Expand Down
20 changes: 1 addition & 19 deletions tests/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions tests/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
#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)
{
Expand Down
25 changes: 25 additions & 0 deletions tests/pcap-hdr.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 837d5d1

Please sign in to comment.