1 #include <ccan/failtest/failtest_override.h>
2 #include <ccan/failtest/failtest.h>
3 #include <ccan/xstring/xstring.h>
4 /* Include the C files directly. */
5 #include <ccan/xstring/xstring.c>
6 #include <ccan/tap/tap.h>
8 unsigned last_fail_line;
10 static enum failtest_result once_only(struct tlist_calls *history)
12 const struct failtest_call *tail = tlist_tail(history, list);
14 if (tail->line == last_fail_line)
15 return FAIL_DONT_FAIL;
17 last_fail_line = tail->line;
21 int main(int argc, char *argv[])
23 failtest_init(argc, argv);
24 failtest_hook = once_only;
29 ok1((x = xstrNew(100)) != NULL); // fail first malloc
32 ok1((x = xstrNew(100)) != NULL); // fail second malloc
35 ok1((x = xstrNew(0)) == NULL && errno == EINVAL);
37 failtest_exit(exit_status());