1 #ifndef BLANK_TEST_INTEGRATION_TESTINSTANCE_HPP_
2 #define BLANK_TEST_INTEGRATION_TESTINSTANCE_HPP_
4 #include "app/Process.hpp"
5 #include "io/filesystem.hpp"
6 #include "io/LineBuffer.hpp"
16 /// Launch a blank instance with given arguments (program name
17 /// will be prepended by the constructor).
18 /// If connect is true, a command service connection will be
19 /// established during construction.
20 explicit TestInstance(const Process::Arguments &args, bool connect = false);
24 /// Write given text to program's stdin.
25 /// Data is not modified, so if you want to push a line, be
26 /// sure to include a newline character.
27 void WriteInput(const std::string &data);
29 /// read next line from program's stdout
30 void ReadOutputLine(std::string &line);
31 /// assert that the next line the program writes to stdout will
32 /// be the given one (without a trailing newline character)
33 void AssertOutputLine(const std::string &line);
34 /// wait until program writes given line to stdout
35 void WaitOutputLine(const std::string &line);
36 /// read from program's stdout until EOF
37 void ExhaustOutput(std::string &output);
38 /// assert that the program produces no more output
39 void AssertNoOutput();
41 /// read next line from program's stderr
42 void ReadErrorLine(std::string &line);
43 /// assert that the next line the program writes to stderr will
44 /// be the given one (without a trailing newline character)
45 void AssertErrorLine(const std::string &line);
46 /// wait until program writes given line to stderr
47 void WaitErrorLine(const std::string &line);
48 /// read from program's stdout until EOF
49 void ExhaustError(std::string &error);
50 /// assert that the program produces no more output on stderr
53 /// send termination signal
55 /// assert that the program has not exited
57 /// assert that the program has exited
58 void AssertTerminated();
59 /// make sure the process terminated with given status
60 void AssertExitStatus(int expected);
62 // the following methods are only valid when a command service is connected
64 /// wait for given message on the command service
65 void WaitCommandMessage(const std::string &line);
66 /// wait for given error on the command service
67 void WaitCommandError(const std::string &line);
68 /// wait for given broadcast on the command service
69 void WaitCommandBroadcast(const std::string &line);
70 /// wait for given line on the command service
71 void WaitCommandLine(const std::string &line);
73 /// send command line to program
74 void SendCommand(const std::string &);
81 LineBuffer<BUFSIZ> out_buf;
82 LineBuffer<BUFSIZ> err_buf;
83 LineBuffer<BUFSIZ> cmd_buf;