From 36b250c315ac36a8e82f915ce5c79a29413e53bf Mon Sep 17 00:00:00 2001 From: Marek Vavrusa <marek@vavrusa.com> Date: Tue, 19 Oct 2010 11:36:01 +0200 Subject: [PATCH] Updated template and server unit tests. --- src/tests/server_tests.c | 8 ++++---- src/tests/template_tests.c | 33 +++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/tests/server_tests.c b/src/tests/server_tests.c index d7e3c11da..242731bf5 100644 --- a/src/tests/server_tests.c +++ b/src/tests/server_tests.c @@ -1,8 +1,8 @@ #include "server/server.h" #include "tap_unit.h" -int server_tests_count(int argc, char * argv[]); -int server_tests_run(int argc, char * argv[]); +static int server_tests_count(int argc, char * argv[]); +static int server_tests_run(int argc, char * argv[]); /* * Unit API. @@ -45,7 +45,7 @@ int test_server_destroy(cute_server* s) } /*! API: return number of tests. */ -int server_tests_count(int argc, char * argv[]) +static int server_tests_count(int argc, char * argv[]) { return SERVER_TEST_COUNT + 1; } @@ -56,7 +56,7 @@ static void interrupt_handle(int s) } /*! API: run tests. */ -int server_tests_run(int argc, char * argv[]) +static int server_tests_run(int argc, char * argv[]) { cute_server* server = 0; int ret = 0; diff --git a/src/tests/template_tests.c b/src/tests/template_tests.c index 2dd4bef5b..ca097f439 100644 --- a/src/tests/template_tests.c +++ b/src/tests/template_tests.c @@ -1,20 +1,41 @@ #include "tap_unit.h" +/* This is unit test template. + Implement two mandatory functions below, + name them accordingly and export unit API + via global variable of "unit_api". + + Add the exported variable into the list + "unit_api* tests[]" in src/tests/main.c + + There is no header file, all modules *.c files + are included directly into src/tests/main.c + + */ + /* Unit implementation */ -int TEMPLATE_tests_count(int argc, char *argv[]) + +/*! This helper routine should report number of + * scheduled tests for given parameters. + */ +static int TEMPLATE_tests_count(int argc, char *argv[]) { return 1; } -int TEMPLATE_tests_run(int argc, char *argv[]) +/*! Run all scheduled tests for given parameters. + */ +static int TEMPLATE_tests_run(int argc, char *argv[]) { ok(1 == 1, "dummy test"); return 0; } -/* Exported unit API. */ +/*! Exported unit API for later incorporation. + * Name must be unique for each module. + */ unit_api TEMPLATE_tests_api = { - "TEMPLATE unit", - &TEMPLATE_tests_count, - &TEMPLATE_tests_run + "TEMPLATE unit", //! Unit name + &TEMPLATE_tests_count, //! Count scheduled tests + &TEMPLATE_tests_run //! Run scheduled tests }; -- GitLab