Commit 11af31c3 authored by David Gibson's avatar David Gibson

altstack: Clarify checking macros

The chkfail() and chkok() macros in altstack's test program are pretty
difficult to read.  More importantly, though, they do all their tests with
one big ok1().  That means if the test fails, you get no indication which
of the checks was actually wrong, making debugging harder.

This reworks the macros into a more verbose form that's easier to read,
and splits them into multiple ok1() tests to make failures more explicit.
Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
parent dd3f80c1
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment