X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Foserver%2Ftest%2Frun.c;fp=ccan%2Foserver%2Ftest%2Frun.c;h=03180c9bec8ccccb6bcc524562aa2134fe7eb4ff;hb=a1ee151190dc9ac9bf17163ab4d31f0491b8bbee;hp=e553f3d6a75494ba1ceb882899190c17e1ecc11f;hpb=a3f893b6ac5fd0040a0610711a7eded786681d2b;p=ccan-lca-2011.git diff --git a/ccan/oserver/test/run.c b/ccan/oserver/test/run.c index e553f3d..03180c9 100644 --- a/ccan/oserver/test/run.c +++ b/ccan/oserver/test/run.c @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) char c; /* This is how many tests you plan to run */ - plan_tests(15); + plan_tests(20); pipe(readyfd); pipe(exitfd); @@ -106,19 +106,31 @@ int main(int argc, char *argv[]) ok1(input_is(sfd1, "Welcome. Please ask your question.\n")); ok1(input_is(sfd2, "Welcome. Please ask your question.\n")); - ok1(write_sall(sfd1, "question")); - ok1(write_sall(sfd2, "question")); - /* It shouldn't say anything until we've finished! */ + ok1(write_sall(sfd1, "QUESTION")); + ok1(write_sall(sfd2, "QUESTION")); + ok1(write_sall(sfd1, " 1\n")); + + /* It can't ask a question yet, since client 2 isn't finished. */ ok1(no_input(sfd1)); - ok1(no_input(sfd2)); - ok1(write_sall(sfd1, " 1\n")); /* Make sure that arrives first! */ sleep(1); ok1(write_sall(sfd2, " 2\n")); - ok1(input_is(sfd1, "I believe a better question is how many manly men mendaciously mention mending mansions?\n")); - ok1(input_is(sfd2, "I believe a better question is question 1\n")); + ok1(input_is(sfd1, "While the Oracle ponders," + " please answer the following question:\nQUESTION 2\n")); + ok1(input_is(sfd2, "While the Oracle ponders," + " please answer the following question:\nQUESTION 1\n")); + + ok1(write_sall(sfd1, "ANSWER 2\n")); + ok1(write_sall(sfd2, "ANSWER 1")); + + /* Nothing, until client 2 answers. */ + ok1(no_input(sfd1)); + ok1(write_sall(sfd2, "\n")); + + ok1(input_is(sfd1, "The Oracle spake thus:\nANSWER 1\n")); + ok1(input_is(sfd2, "The Oracle spake thus:\nANSWER 2\n")); /* Sockets should be dead now. */ ok1(read(sfd1, &c, 1) == 0);