2016-06-04 14:29:14 +02:00
|
|
|
#ifndef _NOTMUCH_TEST_H
|
|
|
|
#define _NOTMUCH_TEST_H
|
2021-10-25 03:15:14 +02:00
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif
|
|
|
|
|
2021-10-28 14:32:34 +02:00
|
|
|
#include <assert.h>
|
2021-10-25 03:15:14 +02:00
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <fcntl.h>
|
2016-06-04 14:29:14 +02:00
|
|
|
#include <stdio.h>
|
2020-06-30 03:14:08 +02:00
|
|
|
#include <stdlib.h>
|
2021-10-28 14:32:34 +02:00
|
|
|
#include <string.h>
|
2021-10-25 03:15:14 +02:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
2021-10-28 14:32:34 +02:00
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <talloc.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2016-06-04 14:29:14 +02:00
|
|
|
#include <notmuch.h>
|
|
|
|
|
|
|
|
inline static void
|
2019-06-25 19:55:45 +02:00
|
|
|
expect0 (int line, notmuch_status_t ret)
|
2016-06-04 14:29:14 +02:00
|
|
|
{
|
2019-06-25 19:55:45 +02:00
|
|
|
if (ret) {
|
2016-09-22 13:11:42 +02:00
|
|
|
fprintf (stderr, "line %d: %d\n", line, ret);
|
2016-06-04 14:29:14 +02:00
|
|
|
exit (1);
|
2019-06-25 19:55:45 +02:00
|
|
|
}
|
2016-06-04 14:29:14 +02:00
|
|
|
}
|
|
|
|
|
2019-06-25 19:55:45 +02:00
|
|
|
#define EXPECT0(v) expect0 (__LINE__, v);
|
2021-10-25 03:15:14 +02:00
|
|
|
|
|
|
|
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);
|
2016-06-04 14:29:14 +02:00
|
|
|
#endif
|