diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-06-27 16:07:15 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-07-12 15:10:42 +1000 |
commit | b0417d54245d97fa08f5e8b7c2669f2f4b28ba64 (patch) | |
tree | ab44a84199a5f85eda725a205bea84070097584c | |
parent | d5e07ba3f95a64472e9df52fc1c7efc20c5ead4a (diff) |
xserver: store config, logfile, binary paths in the XServer object
And provide a SetOption call for the various commandline options that the
server may take.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | include/xorg/gtest/xorg-gtest-xserver.h | 19 | ||||
-rw-r--r-- | src/environment.cpp | 2 | ||||
-rw-r--r-- | src/xserver.cpp | 20 |
3 files changed, 41 insertions, 0 deletions
diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h index e717039..569387b 100644 --- a/include/xorg/gtest/xorg-gtest-xserver.h +++ b/include/xorg/gtest/xorg-gtest-xserver.h @@ -56,6 +56,14 @@ class XServer : public xorg::testing::Process { void SetDisplayNumber(unsigned int display_number); /** + * Set the path to the server binary to be started. Optional call, if + * not invoked the built-in default path is chosen. + * + * @param [in] path_to_server The path to the binary + */ + void SetServerPath(const std::string &path_to_server); + + /** * Get the display number from this server. If the server was not * started yet, this function returns the display number the server will * be started on. @@ -73,6 +81,17 @@ class XServer : public xorg::testing::Process { const std::string& GetDisplayString(void); /** + * Set startup options for the server. + * + * For arguments that do not take/need a value, use the empty string as + * value. + * + * @param [in] key Commandline option + * @param [in] value Option value (if any) + */ + void SetOption(const std::string &key, const std::string &value); + + /** * Wait for a specific device to be added to the server. * * @param [in] display The X display connection diff --git a/src/environment.cpp b/src/environment.cpp index 9a524ab..2f1c4e2 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -142,6 +142,8 @@ 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", diff --git a/src/xserver.cpp b/src/xserver.cpp index 9cd07f4..203c0f9 100644 --- a/src/xserver.cpp +++ b/src/xserver.cpp @@ -27,6 +27,7 @@ ******************************************************************************/ #include "xorg/gtest/xorg-gtest-xserver.h" +#include "defines.h" #include <sys/types.h> #include <sys/wait.h> @@ -40,12 +41,23 @@ #include <cstring> #include <stdexcept> #include <vector> +#include <map> #include <X11/extensions/XInput2.h> struct xorg::testing::XServer::Private { + Private() + : display_number(DEFAULT_DISPLAY), + path_to_server(DEFAULT_XORG_SERVER) { + + options["-config"] = DUMMY_CONF_PATH; + options["-logfile"] = DEFAULT_XORG_LOGFILE; + } + unsigned int display_number; std::string display_string; + std::string path_to_server; + std::map<std::string, std::string> options; }; xorg::testing::XServer::XServer() : d_(new Private) { @@ -69,6 +81,10 @@ const std::string& xorg::testing::XServer::GetDisplayString(void) { return d_->display_string; } +void xorg::testing::XServer::SetServerPath(const std::string &path_to_server) { + d_->path_to_server = path_to_server; +} + bool xorg::testing::XServer::WaitForEvent(::Display *display, time_t timeout) { fd_set fds; @@ -195,3 +211,7 @@ bool xorg::testing::XServer::WaitForDevice(::Display *display, const std::string return false; } + +void xorg::testing::XServer::SetOption(const std::string &key, const std::string &value) { + d_->options[key] = value; +} |