Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
test_utils.h
1 #ifndef TEST_UTILS_H_
2 #define TEST_UTILS_H_
3 
4 #include <netinet/in.h>
5 #include <sys/socket.h>
6 #include <sys/types.h>
7 #include <sys/un.h>
8 
9 #include "utilities/utils.h"
10 
11 struct TestUtils {
12  static std::string getFreePort();
13  static in_port_t getFreePortAsInt();
14  static void writePathToConfig(const boost::filesystem::path &toml_in, const boost::filesystem::path &toml_out,
15  const boost::filesystem::path &storage_path);
16  static void waitForServer(const std::string &address);
17 };
18 
19 class Process {
20  public:
21  using Result = std::tuple<int, std::string, std::string>;
22 
23  static Result spawn(const std::string &executable_to_run, const std::vector<std::string> &executable_args);
24 
25  Process(const std::string &exe_path) : exe_path_(exe_path) {}
26 
27  Process::Result run(const std::vector<std::string> &args);
28 
29  int lastExitCode() const { return last_exit_code_; }
30 
31  const std::string &lastStdOut() const { return last_stdout_; }
32 
33  const std::string &lastStdErr() const { return last_stderr_; }
34 
35  private:
36  const std::string exe_path_;
37 
38  int last_exit_code_;
39  std::string last_stdout_;
40  std::string last_stderr_;
41 };
42 
43 #endif // TEST_UTILS_H_
Process
Definition: test_utils.h:19
TestUtils
Definition: test_utils.h:11