summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-10-29 09:25:42 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-11-07 13:14:08 +1000
commit800d2c0a4f25d7c92c1db27d9945c746bd08f0cb (patch)
tree3c0dbba91f4c87db3e56353bf8a8d17efdaf9e67
parent07dabf1d9044fb819a0728a3095bda065e794e0c (diff)
Move default log/config setting back to environment
This was moved out of the Environment when the XServer class was added, but it really doesn't belong there. Users of XServer should set custom config and log file paths (if any) directly instead of having to undo the libraries' defaults. Move it back into the environment to avoid breaking users of that, but really, this shouldn't even be in the environment either but rather in the caller that needs those defaults. Also move default path and display settings. Note that these are the same defaults in the environment and in the server. Since we can't rely on -displayfd yet, I'll leave the default display in XServer to ensure the server always starts up (:133 is not likely to be in use) and to auto-compose the display string for XOpenDisplay(). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/environment.cpp17
-rw-r--r--src/xserver.cpp3
-rw-r--r--test/Makefile.am3
-rw-r--r--test/xserver-test.cpp8
4 files changed, 20 insertions, 11 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 44d6b2e..6799427 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -42,8 +42,14 @@
#include <X11/Xlib.h>
+#include "defines.h"
+
struct xorg::testing::Environment::Private {
- Private() : display(-1) {
+ Private() : path_to_conf(DUMMY_CONF_PATH),
+ path_to_log_file(DEFAULT_XORG_LOGFILE),
+ path_to_server(DEFAULT_XORG_SERVER),
+ display(DEFAULT_DISPLAY)
+ {
}
std::string path_to_conf;
std::string path_to_log_file;
@@ -99,12 +105,9 @@ void xorg::testing::Environment::SetDisplayNumber(int display_num)
}
void xorg::testing::Environment::SetUp() {
- if (d_->display >= 0)
- d_->server.SetDisplayNumber(d_->display);
- if (d_->path_to_log_file.length())
- d_->server.SetOption("-logfile", d_->path_to_log_file);
- if (d_->path_to_conf.length())
- d_->server.SetOption("-config", d_->path_to_log_file);
+ 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);
Process::SetEnv("DISPLAY", d_->server.GetDisplayString(), true);
diff --git a/src/xserver.cpp b/src/xserver.cpp
index c511fab..0c8f342 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -52,9 +52,6 @@ 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;
diff --git a/test/Makefile.am b/test/Makefile.am
index cab7cf7..a1f94cb 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -55,7 +55,8 @@ process_test_helper_SOURCES = process-test-helper.cpp
process_test_helper_CPPFLAGS = $(AM_CPPFLAGS)
xserver_test_SOURCES = xserver-test.cpp
-xserver_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include
+xserver_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include \
+ -DDUMMY_CONF_PATH="\"$(top_srcdir)/data/xorg/gtest/dummy.conf\""
xserver_test_LDADD = $(tests_libraries)
xserver_test_helper_SOURCES = xserver-test-helper.cpp
diff --git a/test/xserver-test.cpp b/test/xserver-test.cpp
index e41267d..70402fc 100644
--- a/test/xserver-test.cpp
+++ b/test/xserver-test.cpp
@@ -20,6 +20,7 @@ TEST(XServer, LogRemoval)
XServer server;
server.SetOption("-logfile", logfile);
+ server.SetOption("-config", DUMMY_CONF_PATH);
server.Start();
server.Terminate(3000);
server.RemoveLogFile();
@@ -63,6 +64,7 @@ TEST(XServer, WaitForSIGUSR1)
for (int i = 0; i < 20; i++) {
XServer server;
server.SetOption("-logfile", "/tmp/xorg-testing-xserver-sigusr1.log");
+ server.SetOption("-config", DUMMY_CONF_PATH);
server.SetOption("-noreset", "");
server.Start();
ASSERT_EQ(server.GetState(), Process::RUNNING);
@@ -103,6 +105,7 @@ TEST(XServer, WaitForDeviceEventMask)
XServer server;
server.SetOption("-logfile", "/tmp/Xorg-WaitForDevice.log");
+ server.SetOption("-config", DUMMY_CONF_PATH);
server.SetOption("-noreset", "");
server.Start();
ASSERT_EQ(server.GetState(), Process::RUNNING);
@@ -165,6 +168,7 @@ TEST(XServer, WaitForExistingDevice)
XServer server;
server.SetOption("-logfile", "/tmp/Xorg-WaitForDevice.log");
+ server.SetOption("-config", DUMMY_CONF_PATH);
server.SetOption("-noreset", "");
server.Start();
ASSERT_EQ(server.GetState(), Process::RUNNING);
@@ -180,6 +184,7 @@ TEST(XServer, WaitForNewDevice)
XServer server;
server.SetOption("-logfile", "/tmp/Xorg-WaitForDevice.log");
+ server.SetOption("-config", DUMMY_CONF_PATH);
server.SetOption("-noreset", "");
server.Start();
ASSERT_EQ(server.GetState(), Process::RUNNING);
@@ -197,6 +202,7 @@ TEST(XServer, IOErrorException)
ASSERT_THROW({
XServer server;
server.SetOption("-logfile", "/tmp/xorg-io-error-test.log");
+ server.SetOption("-config", DUMMY_CONF_PATH);
server.SetOption("-noreset", "");
server.Start();
ASSERT_EQ(server.GetState(), Process::RUNNING);
@@ -224,6 +230,7 @@ TEST(XServer, KeepAlive)
XServer server;
server.SetOption("-logfile", "/tmp/Xorg-keepalive.log");
+ server.SetOption("-config", DUMMY_CONF_PATH);
server.SetOption("-noreset", "");
server.Start();
ASSERT_EQ(server.GetState(), Process::RUNNING);
@@ -278,6 +285,7 @@ TEST(XServer, RemoveOption)
{
XServer server;
server.SetOption("-fail", "yes");
+ server.SetOption("-logfile", "/tmp/Xorg-remove-option.log");
server.Start(TEST_ROOT_DIR "/xserver-test-helper");
ASSERT_EQ(server.GetState(), Process::FINISHED_FAILURE);