X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Frfc822%2Ftest%2Fhelper.c;fp=ccan%2Frfc822%2Ftest%2Fhelper.c;h=cc62a6621e4caf4bd94bd09f4374f6935bdae584;hb=e4b6a262822484244b52c476d1b4cc9c4fd8ee2b;hp=42894ed0288cbee530e38725133b4aa83be760fb;hpb=97d99004bec31012400b6c1d9bad045ae1c9b075;p=ccan diff --git a/ccan/rfc822/test/helper.c b/ccan/rfc822/test/helper.c index 42894ed0..cc62a662 100644 --- a/ccan/rfc822/test/helper.c +++ b/ccan/rfc822/test/helper.c @@ -1,7 +1,6 @@ #include #include -#include #include #include @@ -11,6 +10,7 @@ /* failtest limitations mean we need these wrappers to test talloc * failure paths. */ +#ifndef TAL_USE_TALLOC static void *malloc_wrapper(size_t size) { return malloc(size); @@ -25,6 +25,7 @@ static void *realloc_wrapper(void *ptr, size_t size) { return realloc(ptr, size); } +#endif #if 0 static void allocation_failure_exit(const char *s) @@ -50,11 +51,29 @@ void allocation_failure_check(void) } } +#ifdef TAL_USE_TALLOC +#include +#else +#include +#endif + +/* Don't abort on allocation failures! */ +static void noabort_wrapper(const char *why) +{ + return; +} + void failtest_setup(int argc, char *argv[]) { failtest_init(argc, argv); rfc822_set_allocation_failure_handler(allocation_failure_continue); - talloc_set_allocator(malloc_wrapper, free_wrapper, realloc_wrapper); +#ifdef TAL_USE_TALLOC + /* FIXME: we can't inject allocation failures in talloc! */ + tal_set_backend(NULL, NULL, NULL, noabort_wrapper); +#else + tal_set_backend(malloc_wrapper, realloc_wrapper, free_wrapper, + noabort_wrapper); +#endif } void check_header(struct rfc822_msg *msg,