[PATCH xorg-gtest 2/2] Check if log file and old log file are writable before starting X server
Chase Douglas
chase.douglas at canonical.com
Fri May 25 08:22:11 PDT 2012
Otherwise, the server will fail to start and it won't be obvious what
happened.
Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
src/environment.cpp | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/environment.cpp b/src/environment.cpp
index 68e05ce..a3a8ead 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -36,6 +36,7 @@
#include <csignal>
#include <cstdlib>
#include <cstring>
+#include <fstream>
#include <iostream>
#include <stdexcept>
@@ -114,6 +115,31 @@ void xorg::testing::Environment::SetUp() {
throw std::runtime_error(message);
}
+ /* The Xorg server won't start unless the log file and the old log file are
+ * writable. */
+ std::ofstream log_test;
+ log_test.open(d_->path_to_log_file.c_str(), std::ofstream::out);
+ log_test.close();
+ if (log_test.fail()) {
+ std::string message;
+ message += "X.org server log file ";
+ message += d_->path_to_log_file;
+ message += " is not writable.";
+ throw std::runtime_error(message);
+ }
+
+ std::string old_log_file = d_->path_to_log_file.c_str();
+ old_log_file += ".old";
+ log_test.open(old_log_file.c_str(), std::ofstream::out);
+ log_test.close();
+ if (log_test.fail()) {
+ std::string message;
+ message += "X.org old server log file ";
+ message += old_log_file;
+ message += " is not writable.";
+ throw std::runtime_error(message);
+ }
+
d_->process.Start(d_->path_to_server, d_->path_to_server.c_str(),
display_string,
"-logfile", d_->path_to_log_file.c_str(),
--
1.7.9.5
More information about the xorg-devel
mailing list