]> git.ozlabs.org Git - ccan/blob - ccan/tal/grab_file/test/run-grab.c
Remove unused main() args in many modules.
[ccan] / ccan / tal / grab_file / test / run-grab.c
1 /* This is test for grab_file() function
2  */
3 #include <ccan/tal/grab_file/grab_file.h>
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <err.h>
7 #include <sys/stat.h>
8 #include <ccan/tal/grab_file/grab_file.c>
9 #include <ccan/tap/tap.h>
10 #include <ccan/tal/str/str.h>
11
12 int
13 main(void)
14 {
15         unsigned int    i;
16         char            **split, *str;
17         int             length;
18         struct          stat st;
19
20         str = grab_file(NULL, "test/run-grab.c");
21         split = tal_strsplit(str, str, "\n", STR_EMPTY_OK);
22         length = strlen(split[0]);
23         ok1(!strcmp(split[0], "/* This is test for grab_file() function"));
24         for (i = 1; split[i]; i++)
25                 length += strlen(split[i]);
26         ok1(!strcmp(split[i-1], "/* End of grab_file() test */"));
27         if (stat("test/run-grab.c", &st) != 0)
28                 /* FIXME: ditto */
29                 if (stat("ccan/tal/grab_file/test/run-grab.c", &st) != 0)
30                         err(1, "Could not stat self");
31         ok1(st.st_size == length + i);
32         tal_free(str);
33
34         return 0;
35 }
36
37 /* End of grab_file() test */