]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test/unit: add more helper functions
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 15 Feb 2016 15:05:18 +0000 (16:05 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 16 Feb 2016 12:43:07 +0000 (13:43 +0100)
test/unit/test.c
test/unit/test.h

index 3a1103301c761a414324cdbe130668da50a90d5a..7709cb764666f0d765286b27582bccab5b736102 100644 (file)
@@ -21,6 +21,7 @@
 #include <config.h>
 #include <sysincl.h>
 #include <logging.h>
+#include <localp.h>
 
 #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);
+}
index e736e27458b317c6fbb14f6aa2b095525b94fb21..d96f3afb18d68d4b8ad275a9eda57a22aa4650c0 100644 (file)
@@ -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