diff options
author | Povilas Kanapickas <povilas@radix.lt> | 2020-12-19 21:42:42 +0200 |
---|---|---|
committer | Povilas Kanapickas <povilas@radix.lt> | 2021-02-07 15:23:27 +0200 |
commit | 4c45f19e9ca59c9ca15123701a550a8f6332c888 (patch) | |
tree | 0c5e181ad1dbac4537997b397754fdd645197147 | |
parent | a0976f77bcf912935bf0f8bd466e57fc20f43386 (diff) |
gtest: Add a way to disable server termination in destructor
-rw-r--r-- | gtest/include/xorg/gtest/xorg-gtest-xserver.h | 6 | ||||
-rw-r--r-- | gtest/src/xserver.cpp | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/gtest/include/xorg/gtest/xorg-gtest-xserver.h b/gtest/include/xorg/gtest/xorg-gtest-xserver.h index 5101d52..defe62c 100644 --- a/gtest/include/xorg/gtest/xorg-gtest-xserver.h +++ b/gtest/include/xorg/gtest/xorg-gtest-xserver.h @@ -104,6 +104,12 @@ class XServer : public xorg::testing::Process { bool Terminate(unsigned int timeout = 2000) override; /** + * Disable termination of the server when this class is being destroyed. This is expected + * by certain tests. + */ + void SetKeepalive(); + + /** * Kills the server. With a vengeance. * * @param [in] timeout The timeout in millis to wait for the process to diff --git a/gtest/src/xserver.cpp b/gtest/src/xserver.cpp index 0e04f0b..010ed13 100644 --- a/gtest/src/xserver.cpp +++ b/gtest/src/xserver.cpp @@ -65,6 +65,7 @@ struct xorg::testing::XServer::Private { std::string path_to_server; std::map<std::string, std::string> options; std::string version; + bool terminate_at_end = true; }; xorg::testing::XServer::XServer() : d_(new Private) { @@ -73,7 +74,7 @@ xorg::testing::XServer::XServer() : d_(new Private) { } xorg::testing::XServer::~XServer() { - if (Pid() > 0) + if (Pid() > 0 && d_->terminate_at_end) if (!Terminate(3000)) Kill(300); } @@ -567,6 +568,11 @@ bool xorg::testing::XServer::Terminate(unsigned int timeout) { return true; } +void xorg::testing::XServer::SetKeepalive() +{ + d_->terminate_at_end = false; +} + bool xorg::testing::XServer::Kill(unsigned int timeout) { if (getenv("XORG_GTEST_XSERVER_KEEPALIVE")) return true; |