1 #include "TestServer.hpp"
9 TestServer::TestServer()
12 "./blank" BLANK_SUFFIX,
13 { "blank", "--server", "--save-path", dir.Path(), "--cmd-port", "12354" },
18 // wait for command service startup
19 // TODO: timeouts for reading from process
20 WaitOutputLine("listening on TCP port 12354");
21 // connect to command service
22 conn = tcp::Socket("localhost", 12354);
25 TestServer::~TestServer() {
30 void TestServer::WaitOutputLine(const std::string &expected) {
33 if (!serv_buf.Extract(line)) {
34 // buffer exhausted, fetch more data
35 serv_buf.Update(proc.ReadOut(serv_buf.WriteHead(), serv_buf.Remain()));
38 if (line == expected) {
41 std::cerr << "ignoring line: " << line << std::endl;
46 void TestServer::WaitCommandMessage(const std::string &line) {
47 WaitCommandLine(" > " + line);
50 void TestServer::WaitCommandError(const std::string &line) {
51 WaitCommandLine(" ! " + line);
54 void TestServer::WaitCommandBroadcast(const std::string &line) {
55 WaitCommandLine(" @ " + line);
58 void TestServer::WaitCommandLine(const std::string &expected) {
61 if (!serv_buf.Extract(line)) {
62 // buffer exhausted, fetch more data
63 serv_buf.Update(conn.Recv(serv_buf.WriteHead(), serv_buf.Remain()));
66 if (line == expected) {