Commit e0176f26 authored by Pavel Tvrdík's avatar Pavel Tvrdík
Browse files

Birdtest: Clean up unit tests from mock-ups

parent 856250c2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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)))
+4 −35
Original line number Diff line number Diff line
@@ -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;
}
+0 −14
Original line number Diff line number Diff line
@@ -11,10 +11,7 @@
#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();
}
+14 −5
Original line number Diff line number Diff line
@@ -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);
+0 −3
Original line number Diff line number Diff line
/*
 *	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 {
Loading