Skip to content
Snippets Groups Projects
Commit 5a7c47fc authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

Updated unittest for easier unit plugging.

parent e5dbb06d
No related branches found
No related tags found
No related merge requests found
......@@ -29,10 +29,16 @@ src/zone/zone-node.c
src/zone/zone-node.h
src/zone/zone-parser.c
src/zone/zone-parser.h
src/tests/libtap/tap.c
src/tests/libtap/tap.h
src/tests/main.c
src/tests/tests.c
src/tests/tests.h
src/tests/cuckoo-test.c
src/tests/cuckoo-test.h
src/tests/server_tests.c
src/tests/tap_unit.h
src/tests/template_tests.c
src/other/log.h
src/other/log.c
src/other/debug.h
......
......@@ -36,11 +36,11 @@ Makefile.depend:
# cutedns
cutedns: Makefile.depend $(OBJS) $(SRC_DIRS)main.c
# @echo "$(COL_WHITE)Linking... $(COL_YELLOW)${BIN_DIR}$@$(COL_END) <-- $(COL_CYAN)$(OBJS) $(SRC_DIRS)main.c$(COL_END)"
@echo "$(COL_WHITE)Linking... $(COL_YELLOW)${BIN_DIR}$@$(COL_END) <-- $(COL_CYAN)$(OBJS) $(SRC_DIRS)main.c$(COL_END)"
@$(CC) $(CFLAGS) $(addprefix -I ,$(INC_DIRS)) $(LDFLAGS) $(OBJS) $(SRC_DIRS)main.c -o ${BIN_DIR}$@
unittests: Makefile.depend cutedns $(OBJS) $(TESTS_FILES)
# @echo "$(COL_WHITE)Linking... $(COL_YELLOW)${BIN_DIR}$@$(COL_END) <-- $(COL_CYAN)$(OBJS) $(TESTS_FILES)$(COL_END)"
@echo "$(COL_WHITE)Linking... $(COL_YELLOW)${BIN_DIR}$@$(COL_END) <-- $(COL_CYAN)$(OBJS) $(TESTS_FILES)$(COL_END)"
@$(CC) $(CFLAGS) $(addprefix -I ,$(INC_DIRS)) $(LDFLAGS) $(OBJS) $(TESTS_FILES) -o ${BIN_DIR}$@
test: unittests
......
......@@ -7,14 +7,29 @@
// Run all loaded units
int main(int argc, char * argv[])
{
// Build test set
unit_api* tests[] = {
&server_tests_api, //! Server unit
NULL
};
// Plan number of tests
int id = 0;
int test_count = 0;
test_count += server_tests_api.count(argc, argv);
while(tests[id] != NULL) {
test_count += tests[id]->count(argc, argv);
++id;
}
plan(test_count);
// Run tests
note("Testing unit: %s ...", server_tests_api.name);
server_tests_api.run(argc, argv);
id = 0;
while(tests[id] != NULL) {
note("Testing unit: %s ...", tests[id]->name);
tests[id]->run(argc, argv);
++id;
}
// Evaluate
return exit_status();
......
#include "tap_unit.h"
/* Unit implementation */
int TEMPLATE_tests_count(int argc, char *argv[])
{
return 1;
}
int TEMPLATE_tests_run(int argc, char *argv[])
{
ok(1 == 1, "dummy test");
return 0;
}
/* Exported unit API. */
unit_api TEMPLATE_tests_api = {
"TEMPLATE unit",
&TEMPLATE_tests_count,
&TEMPLATE_tests_run
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment