X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=tst%2Fintegration%2FTestInstance.cpp;h=71bc194da48ce4ca226d1ad3e7e91f02025cae49;hb=7f829070c9a5e4e036b483863e5ee75a3a824c38;hp=495ba6cdd413d602b0034895b06386d381843c03;hpb=0644360107ca50d681ae8b8cad608c7bc2ec7a40;p=blank.git diff --git a/tst/integration/TestInstance.cpp b/tst/integration/TestInstance.cpp index 495ba6c..71bc194 100644 --- a/tst/integration/TestInstance.cpp +++ b/tst/integration/TestInstance.cpp @@ -28,17 +28,13 @@ Process::Arguments combine_args(const TempDir &dir, const Process::Arguments &in TestInstance::TestInstance(const Process::Arguments &args, bool cmd) : dir() -, proc( - "./blank" BLANK_SUFFIX, - combine_args(dir, args, cmd), - { }) +, proc("./blank" BLANK_SUFFIX, combine_args(dir, args, cmd)) , conn() , out_buf() , err_buf() , cmd_buf() { if (cmd) { // wait for command service startup - // TODO: timeouts for reading from process WaitOutputLine("listening on TCP port 12354"); // connect to command service conn = tcp::Socket("localhost", 12354); @@ -66,7 +62,7 @@ void TestInstance::WriteInput(const string &data) { void TestInstance::ReadOutputLine(string &line) { while (!out_buf.Extract(line)) { // buffer exhausted, fetch more data - int len = proc.ReadOut(out_buf.WriteHead(), out_buf.Remain()); + int len = proc.ReadOut(out_buf.WriteHead(), out_buf.Remain(), 5000); if (len == 0) { throw runtime_error("failed read from child process' stdout"); } @@ -95,7 +91,7 @@ void TestInstance::WaitOutputLine(const string &expected) { void TestInstance::ExhaustOutput(string &output) { while (!out_buf.Extract(output)) { // buffer exhausted, fetch more data - int len = proc.ReadOut(out_buf.WriteHead(), out_buf.Remain()); + int len = proc.ReadOut(out_buf.WriteHead(), out_buf.Remain(), 5000); if (len == 0) { return; } @@ -107,7 +103,7 @@ void TestInstance::AssertNoOutput() { string output; ExhaustOutput(output); CPPUNIT_ASSERT_EQUAL_MESSAGE( - "test instanced produced unexpected output", + "test instance produced unexpected output", string(""), output); } @@ -115,7 +111,7 @@ void TestInstance::AssertNoOutput() { void TestInstance::ReadErrorLine(string &line) { while (!err_buf.Extract(line)) { // buffer exhausted, fetch more data - int len = proc.ReadErr(err_buf.WriteHead(), err_buf.Remain()); + int len = proc.ReadErr(err_buf.WriteHead(), err_buf.Remain(), 5000); if (len == 0) { throw runtime_error("failed read from child process' stderr"); } @@ -144,7 +140,7 @@ void TestInstance::WaitErrorLine(const string &expected) { void TestInstance::ExhaustError(string &error) { while (!err_buf.Extract(error)) { // buffer exhausted, fetch more data - int len = proc.ReadErr(err_buf.WriteHead(), err_buf.Remain()); + int len = proc.ReadErr(err_buf.WriteHead(), err_buf.Remain(), 5000); if (len == 0) { return; } @@ -156,7 +152,7 @@ void TestInstance::AssertNoError() { string error; ExhaustError(error); CPPUNIT_ASSERT_EQUAL_MESSAGE( - "test instanced produced unexpected error output", + "test instance produced unexpected error output", string(""), error); }