summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/ntp_core.c16
-rw-r--r--test/unit/ntp_sources.c14
-rw-r--r--test/unit/test.c8
-rw-r--r--test/unit/test.h9
4 files changed, 42 insertions, 5 deletions
diff --git a/test/unit/ntp_core.c b/test/unit/ntp_core.c
index 5e519e5..ac01205 100644
--- a/test/unit/ntp_core.c
+++ b/test/unit/ntp_core.c
@@ -28,6 +28,8 @@
#include <local.h>
#include "test.h"
+#ifdef FEAT_NTP
+
static struct timespec current_time;
static NTP_Receive_Buffer req_buffer, res_buffer;
static int req_length, res_length;
@@ -332,10 +334,8 @@ test_unit(void)
CPS_ParseNTPSourceAdd(source_line, &source);
for (i = 0; i < 1000; i++) {
- if (random() % 2)
- source.params.interleaved = 1;
- if (random() % 2)
- source.params.authkey = get_random_key_id();
+ source.params.interleaved = random() % 2;
+ source.params.authkey = random() % 2 ? get_random_key_id() : INACTIVE_AUTHKEY;
source.params.version = random() % 4 + 1;
UTI_ZeroTimespec(&current_time);
@@ -475,3 +475,11 @@ test_unit(void)
CNF_Finalise();
HSH_Finalise();
}
+
+#else
+void
+test_unit(void)
+{
+ TEST_REQUIRE(0);
+}
+#endif
diff --git a/test/unit/ntp_sources.c b/test/unit/ntp_sources.c
index ea8f19c..f13852e 100644
--- a/test/unit/ntp_sources.c
+++ b/test/unit/ntp_sources.c
@@ -18,10 +18,14 @@
**********************************************************************
*/
+#include <config.h>
+#include "test.h"
+
+#ifdef FEAT_NTP
+
#include <ntp_sources.c>
#include <conf.h>
#include <ntp_io.h>
-#include "test.h"
void
test_unit(void)
@@ -98,3 +102,11 @@ test_unit(void)
CNF_Finalise();
HSH_Finalise();
}
+
+#else
+void
+test_unit(void)
+{
+ TEST_REQUIRE(0);
+}
+#endif
diff --git a/test/unit/test.c b/test/unit/test.c
index 3a9ec74..fbfeb4b 100644
--- a/test/unit/test.c
+++ b/test/unit/test.c
@@ -22,6 +22,7 @@
#include <sysincl.h>
#include <logging.h>
#include <localp.h>
+#include <util.h>
#include "test.h"
@@ -32,6 +33,13 @@ TST_Fail(int line)
exit(1);
}
+void
+TST_Skip(int line)
+{
+ printf("SKIP (on line %d)\n", line);
+ exit(0);
+}
+
int
main(int argc, char **argv)
{
diff --git a/test/unit/test.h b/test/unit/test.h
index f409252..2d3637b 100644
--- a/test/unit/test.h
+++ b/test/unit/test.h
@@ -33,7 +33,16 @@ extern void test_unit(void);
} \
} while (0)
+#define TEST_REQUIRE(expr) \
+ do { \
+ if (!(expr)) { \
+ TST_Skip(__LINE__); \
+ exit(0); \
+ } \
+ } while (0)
+
extern void TST_Fail(int line);
+extern void TST_Skip(int line);
extern void TST_SuspendLogging(void);
extern void TST_ResumeLogging(void);