[PATCH xorg-gtest 3/5] xserver: add destructor to tear down the server

Peter Hutterer peter.hutterer at who-t.net
Thu Aug 9 22:38:13 PDT 2012


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 include/xorg/gtest/xorg-gtest-xserver.h | 1 +
 src/xserver.cpp                         | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h
index ee2b0e3..f3bda9b 100644
--- a/include/xorg/gtest/xorg-gtest-xserver.h
+++ b/include/xorg/gtest/xorg-gtest-xserver.h
@@ -59,6 +59,7 @@ namespace testing {
 class XServer : public xorg::testing::Process {
   public:
     XServer();
+    ~XServer();
 
     /**
      * Start a new server. If no binary is given, the server started is the
diff --git a/src/xserver.cpp b/src/xserver.cpp
index 244a96e..86c8484 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -68,6 +68,12 @@ xorg::testing::XServer::XServer() : d_(new Private) {
   SetDisplayNumber(d_->display_number);
 }
 
+xorg::testing::XServer::~XServer() {
+  if (Pid() > 0)
+    if (!Terminate(3000))
+      Kill(300);
+}
+
 void xorg::testing::XServer::SetDisplayNumber(unsigned int display_number) {
     d_->display_number = display_number;
 
-- 
1.7.11.2



More information about the xorg-devel mailing list