X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=test%2Fnotmuch-test.h;h=ed713099b1d3b435024abae6d100d6c1ddf75a4d;hb=5ea5a5557d9ad4cef67e61a83bb81abd44dc7f76;hp=34dbb8e0403feefc4be402178943d8576a8d9c01;hpb=2c17327ee5c428e3d52a188b0433a130b4684438;p=notmuch diff --git a/test/notmuch-test.h b/test/notmuch-test.h index 34dbb8e0..ed713099 100644 --- a/test/notmuch-test.h +++ b/test/notmuch-test.h @@ -1,7 +1,21 @@ #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 @@ -14,4 +28,23 @@ expect0 (int line, notmuch_status_t ret) } #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 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