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, ...)
22 ret = vsprintf(printf_buffer, format, ap);
27 #define CCAN_LIST_DEBUG 1
28 #include <ccan/list/list.h>
29 #include <ccan/tap/tap.h>
30 #include <ccan/list/list.c>
34 struct list_head list;
40 list.n.next = &list.n;
41 list.n.prev = &list.n;
42 ok1(list_check(&list, NULL) == &list);
47 /* Aborting version. */
48 sprintf(expect, "run-CCAN_LIST_DEBUG.c:51: prev corrupt in node %p (0) of %p\n",
50 if (setjmp(aborted) == 0) {
51 assert(list_empty(&list));
52 fail("list_empty on empty with bad back ptr didn't fail!");
54 /* __FILE__ might give full path. */
55 int prep = strlen(printf_buffer) - strlen(expect);
56 ok1(prep >= 0 && strcmp(printf_buffer + prep, expect) == 0);