]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Birdtest: Add default timeout and forking setting
authorPavel Tvrdík <pawel.tvrdik@gmail.cz>
Tue, 17 Mar 2015 10:27:40 +0000 (11:27 +0100)
committerPavel Tvrdík <pawel.tvrdik@gmail.cz>
Tue, 17 Mar 2015 10:27:40 +0000 (11:27 +0100)
birdtest/birdtest.c
birdtest/birdtest.h
lib/heap_test.c
lib/lists_test.c

index 53c31d33015113fbe9640eb0e973482f020fc720..14421fb8e635a17dd8805e192675748da29c31d8 100644 (file)
@@ -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 <santiago@crfreenet.org>
  *     (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)
   {
index 397d22d80bf07ed8661a85c51eb3e79df35d034c..ae70e713f64bb91f1a3f7292563178863f3e5e3d 100644 (file)
@@ -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 <santiago@crfreenet.org>
  *     (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 <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -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_ */
index aaf616bc4f92fa66d6baf9055e377716d57205bf..dc188a626516452c65ad702ea8e876faf1dcb332 100644 (file)
@@ -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 <sys/stat.h>
-#include <fcntl.h>
+#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;
 }
index 866883037dcf4e0ef1bd1c9d96c5c3ecbefc3ad2..4e6d9b1e5873153bebc9d3bde59c94902252e26e 100644 (file)
@@ -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 <sys/stat.h>
-#include <fcntl.h>
+#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;
 }