Commit 60e6db66 authored by Peter Hutterer's avatar Peter Hutterer
Browse files

xserver: add RemoveLogFile()



Simple unlink() call to the logfile in use. The log file is only removed if
the server was started and terminated or finished successfully. If it was
never started or the startup failed for some reason, this function does
nothing. Behaviour can be overridden by forcing the removal.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarChase Douglas <chase.douglas@canonical.com>
parent 81fe80e8
...@@ -94,6 +94,18 @@ class XServer : public xorg::testing::Process { ...@@ -94,6 +94,18 @@ class XServer : public xorg::testing::Process {
*/ */
virtual bool Kill(unsigned int timeout = 0); virtual bool Kill(unsigned int timeout = 0);
/**
* Remove the log file used by this server. By default, this function
* only removes the log file if the server was terminated or finished
* with an exit code of 0.
*
* If force is true, the log file is removed regardless of the state of
* the server.
*
* @param force Force removal of the log file
*/
void RemoveLogFile(bool force = false);
/** /**
* Waits until this server is ready to take connections. * Waits until this server is ready to take connections.
*/ */
......
...@@ -367,6 +367,12 @@ bool xorg::testing::XServer::Kill(unsigned int timeout) { ...@@ -367,6 +367,12 @@ bool xorg::testing::XServer::Kill(unsigned int timeout) {
return true; return true;
} }
void xorg::testing::XServer::RemoveLogFile(bool force) {
enum Process::State state = GetState();
if (force || state == Process::TERMINATED || state == Process::FINISHED_SUCCESS)
unlink(d_->options["-logfile"].c_str());
}
void xorg::testing::XServer::SetOption(const std::string &key, const std::string &value) { void xorg::testing::XServer::SetOption(const std::string &key, const std::string &value) {
d_->options[key] = value; d_->options[key] = value;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment