Commit 59de5d4f authored by Peter Hutterer's avatar Peter Hutterer
Browse files

xserver: move starting the process into the XServer object



Changes from hardcoded vararg call to requiring the caller to set up options
for logfile, config, etc. beforehand. The display string is automatically
added to the command line.

If no binary is given by the caller, the previously set binary path is used.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarChase Douglas <chase.douglas@canonical.com>
parent 23bd952b
......@@ -46,6 +46,14 @@ class XServer : public xorg::testing::Process {
public:
XServer();
/**
* Start a new server. If no binary is given, the server started is the
* default compiled-in server binary.
*
* @param [in] program Path to the XServer binary
*/
void Start(const std::string &program = "");
/**
* Waits until this server is ready to take connections.
*/
......
......@@ -144,12 +144,7 @@ void xorg::testing::Environment::SetUp() {
d_->server.SetDisplayNumber(d_->display);
d_->server.SetOption("-logfile", d_->path_to_log_file);
d_->server.SetOption("-config", d_->path_to_conf);
d_->server.Start(d_->path_to_server, d_->path_to_server.c_str(),
display_string,
"-logverbose", "10",
"-logfile", d_->path_to_log_file.c_str(),
"-config", d_->path_to_conf.c_str(),
NULL);
d_->server.Start(d_->path_to_server);
d_->server.WaitForConnections();
Process::SetEnv("DISPLAY", display_string, true);
......
......@@ -247,6 +247,22 @@ void xorg::testing::XServer::WaitForConnections(void) {
throw std::runtime_error("Unable to open connection to dummy X server");
}
void xorg::testing::XServer::Start(const std::string &program) {
std::vector<std::string> args;
std::map<std::string, std::string>::iterator it;
args.push_back(program);
args.push_back(std::string(GetDisplayString()));
for (it = d_->options.begin(); it != d_->options.end(); it++) {
args.push_back(it->first);
if (!it->second.empty())
args.push_back(it->second);
}
Process::Start(program.empty() ? d_->path_to_server : program, args);
}
void xorg::testing::XServer::SetOption(const std::string &key, const std::string &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