Skip to content

Commit b1a69b9

Browse files
committed
Restructure build system into multiple directories.
This additionally adds a unit test for #1.
1 parent 7d7b7df commit b1a69b9

12 files changed

Lines changed: 218 additions & 108 deletions

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
/m4/ltversion.m4
2121
/m4/lt~obsolete.m4
2222
/missing
23-
/t/test_*
24-
!/t/test_*.*
2523

2624
.deps/
2725
.dirstamp

Makefile.am

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,6 @@
11
ACLOCAL_AMFLAGS = -I m4
22

3-
lib_LTLIBRARIES = libcurvecpr.la
4-
5-
libcurvecpr_la_CPPFLAGS = -I$(top_srcdir)/include
6-
libcurvecpr_la_LDFLAGS = -version-info $(CURVECPR_LIBRARY_VERSION)
7-
8-
libcurvecpr_la_SOURCES = \
9-
lib/bytes.c \
10-
lib/chicago.c \
11-
lib/client.c \
12-
lib/client_recv.c \
13-
lib/client_send.c \
14-
lib/messager.c \
15-
lib/server.c \
16-
lib/server_recv.c \
17-
lib/server_send.c \
18-
lib/session.c \
19-
lib/util.c
20-
21-
curvecprincludedir = $(includedir)/curvecpr
22-
curvecprinclude_HEADERS = \
23-
include/block.h \
24-
include/bytes.h \
25-
include/chicago.h \
26-
include/client.h \
27-
include/messager.h \
28-
include/packet.h \
29-
include/server.h \
30-
include/session.h \
31-
include/util.h
32-
33-
check_PROGRAMS =
34-
35-
check_PROGRAMS += t/test_messager
36-
t_test_messager_SOURCES = t/test_messager.c
37-
t_test_messager_CPPFLAGS = -I$(top_srcdir)/include
38-
t_test_messager_CFLAGS = @CHECK_CFLAGS@
39-
t_test_messager_LDADD = $(top_builddir)/libcurvecpr.la @CHECK_LIBS@
40-
41-
TESTS = $(check_PROGRAMS)
3+
SUBDIRS = include lib t
424

435
pkgconfigdir = $(libdir)/pkgconfig
446
pkgconfig_DATA = libcurvecpr.pc

configure.ac

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,11 @@ AX_APPEND_COMPILE_FLAGS([ dnl
6161
AX_APPEND_LINK_FLAGS([-Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack], [], [$CCHECKFLAGS])
6262

6363
# Done!
64-
AC_CONFIG_FILES([Makefile libcurvecpr.pc])
64+
AC_CONFIG_FILES([
65+
Makefile
66+
include/Makefile
67+
lib/Makefile
68+
t/Makefile
69+
libcurvecpr.pc
70+
])
6571
AC_OUTPUT

include/Makefile.am

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
curvecprincludedir = $(includedir)/curvecpr
2+
curvecprinclude_HEADERS = \
3+
block.h \
4+
bytes.h \
5+
chicago.h \
6+
client.h \
7+
messager.h \
8+
packet.h \
9+
server.h \
10+
session.h \
11+
util.h

lib/Makefile.am

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
lib_LTLIBRARIES = libcurvecpr.la
2+
3+
libcurvecpr_la_CPPFLAGS = -I$(top_srcdir)/include
4+
libcurvecpr_la_LDFLAGS = -version-info $(CURVECPR_LIBRARY_VERSION)
5+
libcurvecpr_la_SOURCES = \
6+
bytes.c \
7+
chicago.c \
8+
client.c \
9+
client_recv.c \
10+
client_send.c \
11+
messager.c \
12+
server.c \
13+
server_recv.c \
14+
server_send.c \
15+
session.c \
16+
util.c

t/Makefile.am

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/t
2+
AM_CFLAGS = @CHECK_CFLAGS@
3+
LDADD = $(top_builddir)/lib/libcurvecpr.la @CHECK_LIBS@
4+
5+
check_PROGRAMS =
6+
7+
check_PROGRAMS += messager/test_new_configures_object
8+
messager_test_new_configures_object_SOURCES = messager/test_new_configures_object.c
9+
10+
check_PROGRAMS += messager/test_recv_requests_removal_from_sendmarkq
11+
messager_test_recv_requests_removal_from_sendmarkq_SOURCES = messager/test_recv_requests_removal_from_sendmarkq.c
12+
13+
check_PROGRAMS += messager/test_send_with_1_failure_moves_message_from_sendq
14+
messager_test_send_with_1_failure_moves_message_from_sendq_SOURCES = messager/test_send_with_1_failure_moves_message_from_sendq.c
15+
16+
TESTS = $(check_PROGRAMS)

t/check_extras.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <check.h>
2+
3+
#ifndef RUN_TEST
4+
#define RUN_TEST(fn) \
5+
int main (void) \
6+
{ \
7+
Suite *s = suite_create(#fn); \
8+
\
9+
TCase *tc = tcase_create(#fn); \
10+
tcase_add_test(tc, (fn)); \
11+
suite_add_tcase(s, tc); \
12+
\
13+
SRunner *sr = srunner_create(s); \
14+
srunner_run_all(sr, CK_NORMAL); \
15+
int failed = srunner_ntests_failed(sr); \
16+
srunner_free(sr); \
17+
\
18+
return failed ? 1 : 0; \
19+
}
20+
#endif

t/messager/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/test_new_configures_object
2+
/test_recv_requests_removal_from_sendmarkq
3+
/test_send_with_1_failure_moves_message_from_sendq
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <check.h>
2+
#include <check_extras.h>
3+
4+
#include "messager.h"
5+
6+
static char static_priv[] = "Hello!";
7+
8+
START_TEST (test_new_configures_object)
9+
{
10+
struct curvecpr_messager messager;
11+
struct curvecpr_messager_cf cf = { .priv = static_priv };
12+
13+
curvecpr_messager_new(&messager, &cf, 1);
14+
15+
fail_unless(memcmp(static_priv, messager.cf.priv, sizeof(static_priv)) == 0);
16+
fail_unless(messager.my_maximum_send_bytes == 512);
17+
}
18+
END_TEST
19+
20+
RUN_TEST (test_new_configures_object)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <check.h>
2+
#include <check_extras.h>
3+
4+
#include "bytes.h"
5+
#include "messager.h"
6+
7+
static int t_sendmarkq_remove_range (struct curvecpr_messager *messager, unsigned long long start, unsigned long long end)
8+
{
9+
fail_unless(start == 0);
10+
fail_unless(end == 1234);
11+
12+
return 0;
13+
}
14+
15+
START_TEST (test_recv_requests_removal_from_sendmarkq)
16+
{
17+
struct curvecpr_messager messager;
18+
struct curvecpr_messager_cf cf = {
19+
.ops = {
20+
.sendmarkq_remove_range = t_sendmarkq_remove_range
21+
}
22+
};
23+
unsigned char buf[1024] = { 0 };
24+
size_t len = 128;
25+
26+
curvecpr_bytes_pack_uint64(buf + 8, 1234L);
27+
28+
curvecpr_messager_new(&messager, &cf, 1);
29+
curvecpr_messager_recv(&messager, buf, len);
30+
}
31+
END_TEST
32+
33+
RUN_TEST (test_recv_requests_removal_from_sendmarkq)

0 commit comments

Comments
 (0)