mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-08 18:11:54 +00:00
Birdtest: Add default timeout and forking setting
This commit is contained in:
parent
a8a67537ed
commit
e8b3845e86
@ -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)
|
||||
{
|
||||
|
@ -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_ */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user