1 /* This is test for grab_file() function
5 * void *grab_file(const void *ctx, const char *filename)
10 * if (streq(filename, "-"))
11 * fd = dup(STDIN_FILENO);
13 * fd = open(filename, O_RDONLY, 0);
18 * buffer = grab_fd(ctx, fd);
28 #include "string/string.h"
29 #include "string/string.c"
33 main(int argc, char *argv[])
40 str = grab_file(NULL, "ccan/string/test/run-grab.c");
41 split = strsplit(NULL, str, "\n", NULL);
42 length = strlen(split[0]);
43 ok1(streq(split[0], "/* This is test for grab_file() function"));
44 for (i = 1; split[i]; i++)
45 length += strlen(split[i]);
46 ok1(streq(split[i-1], "/* End of grab_file() test */"));
47 if (stat("ccan/string/test/run-grab.c", &st) != 0)
48 err(1, "Could not stat self");
49 ok1(st.st_size == length + i);
54 /* End of grab_file() test */