mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-03-11 17:08:46 +00:00
Birdtest: Clean up unit tests from mock-ups
This commit is contained in:
parent
856250c27f
commit
e0176f2639
@ -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)))
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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 */
|
||||
|
@ -7,8 +7,6 @@
|
||||
*/
|
||||
|
||||
#include "test/birdtest.h"
|
||||
#include "test/birdtest_support.h" /* REMOVE ME */
|
||||
|
||||
#include "lib/ip.h"
|
||||
|
||||
#define IP4_MAX_LEN 16
|
||||
|
@ -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])
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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");
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user