From 3f019e8272e33869312a7b5a94af94e14c81cd15 Mon Sep 17 00:00:00 2001 From: Chase Douglas Date: Tue, 13 Mar 2012 23:30:39 -0700 Subject: Print more helpful error message when X server fails to start Usually, xorg-gtest requires the dummy video driver. It also requires an X server at least version 1.12, or to be run as root when testing with a previous X server. Print this information when the server fails to start, and point the user to the log file for further details. Signed-off-by: Chase Douglas Reviewed-By: Christopher Halse Rogers --- src/environment.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index 3da27cb..f4bb9e1 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -122,16 +122,22 @@ void xorg::testing::Environment::SetUp() { int status; int pid = waitpid(d_->process.Pid(), &status, WNOHANG); - if (pid == d_->process.Pid()) - throw std::runtime_error("Dummy X server failed to start, did you run as " - "root?"); - else if (pid == 0) + if (pid == d_->process.Pid()) { + std::string message; + message += "X server failed to start. Ensure that the \"dummy\" video " + "driver is installed. If the X.org server is older than 1.12, " + "tests will need to be run as root. Check "; + message += d_->path_to_log_file; + message += " for any errors"; + throw std::runtime_error(message); + } else if (pid == 0) { sleep(1); /* Give the dummy X server some time to start */ - else if (pid == -1) + } else if (pid == -1) { throw std::runtime_error("Could not get status of dummy X server " "process"); - else + } else { throw std::runtime_error("Invalid child PID returned by Process::Wait()"); + } } throw std::runtime_error("Unable to open connection to dummy X server"); -- cgit v1.2.3