static struct lock_info *locks = NULL;
static unsigned int lock_num = 0;
+static pid_t orig_pid;
+
static const char info_to_arg[] = "mceoxprwf";
/* Dummy call used for failtest_undo wrappers. */
return p->u.fcntl.ret;
}
+pid_t failtest_getpid(const char *file, unsigned line)
+{
+ /* You must call failtest_init first! */
+ assert(orig_pid);
+ return orig_pid;
+}
+
void failtest_init(int argc, char *argv[])
{
unsigned int i;
+ orig_pid = getpid();
+
for (i = 1; i < argc; i++) {
if (!strncmp(argv[i], "--failpath=", strlen("--failpath="))) {
failpath = argv[i] + strlen("--failpath=");
#undef fcntl
#define fcntl(fd, ...) failtest_fcntl((fd), __FILE__, __LINE__, __VA_ARGS__)
+/* Replacement of getpid (since failtest will fork). */
+#undef getpid
+#define getpid() failtest_getpid(__FILE__, __LINE__)
+
#include <ccan/failtest/failtest_proto.h>
#endif /* CCAN_FAILTEST_OVERRIDE_H */
const char *file, unsigned line);
int failtest_close(int fd, const char *file, unsigned line);
int failtest_fcntl(int fd, const char *file, unsigned line, int cmd, ...);
+pid_t failtest_getpid(const char *file, unsigned line);
#endif /* CCAN_FAILTEST_PROTO_H */