1 #include <ccan/rbuf/rbuf.h>
2 /* Include the C files directly. */
3 #include <ccan/rbuf/rbuf.c>
4 #include <ccan/tap/tap.h>
14 int i, size, fd = open("run-all-file", O_WRONLY|O_CREAT, 0600);
16 /* This is how many tests you plan to run */
19 /* Make sure we're bigger than a single buffer! */
20 size = rbuf_good_size(fd)*2;
21 for (i = 0; i * sizeof(buf) < size; i++) {
22 memset(buf, 0x42 + i, sizeof(buf));
23 write(fd, buf, sizeof(buf));
27 ok1(rbuf_open(&in, "run-all-file", NULL, 0));
28 /* Can't fill without realloc. */
29 ok1(!rbuf_fill(&in, NULL));
31 ok1(rbuf_fill(&in, realloc));
32 /* But can't load in whole file. */
33 ok1(!rbuf_fill_all(&in, NULL));
35 ok1(rbuf_fill_all(&in, realloc));
37 for (i = 0; i * sizeof(buf) < size; i++) {
38 memset(buf, 0x42 + i, sizeof(buf));
39 if (memcmp(buf, in.start, sizeof(buf)) != 0) {
40 fail("Bad buffer contents");
43 rbuf_consume(&in, sizeof(buf));
47 /* This exits depending on whether all tests passed */