]> git.ozlabs.org Git - ccan/blob - ccan/rbuf/test/run-open.c
rbuf, tools: clean up rbuf usage.
[ccan] / ccan / rbuf / test / run-open.c
1 #include <ccan/rbuf/rbuf.h>
2 /* Include the C files directly. */
3 #include <ccan/rbuf/rbuf.c>
4 #include <ccan/tap/tap.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8 #include <stdlib.h>
9
10 int main(void)
11 {
12         struct rbuf in;
13
14         /* This is how many tests you plan to run */
15         plan_tests(5);
16
17         ok1(!rbuf_open(&in, "nonexistent-file", NULL, 0, NULL));
18         ok1(errno == ENOENT);
19         ok1(rbuf_open(&in, "test/run-open.c", NULL, 0, NULL));
20         ok1(close(in.fd) == 0);
21         /* If this fails to stat, it should fall back */
22         ok1(rbuf_good_size(in.fd) == 4096);
23
24         return exit_status();
25 }