aboutsummaryrefslogtreecommitdiff
path: root/test/core/tap.h
diff options
context:
space:
mode:
authorRandy Palamar <randy@rnpnr.xyz>2024-05-21 19:53:22 -0600
committerRandy Palamar <randy@rnpnr.xyz>2024-05-21 19:53:22 -0600
commitb7074021b7bfb0932b889b9560dd22df31cef818 (patch)
tree0295b18de8fb8ea5289cbda95675687ae06025ff /test/core/tap.h
parentb7f8018a00be930e3f2b864949aec1f91291309c (diff)
parentefafa3c178268a4149fc3e432bc1174a013c16de (diff)
downloadvis-b7074021b7bfb0932b889b9560dd22df31cef818.tar.gz
vis-b7074021b7bfb0932b889b9560dd22df31cef818.tar.xz
Merge vis-tests into test directory
Going forward all tests should be submitted here directly.
Diffstat (limited to 'test/core/tap.h')
-rw-r--r--test/core/tap.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/core/tap.h b/test/core/tap.h
new file mode 100644
index 0000000..b8a7213
--- /dev/null
+++ b/test/core/tap.h
@@ -0,0 +1,58 @@
+#ifndef TAP_H
+#define TAP_H
+
+#ifdef TIS_INTERPRETER
+static int failures = 0;
+static int test_count = 0;
+static void plan_no_plan(void) { }
+
+static int exit_status() {
+ if (failures > 255)
+ failures = 255;
+ return failures;
+}
+
+#define ok(e, ...) do { \
+ bool _e = (e); \
+ printf("%sok %d - ", _e ? "" : "not ", ++test_count); \
+ printf(__VA_ARGS__); \
+ printf("\n"); \
+ if (!_e) { \
+ failures++; \
+ printf(" Failed test (%s:%s() at line %d)\n", __FILE__, __func__, __LINE__); \
+ } \
+} while (0)
+
+#define skip_if(cond, n, ...) \
+ if (cond) skip((n), __VA_ARGS__); \
+ else
+
+#define skip(n, ...) do { \
+ int _n = (n); \
+ while (_n--) { \
+ printf("ok %d # skip ", ++test_count); \
+ printf(__VA_ARGS__); \
+ printf("\n"); \
+ } \
+} while (0)
+
+#include <time.h>
+time_t time(time_t *p)
+{
+ static time_t value;
+ value++;
+ if (p) *p = value;
+ return value;
+}
+
+long labs(long v)
+{
+ return v > 0 ? v : -v;
+}
+
+#else
+#include <ccan/tap/tap.h>
+#define TIS_INTERPRETER 0
+#endif
+
+#endif