if (strcmp(argv[1], "depends") == 0) {
printf("ccan/compiler\n");
printf("ccan/read_write_all\n");
+ printf("ccan/str\n");
return 0;
}
--- /dev/null
+#include <ccan/oserver/oserver.h>
+#include <ccan/oserver/oserver.c>
+#include <ccan/str/str.h>
+#include <ccan/tap/tap.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/wait.h>
+
+int main(void)
+{
+ int fd;
+ int status;
+ char buf[200];
+
+ /* This is how many tests you plan to run */
+ plan_tests(3);
+
+ fd = open("run-fd", O_RDWR|O_CREAT|O_TRUNC, 0600);
+ write(fd, "This is a test\n", sizeof("This is a test\n"));
+ lseek(fd, 0, SEEK_SET);
+
+ if (fork() == 0)
+ oserver_serve(fd);
+
+ wait(&status);
+
+ ok1(WIFEXITED(status));
+ ok1(WEXITSTATUS(status) == 0);
+
+ lseek(fd, 0, SEEK_SET);
+ buf[read(fd, buf, sizeof(buf)-1)] = '\0';
+
+ ok1(streq(buf, "This is a test\n"
+ "Louder, like this: 'THIS IS A TEST'\r\n"));
+
+ /* This exits depending on whether all tests passed */
+ return exit_status();
+}