1 /* Check that CCAN_LIST_DEBUG works */
9 /* We don't actually want it to exit... */
10 static jmp_buf aborted;
11 #define abort() longjmp(aborted, 1)
13 #define fprintf my_fprintf
14 static char printf_buffer[1000];
16 static int my_fprintf(FILE *stream, const char *format, ...)
21 ret = vsprintf(printf_buffer, format, ap);
26 #define CCAN_LIST_DEBUG 1
27 #include <ccan/list/list.h>
28 #include <ccan/tap/tap.h>
29 #include <ccan/list/list.c>
31 int main(int argc, char *argv[])
33 struct list_head list;
39 list.n.next = &list.n;
40 list.n.prev = &list.n;
41 ok1(list_check(&list, NULL) == &list);
46 /* Aborting version. */
47 sprintf(expect, "run-CCAN_LIST_DEBUG.c:50: prev corrupt in node %p (0) of %p\n",
49 if (setjmp(aborted) == 0) {
50 assert(list_empty(&list));
51 fail("list_empty on empty with bad back ptr didn't fail!");
53 /* __FILE__ might give full path. */
54 int prep = strlen(printf_buffer) - strlen(expect);
55 ok1(prep >= 0 && strcmp(printf_buffer + prep, expect) == 0);