refactor(test): compile tests into single binary
parent
195eb9eb48
commit
5ff788c108
23
Makefile
23
Makefile
|
@ -17,7 +17,7 @@ OBJS_EXAMPLE := $(SRCS_EXAMPLE:%=$(BUILD_DIR)/%.o)
|
|||
|
||||
DEPS := $(SRCS:%=$(BUILD_DIR)/%.d) $(SRCS_TEST:%=$(BUILD_DIR)/%.d)
|
||||
|
||||
BINS_TEST := $(OBJS_TEST:%.c.o=%)
|
||||
BIN_TEST := $(BUILD_DIR)/$(TEST_DIR)/runner
|
||||
BINS_EXAMPLE := $(OBJS_EXAMPLE:%.c.o=%)
|
||||
|
||||
TARGETS_TEST := $(BINS_TEST:%=test-%)
|
||||
|
@ -46,25 +46,18 @@ $(BUILD_DIR)/$(SRC_DIR)/%.c.o: $(SRC_DIR)/%.c
|
|||
|
||||
# =====TESTING=====
|
||||
.PHONY: test
|
||||
test: $(TARGETS_TEST)
|
||||
test: $(BIN_TEST)
|
||||
'./$^'
|
||||
|
||||
.PHONY: test-mem
|
||||
test-mem: $(TARGETS_MEM_TEST)
|
||||
|
||||
.PHONY: $(TARGETS_TEST)
|
||||
$(TARGETS_TEST): test-%: %
|
||||
./$^
|
||||
|
||||
.PHONY: $(TARGETS_MEM_TEST)
|
||||
$(TARGETS_MEM_TEST): test-mem-%: %
|
||||
valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --leak-check=full ./$^
|
||||
test-mem: $(BIN_TEST)
|
||||
valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --leak-check=full './$^'
|
||||
|
||||
.PHONY: build-test
|
||||
build-test: $(BINS_TEST)
|
||||
build-test: $(BIN_TEST)
|
||||
|
||||
$(BINS_TEST): %: %.c.o $(LIB)
|
||||
$(CC) \
|
||||
$^ -o $@
|
||||
$(BIN_TEST): $(OBJS_TEST) $(LIB)
|
||||
$(CC) -o $@ $^ $(_LDFLAGS)
|
||||
|
||||
# Along with the include directory, each test includes $(TEST_DIR) (which
|
||||
# contains the acutest.h header file), and the src directory of the module it's
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,9 @@
|
|||
#define TEST_NO_MAIN
|
||||
#include "acutest.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include "lnm/common.h"
|
||||
#include "lnm/http/route.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "lnm/http/loop.h"
|
||||
|
||||
void test_routing_simple() {
|
||||
lnm_http_router *router;
|
||||
|
@ -101,11 +102,3 @@ void test_routing_nest() {
|
|||
|
||||
lnm_http_router_free(r2);
|
||||
}
|
||||
|
||||
TEST_LIST = {
|
||||
{ "routing simple", test_routing_simple },
|
||||
{ "routing star", test_routing_star },
|
||||
{ "routing merge", test_routing_merge },
|
||||
{ "routing nest", test_routing_nest },
|
||||
{ NULL, NULL }
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
#include "acutest.h"
|
||||
#include "tests.h"
|
||||
|
||||
TEST_LIST = {
|
||||
{ "routing simple", test_routing_simple },
|
||||
{ "routing star", test_routing_star },
|
||||
{ "routing merge", test_routing_merge },
|
||||
{ "routing nest", test_routing_nest },
|
||||
{ NULL, NULL }
|
||||
};
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef TEST_TESTS
|
||||
#define TEST_TESTS
|
||||
|
||||
void test_routing_simple();
|
||||
void test_routing_star();
|
||||
void test_routing_merge();
|
||||
void test_routing_nest();
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue