]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: allow unit tests to be skipped
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 27 Sep 2018 07:31:13 +0000 (09:31 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 27 Sep 2018 09:42:38 +0000 (11:42 +0200)
test/unit/test.c
test/unit/test.h

index 23bb8352f28786ab59bdcd851f588a648396f5d5..fbfeb4b46b009b62c0844f8994a220d711a75914 100644 (file)
@@ -33,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)
 {
index f4092524fcde63a8dfbbb693930648d89da813e5..2d3637b581535a6c7760a7bf0dd02306de06fc40 100644 (file)
@@ -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);