X-Git-Url: http://git.scottworley.com/tl-append/blobdiff_plain/71a7e5c5f2fa792715f1c4c9491ad8cc7e718388..d753115a12c9368e24546c04f992740799da0257:/tl-append-test.c diff --git a/tl-append-test.c b/tl-append-test.c index 2a5d233..ea42dc9 100644 --- a/tl-append-test.c +++ b/tl-append-test.c @@ -3,15 +3,21 @@ #include #include #include +#include typedef struct expectation { + time_t a, b; const char *message; } ex_t; -const ex_t END = {NULL}; -static int is_end(ex_t exp) { return exp.message == END.message; } -static ex_t expectation(const char *message) { +const ex_t END = {((time_t)-1), ((time_t)-1), NULL}; +static int is_end(ex_t exp) { + return exp.a == END.a && exp.b == END.b && exp.message == END.message; +} +static ex_t expectation(time_t a, time_t b, const char *message) { ex_t exp; + exp.a = a; + exp.b = b; exp.message = message; return exp; } @@ -39,14 +45,16 @@ static ex_t write_to_tl_append(const char *content) { FILE *p = popen("./tl-append", "w"); if (p == NULL) die_err("Couldn't run tl-append"); + time_t start = time(NULL); if (fputs(content, p) == EOF) die("Couldn't write to pipe"); int status = pclose(p); + time_t end = time(NULL); if (status < 0) die_err("Error closing pipe"); if (status != 0) die("tl-append exited abnormally"); - return expectation(content); + return expectation(start, end, content); } static void verify_log_contents(ex_t exps[]) {