Skip to content

Commit

Permalink
FIFO -> linked list + socket.c test
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubGrajciar committed Jun 27, 2017
1 parent c436306 commit eae6659
Show file tree
Hide file tree
Showing 18 changed files with 502 additions and 1,572 deletions.
32 changes: 9 additions & 23 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,18 @@ AUTOMAKE_OPTIONS = foreign subdir-objects
ACLOCAL_AMFLAGS = -I m4

#
# utils lib
# unit_test
#
libutils_la_SOURCES = src/vector/vec.c src/fifo/fifo.c
libutils_la_CPPFLAGS = $(AM_CPPFLAGS) -Isrc/vector -Isrc/fifo


#
# utils test
#
utils_test_SOURCES = test/utils_test.c test/vec_test.c test/fifo_test.c
utils_test_LDADD = libutils.la
utils_test_CPPFLAGS = $(AM_CPPFLAGS) -Isrc/vector -Isrc/fifo -Itest

#
# perf test
#
perf_test_SOURCES = test/perform/pt.c
perf_test_LDADD = libutils.la
perf_test_CPPFLAGS = $(AM_CPPFLAGS) -Isrc/vector -Isrc/fifo -Itest/perform
unit_test_SOURCES = test/socket_test.c test/unit_test.c src/socket.c
# macro MEMIF_UNIT_TEST -> compile functions without static keyword
# and declare them in header files, so they can be called from unit tests
unit_test_CPPFLAGS = $(AM_CPPFLAGS) -Itest -Isrc -DMEMIF_UNIT_TEST

#
# main lib
#
libmemif_la_SOURCES = src/main.c src/socket.c
libmemif_la_LIBADD = libutils.la
libmemif_la_CPPFLAGS = $(AM_CPPFLAGS) -Isrc -Isrc/vector -Isrc/fifo
libmemif_la_CPPFLAGS = $(AM_CPPFLAGS) -Isrc

#
# ICMP responder example
Expand All @@ -50,12 +36,12 @@ icmp_responder_SOURCES = examples/icmp_responder/main.c
icmp_responder_LDADD = libmemif.la
icmp_responder_CPPFLAGS = $(AM_CPPFLAGS) -Isrc

noinst_PROGRAMS = icmp_responder perf_test
noinst_PROGRAMS = icmp_responder

check_PROGRAMS = utils_test
check_PROGRAMS = unit_test

include_HEADERS = src/libmemif.h

lib_LTLIBRARIES = libutils.la libmemif.la
lib_LTLIBRARIES = libmemif.la

TESTS = $(check_PROGRAMS)
68 changes: 0 additions & 68 deletions src/fifo/fifo.c

This file was deleted.

53 changes: 0 additions & 53 deletions src/fifo/fifo.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/libmemif.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ int memif_control_fd_handler (memif_conn_handle_t conn, int fd);
/* disconnect session (free memory, close file descriptors, unmap shared memory) */
int memif_disconnect (memif_conn_handle_t conn);

#endif
#endif /* _LIBMEMIF_H_ */
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <stdint.h>

/* memif protocol msg, ring and descriptor definitions */
#include <memif_proto.h>
#include <memif.h>
/* memif api */
#include <libmemif.h>
/* socket messaging functions */
Expand Down
15 changes: 9 additions & 6 deletions src/memif_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <stdint.h>
#include <inttypes.h>
#include <limits.h>

#include <libmemif.h>
#include <fifo.h>

#define MEMIF_DEFAULT_SOCKET_DIR "/run/vpp"
#define MEMIF_DEFAULT_SOCKET_FILENAME "memif.sock"
Expand Down Expand Up @@ -59,7 +61,7 @@
#else
#define DBG(...)
#define DBG_UNIX(...)
#endif
#endif /* MEMIF_DEBUG */

#define error_return_unix(...) do { \
DBG_UNIX(__VA_ARGS__); \
Expand Down Expand Up @@ -92,11 +94,12 @@ typedef struct
uint64_t int_count;
} memif_queue_t;

typedef struct
typedef struct memif_msg_queue_elt
{
memif_msg_t msg;
int fd;
} memif_msg_fifo_elt_t;
struct memif_msg_queue_elt *next;
} memif_msg_queue_elt_t;

struct memif_connection;

Expand All @@ -114,7 +117,7 @@ typedef struct memif_connection
memif_fn *write_fn, *read_fn, *error_fn;

/* connection message queue */
memif_fifo_t msg_queue;
memif_msg_queue_elt_t *msg_queue;

uint8_t remote_if_name[32];
uint8_t remote_name[32];
Expand Down Expand Up @@ -169,4 +172,4 @@ memif_get_buffer (memif_connection_t *conn, memif_ring_t *ring, uint16_t index)
#define F_SEAL_GROW 0x0004 /* prevent file from growing */
#define F_SEAL_WRITE 0x0008 /* prevent writes */

#endif
#endif /* _MEMIF_PRIVATE_H_ */
Loading

0 comments on commit eae6659

Please sign in to comment.