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, ...)
20 ret = vsprintf(printf_buffer, format, ap);
25 #include <ccan/list/list.h>
26 #include <ccan/tap/tap.h>
27 #include <ccan/list/list.c>
29 int main(int argc, char *argv[])
31 struct list_head list;
37 list.n.next = &list.n;
38 list.n.prev = &list.n;
39 ok1(list_check(&list, NULL) == &list);
43 /* Non-aborting version. */
44 ok1(list_check(&list, NULL) == NULL);
46 /* Aborting version. */
47 sprintf(expect, "test message: prev corrupt in node %p (0) of %p\n",
49 if (setjmp(aborted) == 0) {
50 list_check(&list, "test message");
51 fail("list_check on empty with bad back ptr didn't fail!");
53 ok1(strcmp(printf_buffer, expect) == 0);
61 ok1(list_check(&list, NULL) == &list);
62 ok1(list_check_node(&n1, NULL) == &n1);
66 ok1(list_check(&list, NULL) == NULL);
67 ok1(list_check_node(&n1, NULL) == NULL);
69 /* Aborting version. */
70 sprintf(expect, "test message: prev corrupt in node %p (1) of %p\n",
72 if (setjmp(aborted) == 0) {
73 list_check(&list, "test message");
74 fail("list_check on n1 bad back ptr didn't fail!");
76 ok1(strcmp(printf_buffer, expect) == 0);
79 sprintf(expect, "test message: prev corrupt in node %p (0) of %p\n",
81 if (setjmp(aborted) == 0) {
82 list_check_node(&n1, "test message");
83 fail("list_check_node on n1 bad back ptr didn't fail!");
85 ok1(strcmp(printf_buffer, expect) == 0);