]> git.ozlabs.org Git - ccan/blob - ccan/failtest/failtest_override.h
failtest: fix silent exit when top-level return FAIL_PROBE
[ccan] / ccan / failtest / failtest_override.h
1 /* Licensed under LGPL - see LICENSE file for details */
2 #ifndef CCAN_FAILTEST_OVERRIDE_H
3 #define CCAN_FAILTEST_OVERRIDE_H
4 /* This file is included before the source file to test. */
5 #include "config.h"
6
7 /* Replacement of allocators. */
8 #include <stdlib.h>
9
10 #undef calloc
11 #define calloc(nmemb, size)     \
12         failtest_calloc((nmemb), (size), __FILE__, __LINE__)
13
14 #undef malloc
15 #define malloc(size)    \
16         failtest_malloc((size), __FILE__, __LINE__)
17
18 #undef realloc
19 #define realloc(ptr, size)                                      \
20         failtest_realloc((ptr), (size), __FILE__, __LINE__)
21
22 #undef free
23 #define free(ptr) \
24         failtest_free(ptr)
25
26 /* Replacement of I/O. */
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <fcntl.h>
30 #include <unistd.h>
31
32 #undef open
33 #define open(pathname, ...) \
34         failtest_open((pathname), __FILE__, __LINE__, __VA_ARGS__)
35
36 #undef pipe
37 #define pipe(pipefd) \
38         failtest_pipe((pipefd), __FILE__, __LINE__)
39
40 #undef read
41 #define read(fd, buf, count) \
42         failtest_read((fd), (buf), (count), __FILE__, __LINE__)
43
44 #undef write
45 #define write(fd, buf, count) \
46         failtest_write((fd), (buf), (count), __FILE__, __LINE__)
47
48 #undef pread
49 #define pread(fd, buf, count, off)                              \
50         failtest_pread((fd), (buf), (count), (off), __FILE__, __LINE__)
51
52 #undef pwrite
53 #define pwrite(fd, buf, count, off)                                     \
54         failtest_pwrite((fd), (buf), (count), (off), __FILE__, __LINE__)
55
56 #undef close
57 #define close(fd) failtest_close(fd, __FILE__, __LINE__)
58
59 #undef fcntl
60 #define fcntl(fd, ...) failtest_fcntl((fd), __FILE__, __LINE__, __VA_ARGS__)
61
62 /* Replacement of getpid (since failtest will fork). */
63 #undef getpid
64 #define getpid() failtest_getpid(__FILE__, __LINE__)
65
66 #include <ccan/failtest/failtest_proto.h>
67
68 #endif /* CCAN_FAILTEST_OVERRIDE_H */