X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftal%2Fgrab_file%2Ftest%2Frun-grab.c;fp=ccan%2Ftal%2Fgrab_file%2Ftest%2Frun-grab.c;h=b258230e84b270b65b9669e58d5ff884a181a9a9;hb=fbad46cd37018923bf0a7de2df37e35e90792c32;hp=0000000000000000000000000000000000000000;hpb=db4e16e71cd1bb474307c971c6312389bb254053;p=ccan diff --git a/ccan/tal/grab_file/test/run-grab.c b/ccan/tal/grab_file/test/run-grab.c new file mode 100644 index 00000000..b258230e --- /dev/null +++ b/ccan/tal/grab_file/test/run-grab.c @@ -0,0 +1,37 @@ +/* This is test for grab_file() function + */ +#include +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + unsigned int i; + char **split, *str; + int length; + struct stat st; + + str = grab_file(NULL, "test/run-grab.c"); + split = tal_strsplit(str, str, "\n", STR_EMPTY_OK); + length = strlen(split[0]); + ok1(!strcmp(split[0], "/* This is test for grab_file() function")); + for (i = 1; split[i]; i++) + length += strlen(split[i]); + ok1(!strcmp(split[i-1], "/* End of grab_file() test */")); + if (stat("test/run-grab.c", &st) != 0) + /* FIXME: ditto */ + if (stat("ccan/tal/grab_file/test/run-grab.c", &st) != 0) + err(1, "Could not stat self"); + ok1(st.st_size == length + i); + tal_free(str); + + return 0; +} + +/* End of grab_file() test */