From cf545a3ceb6a4ae6aa37dc1cd6e977fc80bb8e0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pavel=20Tvrd=C3=ADk?= Date: Fri, 27 Mar 2015 14:03:47 +0100 Subject: [PATCH] Birdtest: Add bt_rand_num() --- test/birdtest.c | 9 ++++++++- test/birdtest.h | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/birdtest.c b/test/birdtest.c index dc515844d..e6e78628e 100644 --- a/test/birdtest.c +++ b/test/birdtest.c @@ -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(); +} diff --git a/test/birdtest.h b/test/birdtest.h index fbfbfec26..69ee46526 100644 --- a/test/birdtest.h +++ b/test/birdtest.h @@ -13,14 +13,13 @@ #include #include -// 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) -- 2.47.2