8 /* We don't actually want it to exit... */
9 static jmp_buf aborted;
10 #define abort() longjmp(aborted, 1)
12 #define fprintf my_fprintf
13 static char printf_buffer[1000];
15 static int my_fprintf(FILE *stream, const char *format, ...)
21 ret = vsprintf(printf_buffer, format, ap);
26 #include <ccan/list/list.h>
27 #include <ccan/tap/tap.h>
28 #include <ccan/list/list.c>
32 struct list_head list;
38 list.n.next = &list.n;
39 list.n.prev = &list.n;
40 ok1(list_check(&list, NULL) == &list);
44 /* Non-aborting version. */
45 ok1(list_check(&list, NULL) == NULL);
47 /* Aborting version. */
48 sprintf(expect, "test message: prev corrupt in node %p (0) of %p\n",
50 if (setjmp(aborted) == 0) {
51 list_check(&list, "test message");
52 fail("list_check on empty with bad back ptr didn't fail!");
54 ok1(strcmp(printf_buffer, expect) == 0);
62 ok1(list_check(&list, NULL) == &list);
63 ok1(list_check_node(&n1, NULL) == &n1);
67 ok1(list_check(&list, NULL) == NULL);
68 ok1(list_check_node(&n1, NULL) == NULL);
70 /* Aborting version. */
71 sprintf(expect, "test message: prev corrupt in node %p (1) of %p\n",
73 if (setjmp(aborted) == 0) {
74 list_check(&list, "test message");
75 fail("list_check on n1 bad back ptr didn't fail!");
77 ok1(strcmp(printf_buffer, expect) == 0);
80 sprintf(expect, "test message: prev corrupt in node %p (0) of %p\n",
82 if (setjmp(aborted) == 0) {
83 list_check_node(&n1, "test message");
84 fail("list_check_node on n1 bad back ptr didn't fail!");
86 ok1(strcmp(printf_buffer, expect) == 0);