test/unit: add more helper functions
This commit is contained in:
parent
80f4d75968
commit
4998afc9bb
2 changed files with 46 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <sysincl.h>
|
#include <sysincl.h>
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
|
#include <localp.h>
|
||||||
|
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
|
@ -68,6 +69,12 @@ main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
TST_GetRandomDouble(double min, double max)
|
||||||
|
{
|
||||||
|
return min + (double)random() / RAND_MAX * (max - min);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TST_GetRandomAddress(IPAddr *ip, int family, int bits)
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -35,7 +35,9 @@ extern void test_unit(void);
|
||||||
|
|
||||||
extern void TST_Fail(int line);
|
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_GetRandomAddress(IPAddr *ip, int family, int bits);
|
||||||
extern void TST_SwapAddressBit(IPAddr *ip, unsigned int b);
|
extern void TST_SwapAddressBit(IPAddr *ip, unsigned int b);
|
||||||
|
extern void TST_RegisterDummyDrivers(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue