diff options
Diffstat (limited to 'ccan/list/test/run-CCAN_LIST_DEBUG.c')
| -rw-r--r-- | ccan/list/test/run-CCAN_LIST_DEBUG.c | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/ccan/list/test/run-CCAN_LIST_DEBUG.c b/ccan/list/test/run-CCAN_LIST_DEBUG.c deleted file mode 100644 index b8e5165..0000000 --- a/ccan/list/test/run-CCAN_LIST_DEBUG.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Check that CCAN_LIST_DEBUG works */ -#include <setjmp.h> -#include <stdlib.h> -#include <stdio.h> -#include <stdarg.h> -#include <string.h> -#include <err.h> - -/* We don't actually want it to exit... */ -static jmp_buf aborted; -#define abort() longjmp(aborted, 1) - -#define fprintf my_fprintf -static char printf_buffer[1000]; - -static int my_fprintf(FILE *stream, const char *format, ...) -{ - va_list ap; - int ret; - (void)stream; - va_start(ap, format); - ret = vsprintf(printf_buffer, format, ap); - va_end(ap); - return ret; -} - -#define CCAN_LIST_DEBUG 1 -#include <ccan/list/list.h> -#include <ccan/tap/tap.h> -#include <ccan/list/list.c> - -int main(void) -{ - struct list_head list; - struct list_node n1; - char expect[100]; - - plan_tests(2); - /* Empty list. */ - list.n.next = &list.n; - list.n.prev = &list.n; - ok1(list_check(&list, NULL) == &list); - - /* Bad back ptr */ - list.n.prev = &n1; - - /* Aborting version. */ - sprintf(expect, "run-CCAN_LIST_DEBUG.c:51: prev corrupt in node %p (0) of %p\n", - &list, &list); - if (setjmp(aborted) == 0) { - assert(list_empty(&list)); - fail("list_empty on empty with bad back ptr didn't fail!"); - } else { - /* __FILE__ might give full path. */ - int prep = strlen(printf_buffer) - strlen(expect); - ok1(prep >= 0 && strcmp(printf_buffer + prep, expect) == 0); - } - - return exit_status(); -} |
