s3:lib/events: make use of samba_tevent_set_debug()
[Samba/gebeck_regimport.git] / lib / ccan / failtest / test / run-failpath.c
blob9795ee9d054f9810b4aecd2c1a1f73bf2689efbb
1 #include <ccan/failtest/failtest.c>
2 #include <stdlib.h>
3 #include <setjmp.h>
4 #include <stdio.h>
5 #include <stdarg.h>
6 #include <ccan/tap/tap.h>
8 int main(void)
10 int fds[2], fd;
11 void *p;
13 plan_tests(14);
14 failtest_init(0, NULL);
16 failpath = "mceopwrMCEOPWR";
18 ok1((p = failtest_malloc(10, "run-failpath.c", 1)) != NULL);
19 ok1(failtest_calloc(10, 5, "run-failpath.c", 1) != NULL);
20 ok1((p = failtest_realloc(p, 100, "run-failpath.c", 1)) != NULL);
21 ok1((fd = failtest_open("failpath-scratch", "run-failpath.c", 1,
22 O_RDWR|O_CREAT, 0600)) >= 0);
23 ok1(failtest_pipe(fds, "run-failpath.c", 1) == 0);
24 ok1(failtest_write(fd, "xxxx", 4, "run-failpath.c", 1) == 4);
25 lseek(fd, 0, SEEK_SET);
26 ok1(failtest_read(fd, p, 5, "run-failpath.c", 1) == 4);
28 /* Now we're into the failures. */
29 ok1(failtest_malloc(10, "run-failpath.c", 1) == NULL);
30 ok1(failtest_calloc(10, 5, "run-failpath.c", 1) == NULL);
31 ok1(failtest_realloc(p, 100, "run-failpath.c", 1) == NULL);
32 ok1(failtest_open("failpath-scratch", "run-failpath.c", 1,
33 O_RDWR|O_CREAT, 0600) == -1);
34 ok1(failtest_pipe(fds, "run-failpath.c", 1) == -1);
35 ok1(failtest_write(fd, "xxxx", 4, "run-failpath.c", 1) == -1);
36 lseek(fd, 0, SEEK_SET);
37 ok1(failtest_read(fd, p, 5, "run-failpath.c", 1) == -1);
38 return exit_status();