diff --git a/birdtest/birdtest.c b/birdtest/birdtest.c index 53c31d33..14421fb8 100644 --- a/birdtest/birdtest.c +++ b/birdtest/birdtest.c @@ -1,5 +1,5 @@ /* - * BIRD Internet Routing Daemon -- BIRD Unit Testing Framework + * BIRD Internet Routing Daemon -- BIRD Unit Testing Framework (BIRD Test) * * (c) 2015 Ondrej Zajicek * (c) 2015 CZ.NIC z.s.p.o. @@ -91,7 +91,7 @@ bt_init(int argc, char *argv[]) } void -bt_test_case2(int (*test_fn)(void), const char *test_id, const char *dsc, int forked, int timeout) +bt_test_case5(int (*test_fn)(void), const char *test_id, const char *dsc, int forked, int timeout) { if (list_tests) { diff --git a/birdtest/birdtest.h b/birdtest/birdtest.h index 397d22d8..ae70e713 100644 --- a/birdtest/birdtest.h +++ b/birdtest/birdtest.h @@ -1,5 +1,5 @@ /* - * BIRD Internet Routing Daemon -- BIRD Unit Testing Framework + * BIRD Internet Routing Daemon -- BIRD Unit Testing Framework (BIRD Test) * * (c) 2015 Ondrej Zajicek * (c) 2015 CZ.NIC z.s.p.o. @@ -7,6 +7,9 @@ * Can be freely distributed and used under the terms of the GNU GPL. */ +#ifndef _BIRDTEST_H_ +#define _BIRDTEST_H_ + #include #include #include @@ -18,14 +21,20 @@ extern int bt_verbose; extern const char *bt_filename; extern const char *bt_test_id; -void bt_init(int argc, char **argv); -void bt_test_case2(int (*fn)(void), const char *id, const char *dsc, int forked, int timeout); +void bt_init(int argc, char *argv[]); +void bt_test_case5(int (*fn)(void), const char *id, const char *dsc, int forked, int timeout); #define BT_SUCCESS 0 #define BT_FAILURE 1 -#define bt_test_case(fn,dsc,f,t) \ - bt_test_case2(fn, #fn, dsc, f, t) +#define BT_DEFAULT_TIMEOUT 5 +#define BT_DEFAULT_FORKING 1 + +#define bt_test_case(fn,dsc) \ + bt_test_case4(fn, dsc, BT_DEFAULT_FORKING, BT_DEFAULT_TIMEOUT) + +#define bt_test_case4(fn,dsc,f,t) \ + bt_test_case5(fn, #fn, dsc, f, t) #define bt_log(format, ...) \ fprintf(stderr, "%s: " format "\n", bt_filename, ##__VA_ARGS__) @@ -50,3 +59,5 @@ void bt_test_case2(int (*fn)(void), const char *id, const char *dsc, int forked, #define bt_syscall(test,format, ...) \ do { if (test) { bt_log(format ": %s", ##__VA_ARGS__, strerror(errno)); exit(3); } } while (0) + +#endif /* _BIRDTEST_H_ */ diff --git a/lib/heap_test.c b/lib/heap_test.c index aaf616bc..dc188a62 100644 --- a/lib/heap_test.c +++ b/lib/heap_test.c @@ -1,7 +1,13 @@ -#include "lib/heap.h" +/* + * BIRD Library -- Universal Heap Macros Tests + * + * (c) 2015 CZ.NIC z.s.p.o. + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + #include "birdtest.h" -#include -#include +#include "lib/heap.h" #define MAX_NUM 1000 #define SPECIAL_KEY -3213 @@ -144,10 +150,10 @@ main(int argc, char *argv[]) { bt_init(argc, argv); - bt_test_case(t_heap_insert, "Test Inserting", 1, 5); - bt_test_case(t_heap_increase_decrease, "Test Increasing/Decreasing", 1, 5); - bt_test_case(t_heap_delete, "Test Deleting", 1, 5); - bt_test_case(t_heap_0, "Is heap[0] unused?", 1, 5); + bt_test_case(t_heap_insert, "Test Inserting"); + bt_test_case(t_heap_increase_decrease, "Test Increasing/Decreasing"); + bt_test_case(t_heap_delete, "Test Deleting"); + bt_test_case(t_heap_0, "Is heap[0] unused?"); return 0; } diff --git a/lib/lists_test.c b/lib/lists_test.c index 86688303..4e6d9b1e 100644 --- a/lib/lists_test.c +++ b/lib/lists_test.c @@ -1,7 +1,13 @@ -#include "lib/lists.h" +/* + * BIRD Library -- Linked Lists Tests + * + * (c) 2015 CZ.NIC z.s.p.o. + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + #include "birdtest.h" -#include -#include +#include "lib/lists.h" #define MAX_NUM 1000 @@ -270,12 +276,12 @@ main(int argc, char *argv[]) { bt_init(argc, argv); - bt_test_case(t_add_tail, "Adding nodes to tail of list", 1, 5); - bt_test_case(t_add_head, "Adding nodes to head of list", 1, 5); - bt_test_case(t_insert_node, "Inserting nodes to list", 1, 5); - bt_test_case(t_remove_node, "Removing nodes from list", 1, 5); - bt_test_case(t_replace_node, "Replacing nodes in list", 1, 5); - bt_test_case(t_add_tail_list, "At the tail of a list adding the another list", 1, 5); + bt_test_case(t_add_tail, "Adding nodes to tail of list"); + bt_test_case(t_add_head, "Adding nodes to head of list"); + bt_test_case(t_insert_node, "Inserting nodes to list"); + bt_test_case(t_remove_node, "Removing nodes from list"); + bt_test_case(t_replace_node, "Replacing nodes in list"); + bt_test_case(t_add_tail_list, "At the tail of a list adding the another list"); return 0; }