]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Birdtest: Clean up unit tests from mock-ups
authorPavel Tvrdík <pawel.tvrdik@gmail.cz>
Wed, 5 Aug 2015 10:34:21 +0000 (12:34 +0200)
committerPavel Tvrdík <pawel.tvrdik@gmail.cz>
Wed, 5 Aug 2015 10:36:40 +0000 (12:36 +0200)
13 files changed:
lib/bitops_test.c
lib/buffer_test.c
lib/checksum_test.c
lib/event_test.c
lib/fletcher16_test.c
lib/hash_test.c
lib/ip_test.c
lib/md5_test.c
lib/patmatch_test.c
lib/sha256_test.c
lib/sha512_test.c
lib/slist_test.c
test/birdtest_support.h [deleted file]

index 59c0cd56f6b3afe0ed52498292c49ee98e3d64ad..ac103970b28609452ef27968bce2378c17bf8a48 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "test/birdtest.h"
 #include "bitops.h"
-#include "bitops.c" /* REMOVE ME */
 
 #define MAX_NUM 1000
 #define CHECK_BIT(var,pos) ((var) & (u32)(1<<(pos)))
index 26db522948edf7d42979b863e628a9dde3c7df1e..f9049f3477a70e0f2195dca134a37e24cd16ba21 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <stdlib.h>
+
 #include "test/birdtest.h"
 #include "sysdep/config.h"
 #include "lib/resource.h"
@@ -41,16 +42,11 @@ fill_expected_array(void)
 static void
 init_buffer(void)
 {
-  buffer_pool = NULL;
+  resource_init();
+  buffer_pool = &root_pool;
   BUFFER_INIT(buffer, buffer_pool, MAX_NUM);
 }
 
-static void
-free_buffer(void)
-{
-  free(buffer_pool);
-}
-
 static int
 is_buffer_as_expected(buffer_int *b)
 {
@@ -73,7 +69,6 @@ t_buffer_push(void)
     BUFFER_PUSH(buffer) = expected[i];
   is_buffer_as_expected(&buffer);
 
-  free_buffer();
   return BT_SUCCESS;
 }
 
@@ -102,7 +97,6 @@ t_buffer_pop(void)
     BUFFER_PUSH(buffer) = expected[i];
   is_buffer_as_expected(&buffer);
 
-  free_buffer();
   return BT_SUCCESS;
 }
 
@@ -111,7 +105,7 @@ t_buffer_resize(void)
 {
   int i;
 
-  buffer_pool = NULL;
+  init_buffer();
   BUFFER_INIT(buffer, buffer_pool, 0);
   fill_expected_array();
 
@@ -120,7 +114,6 @@ t_buffer_resize(void)
   is_buffer_as_expected(&buffer);
   bt_assert(buffer.size >= MAX_NUM);
 
-  free_buffer();
   return BT_SUCCESS;
 }
 
@@ -137,7 +130,6 @@ t_buffer_flush(void)
   BUFFER_FLUSH(buffer);
   bt_assert(buffer.used == 0);
 
-  free_buffer();
   return BT_SUCCESS;
 }
 
@@ -153,26 +145,3 @@ main(int argc, char *argv[])
 
   return bt_end();
 }
-
-
-/* Mockup */
-void *
-mb_alloc(pool *UNUSED, uint size) {
-  return (void *) malloc(size);
-};
-
-/* Mockup */
-#define STEP_UP(x) ((x) + (x)/2 + 4)
-#define MIN_(a,b) (((a)<(b))?(a):(b))
-#define MIN(a,b) MIN_(a,b)
-void
-buffer_realloc(void **buf, uint *size, uint need, uint item_size)
-{
-  uint nsize = MIN(*size, need);
-
-  while (nsize < need)
-    nsize = STEP_UP(nsize);
-
-  *buf = realloc(*buf, nsize * item_size);
-  *size = nsize;
-}
index 8306d26298566fdc7084b3dc8f7275bb4850b783..52cecb13ef3295236707f900622102ee1e78a386 100644 (file)
 #include "test/birdtest.h"
 #include "sysdep/config.h"
 #include "lib/null.h"
-
-void bug(const char *msg, ...);
 #include "lib/checksum.h"
-#include "lib/checksum.c" /* REMOVE ME */
 
 #define MAX_NUM 10000
 
@@ -96,14 +93,3 @@ main(int argc, char *argv[])
 
   return bt_end();
 }
-
-/* Mockup */
-void
-bug(const char *msg, ...)
-{
-  va_list argptr;
-  va_start(argptr, msg);
-  vfprintf(stderr, msg, argptr);
-  va_end(argptr);
-  abort();
-}
index a461b92efb2ea1acbf176f87261bbed6eb38c61b..70f05593e277ca15a9b64970e92c874188eaea53 100644 (file)
@@ -8,9 +8,12 @@
 
 
 #include "test/birdtest.h"
-#include "test/birdtest_support.h"     /* REMOVE ME */
-
 #include "lib/event.h"
+#include "conf/conf.h"
+#include "nest/locks.h"
+#include "lib/unix.h"
+#include "nest/iface.h"
+#include "nest/route.h"
 
 #define MAX_NUM 4
 
@@ -29,7 +32,7 @@ static void event_hook_3(void *data) { event_hook_body(3); }
 
 #define schedule_event(num)                    \
     do {                                       \
-      struct event *event_##num = ev_new(pool); \
+      struct event *event_##num = ev_new(&root_pool); \
       event_##num->hook = event_hook_##num;    \
       ev_schedule(event_##num);                        \
     } while (0)
@@ -49,8 +52,14 @@ t_ev_run_list(void)
   int i;
 
   resource_init();
-  init_list(&global_event_list);
-  struct pool *pool = rp_new(&root_pool, "Test pool");
+  olock_init();
+  io_init();
+  rt_init();
+  if_init();
+  roa_init();
+  config_init();
+  config = config_alloc("");
+
   init_event_check_points();
 
   schedule_event(1);
index f9c5b4c7e5f0e8d35b38ad84532a15e6ed76ebdb..905e23f2658d1ec7f303bf047280092627469969 100644 (file)
@@ -1,15 +1,12 @@
 /*
  *     BIRD Library -- Fletcher-16 checksum Tests
  *
- *     (c) 2015 Ondrej Zajicek <santiago@crfreenet.org>
  *     (c) 2015 CZ.NIC z.s.p.o.
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
 
 #include "test/birdtest.h"
-#include "test/birdtest_support.h"     /* REMOVE ME */
-
 #include "lib/fletcher16.h"
 
 struct in {
index e6412431e456786fc5be8eb26d0e217b7cad47c0..86d37174c57651c0a6f5b17acd541f558a64f681 100644 (file)
@@ -9,9 +9,8 @@
 #undef LOCAL_DEBUG
 
 #include "test/birdtest.h"
-#include "test/birdtest_support.h"     /* REMOVE ME */
-
 #include "lib/hash.h"
+#include "nest/bird.h"
 
 struct test_node {
   struct test_node *next;      /* Hash chain */
index 90ce3adeadae667e09691785817e2bfbbada9135..fe1d0ac30de1f8ad03cbf7e46a95b4a7b60a35b1 100644 (file)
@@ -7,8 +7,6 @@
  */
 
 #include "test/birdtest.h"
-#include "test/birdtest_support.h"     /* REMOVE ME */
-
 #include "lib/ip.h"
 
 #define IP4_MAX_LEN    16
index 700c324bb9a5495bfa94cdc3f9df6e16a39c942d..5ffbd05bf0f3fef5bfe51b97930ef275e2e78d22 100644 (file)
@@ -11,7 +11,6 @@
 #include "test/birdtest.h"
 #include "sysdep/config.h"
 #include "lib/md5.h"
-#include "lib/md5.c" /* REMOVE ME */
 
 static void
 get_md5(const char *str, char (*out_hash)[MD5_HEX_SIZE])
index 2e781d4944dfd99ab694c27217a03795c76870fd..9321768200d96189cd1f1e4b0fe3da8304128f8a 100644 (file)
@@ -7,9 +7,7 @@
  */
 
 #include "test/birdtest.h"
-#include "test/birdtest_support.h"     /* REMOVE ME */
-
-#include "lib/patmatch.c"              /* REMOVE ME */
+#include "lib/string.h"
 
 #define MATCH          1
 #define NOMATCH                0
index 4abf246c41ecb3047e2ec14794235310c72b8c5e..05e0b2c6fdb559bc6d1f1e27dcff7f73c972ea48 100644 (file)
@@ -9,10 +9,8 @@
 #include <stdlib.h>
 
 #include "test/birdtest.h"
-#include "test/birdtest_support.h"
 #include "sysdep/config.h"
 #include "lib/sha256.h"
-#include "lib/sha256.c" /* REMOVE ME */
 
 
 static void
index c059ca2b266f2ad7429721bcfb1b8eddab3d40db..9983d6bd64ae455a7a218054cbfc3216032e9bb2 100644 (file)
@@ -9,10 +9,8 @@
 #include <stdlib.h>
 
 #include "test/birdtest.h"
-#include "test/birdtest_support.h"
 #include "sysdep/config.h"
 #include "lib/sha512.h"
-#include "lib/sha512.c" /* REMOVE ME */
 
 static void
 byte_to_hex(char *out, const byte *in, uint len)
index 5c818962778306aed1a19367fdc40741bdfead01..b1ce080dc138e71ea5ea220417370e9a590b5d6e 100644 (file)
@@ -7,10 +7,8 @@
  */
 
 #include "test/birdtest.h"
-#include "test/birdtest_support.h"
-
 #include "lib/slists.h"
-#include "lib/slists.c"
+#include "lib/resource.h"
 
 #define MAX_NUM 1000
 
diff --git a/test/birdtest_support.h b/test/birdtest_support.h
deleted file mode 100644 (file)
index 8fb76fe..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "sysdep/config.h"
-#include "lib/event.c"                 /* REMOVE ME */
-#include "lib/ip.c"            /* REMOVE ME */
-#include "lib/resource.c"      /* REMOVE ME */
-#include "lib/printf.c"                /* REMOVE ME */
-#include "lib/xmalloc.c"       /* REMOVE ME */
-#include "lib/bitops.c"                /* REMOVE ME */
-
-#define bug(msg, ...)          debug("BUG: " msg, ##__VA_ARGS__)
-
-void
-debug(const char *msg, ...)
-{
-  va_list argptr;
-  va_start(argptr, msg);
-  vfprintf(stderr, msg, argptr);
-  va_end(argptr);
-};
-
-void
-die(const char *msg, ...)
-{
-  va_list argptr;
-  va_start(argptr, msg);
-  vfprintf(stderr, msg, argptr);
-  va_end(argptr);
-  exit(3);
-};
-
-void
-io_log_event(void *hook, void *data)
-{
-  bt_debug("This is io_log_event mockup. \n");
-};