X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=tst%2Fintegration%2FTestServer.cpp;fp=tst%2Fintegration%2FTestServer.cpp;h=0000000000000000000000000000000000000000;hb=307482574d3acac09e38263de521a1826ceec7ce;hp=cb5819de585d2ea51d4801cffd718bcbd74419c8;hpb=fd86376a8e7d3f1b09be3d018f772ef884937238;p=blank.git diff --git a/tst/integration/TestServer.cpp b/tst/integration/TestServer.cpp deleted file mode 100644 index cb5819d..0000000 --- a/tst/integration/TestServer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "TestServer.hpp" - -#include - - -namespace blank { -namespace test { - -TestServer::TestServer() -: dir() -, proc( - "./blank" BLANK_SUFFIX, - { "blank", "--server", "--save-path", dir.Path(), "--cmd-port", "12354" }, - { }) -, conn() -, serv_buf() -, sock_buf() { - // 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); -} - -TestServer::~TestServer() { - proc.Terminate(); -} - - -void TestServer::WaitOutputLine(const std::string &expected) { - std::string line; - while (true) { - if (!serv_buf.Extract(line)) { - // buffer exhausted, fetch more data - serv_buf.Update(proc.ReadOut(serv_buf.WriteHead(), serv_buf.Remain())); - continue; - } - if (line == expected) { - return; - } else { - std::cerr << "ignoring line: " << line << std::endl; - } - } -} - -void TestServer::WaitCommandMessage(const std::string &line) { - WaitCommandLine(" > " + line); -} - -void TestServer::WaitCommandError(const std::string &line) { - WaitCommandLine(" ! " + line); -} - -void TestServer::WaitCommandBroadcast(const std::string &line) { - WaitCommandLine(" @ " + line); -} - -void TestServer::WaitCommandLine(const std::string &expected) { - std::string line; - while (true) { - if (!serv_buf.Extract(line)) { - // buffer exhausted, fetch more data - serv_buf.Update(conn.Recv(serv_buf.WriteHead(), serv_buf.Remain())); - continue; - } - if (line == expected) { - return; - } - } -} - -} -}