X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Fnotmuch-test.h;h=45d03d67540a795540da7287e1212d460b6289af;hp=d39febbe8f2fe910191d98146a610f0272e6d592;hb=HEAD;hpb=92d8eae8f182e4eebc87d76f8d4f37e6c018883a diff --git a/test/notmuch-test.h b/test/notmuch-test.h index d39febbe..ed713099 100644 --- a/test/notmuch-test.h +++ b/test/notmuch-test.h @@ -1,16 +1,50 @@ #ifndef _NOTMUCH_TEST_H #define _NOTMUCH_TEST_H +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include + #include inline static void -expect0(int line, notmuch_status_t ret) +expect0 (int line, notmuch_status_t ret) { - if (ret) { - fprintf (stderr, "line %d: %s\n", line, ret); + if (ret) { + fprintf (stderr, "line %d: %d\n", line, ret); exit (1); - } + } +} + +#define EXPECT0(v) expect0 (__LINE__, v); + +inline static void * +dlsym_next (const char *symbol) +{ + void *sym = dlsym (RTLD_NEXT, symbol); + char *str = dlerror (); + + if (str != NULL) { + fprintf (stderr, "finding symbol '%s' failed: %s", symbol, str); + exit (77); + } + return sym; } -#define EXPECT0(v) expect0(__LINE__, v); +#define WRAP_DLFUNC(_rtype, _func, _args) \ + _rtype _func _args; \ + _rtype _func _args { \ + static _rtype (*_func##_orig) _args = NULL; \ + if (! _func##_orig ) *(void **) (&_func##_orig) = dlsym_next (#_func); #endif