[PATCH xorg-gtest 5/5] xserver: add RemoveLogFile()

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


Simple unlink() call to the logfile in use. The log file is only removed if
the server was started and terminated successfully. If it was never started
or the startup failed for some reason, this function does nothing.

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

diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h
index f3bda9b..33446a8 100644
--- a/include/xorg/gtest/xorg-gtest-xserver.h
+++ b/include/xorg/gtest/xorg-gtest-xserver.h
@@ -95,6 +95,12 @@ class XServer : public xorg::testing::Process {
     virtual bool Kill(unsigned int timeout = 0);
 
     /**
+     * Remove the log file used by this server. If the server was never
+     * started or the startup failed, this function does nothing.
+     */
+    void RemoveLogFile();
+
+    /**
      * Waits until this server is ready to take connections.
      */
     void WaitForConnections(void);
diff --git a/src/xserver.cpp b/src/xserver.cpp
index 86c8484..114c736 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -365,6 +365,11 @@ bool xorg::testing::XServer::Kill(unsigned int timeout) {
     return true;
 }
 
+void xorg::testing::XServer::RemoveLogFile() {
+  if (GetState() == TERMINATED)
+    unlink(d_->options["-logfile"].c_str());
+}
+
 void xorg::testing::XServer::SetOption(const std::string &key, const std::string &value) {
   d_->options[key] = value;
 }
-- 
1.7.11.2



More information about the xorg-devel mailing list