]>
git.scottworley.com Git - tl-append/blob - tl-append-test.c
1 #define _POSIX_C_SOURCE 2
6 static void die(const char *message
) {
7 fputs(message
, stderr
);
12 static void die_err(const char *message
) {
17 static void write_and_read_line() {
20 FILE *p
= popen("./tl-append", "w");
22 die_err("Couldn't run tl-append");
23 if (fputs("foo\n", p
) == EOF
)
24 die("Couldn't write to pipe");
25 int status
= pclose(p
);
27 die_err("Error closing pipe");
29 die("tl-append exited abnormally");
31 FILE *f
= fopen("tl.log", "r");
33 die_err("Error opening log file");
34 if (fgets(buf
, sizeof(buf
), f
) == NULL
)
35 die("Error reading log file");
36 if (strncmp("foo\n", buf
, sizeof(buf
)) != 0)
37 die("Wrong contents in log file");
39 die_err("Error closing log file");
42 int main() { write_and_read_line(); }