1 #include <ccan/oserver/oserver.h>
2 #include <ccan/oserver/oserver.c>
3 #include <ccan/str/str.h>
4 #include <ccan/array_size/array_size.h>
5 #include <ccan/tap/tap.h>
17 const char *input[] = { "This is a test\n",
20 "This is a test\nWith extra",
21 "This is a test\rWith extra",
22 "This is a test\r\nWith extra" };
24 /* This is how many tests you plan to run */
25 plan_tests(4 * ARRAY_SIZE(input));
27 for (i = 0; i < ARRAY_SIZE(input); i++) {
28 fd = open("run-fd", O_RDWR|O_CREAT|O_TRUNC, 0600);
30 write(fd, input[i], strlen(input[i]));
31 lseek(fd, 0, SEEK_SET);
38 ok1(WIFEXITED(status));
39 ok1(WEXITSTATUS(status) == 0);
41 lseek(fd, 0, SEEK_SET);
42 buf[read(fd, buf, sizeof(buf)-1)] = '\0';
44 ok1(strncmp(buf, input[i], strlen("This is a test")) == 0);
45 ok1(streq(buf + strlen("This is a test") + 1,
46 "Louder, like this: 'THIS IS A TEST'\r\n"));
49 /* This exits depending on whether all tests passed */