]> git.ozlabs.org Git - ccan/blobdiff - ccan/altstack/test/run.c
strgrp: Use ratio of hypotenuse for consistent comparisons
[ccan] / ccan / altstack / test / run.c
index de94887284703977946feca870e07ce4bd9aee42..12cc460d8dd264647e11a7d4e0dacc4cf1b60a3d 100644 (file)
@@ -1,3 +1,4 @@
+#include "config.h"
 #include <assert.h>
 #include <err.h>
 #include <errno.h>
@@ -8,7 +9,6 @@
 #include <sys/mman.h>
 #include <ccan/tap/tap.h>
 #include <ccan/altstack/altstack.h>
-#define _XOPEN_SOURCE 700
 #include <stdio.h>
 
 enum {
@@ -57,14 +57,34 @@ static void *wrap(void *i)
        return wrap;
 }
 
+#define chkfail(x, y, z, c1, c2)                                       \
+       do {                                                            \
+               call1 = 0;                                              \
+               call2 = 0;                                              \
+               errno = 0;                                              \
+               ok1((fail = x) && (y));                                 \
+               ok1(errno == (z));                                      \
+               ok1(call1 == (c1));                                     \
+               ok1(call2 == (c2));                                     \
+       } while (0);
+
+#define chkok(y, z, c1, c2)                                            \
+       do {                                                            \
+               call1 = 0;                                              \
+               call2 = 0;                                              \
+               errno = 0;                                              \
+               fail = 0;                                               \
+               ok1((y));                                               \
+               ok1(errno == (z));                                      \
+               ok1(call1 == (c1));                                     \
+               ok1(call2 == (c2));                                     \
+       } while (0)
+
 int main(void)
 {
        long pgsz = sysconf(_SC_PAGESIZE);
 
-       plan_tests(17);
-
-#define chkfail(x, y, z, c1, c2) (call1 = 0, call2 = 0, errno = 0, ok1((fail = x) && (y) && errno == (z) && call1 == (c1) && call2 == (c2)));
-#define   chkok(   y, z, c1, c2) (call1 = 0, call2 = 0, errno = 0, fail = 0,     ok1((y) && errno == (z) && call1 == (c1) && call2 == (c2)));
+       plan_tests(50);
 
        chkfail(getrlimit_,     altstack(8*MiB, wrap, 0, 0) == -1, e(getrlimit_),
                0,