0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-02-02 22:30:01 +00:00

Birdtest: Add bt_rand_num()

This commit is contained in:
Pavel Tvrdík 2015-03-27 14:03:47 +01:00
parent 016e7be6e5
commit cf545a3ceb
2 changed files with 11 additions and 3 deletions

View File

@ -27,12 +27,13 @@ int bt_verbose;
const char *bt_filename;
const char *bt_test_id;
void
bt_init(int argc, char *argv[])
{
int c;
srandom(BT_RANDOM_SEED);
bt_verbose = 0;
bt_filename = argv[0];
@ -159,3 +160,9 @@ bt_test_case5(int (*test_fn)(void), const char *test_id, const char *dsc, int fo
bt_note("OK");
}
int
bt_rand_num(void)
{
return random();
}

View File

@ -13,14 +13,13 @@
#include <string.h>
#include <errno.h>
// TODO: add a pseudo random number generator with fixed seed
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_case5(int (*fn)(void), const char *id, const char *dsc, int forked, int timeout);
int bt_rand_num(void);
#define BT_SUCCESS 0
#define BT_FAILURE 1
@ -28,6 +27,8 @@ void bt_test_case5(int (*fn)(void), const char *id, const char *dsc, int forked,
#define BT_DEFAULT_TIMEOUT 5
#define BT_DEFAULT_FORKING 1
#define BT_RANDOM_SEED 982451653
#define bt_test_case(fn,dsc) \
bt_test_case4(fn, dsc, BT_DEFAULT_FORKING, BT_DEFAULT_TIMEOUT)