From: Miroslav Lichvar Date: Mon, 15 Feb 2016 15:05:18 +0000 (+0100) Subject: test/unit: add more helper functions X-Git-Tag: 2.3~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4998afc9bb09ed0715bb64ed25e6d26d6d374a49;p=thirdparty%2Fchrony.git test/unit: add more helper functions --- diff --git a/test/unit/test.c b/test/unit/test.c index 3a110330..7709cb76 100644 --- a/test/unit/test.c +++ b/test/unit/test.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "test.h" @@ -68,6 +69,12 @@ main(int argc, char **argv) return 0; } +double +TST_GetRandomDouble(double min, double max) +{ + return min + (double)random() / RAND_MAX * (max - min); +} + void TST_GetRandomAddress(IPAddr *ip, int family, int bits) { @@ -117,3 +124,40 @@ TST_SwapAddressBit(IPAddr *ip, unsigned int b) } } +static double +read_frequency(void) +{ + return 0.0; +} + +static double +set_frequency(double freq_ppm) +{ + return 0.0; +} + +static void +accrue_offset(double offset, double corr_rate) +{ +} + +static int +apply_step_offset(double offset) +{ + return 0; +} + +static void +offset_convert(struct timeval *raw, double *corr, double *err) +{ + *corr = 0.0; + if (err) + *err = 0.0; +} + +void +TST_RegisterDummyDrivers(void) +{ + lcl_RegisterSystemDrivers(read_frequency, set_frequency, accrue_offset, + apply_step_offset, offset_convert, NULL, NULL); +} diff --git a/test/unit/test.h b/test/unit/test.h index e736e274..d96f3afb 100644 --- a/test/unit/test.h +++ b/test/unit/test.h @@ -35,7 +35,9 @@ extern void test_unit(void); extern void TST_Fail(int line); +extern double TST_GetRandomDouble(double min, double max); extern void TST_GetRandomAddress(IPAddr *ip, int family, int bits); extern void TST_SwapAddressBit(IPAddr *ip, unsigned int b); +extern void TST_RegisterDummyDrivers(void); #endif