Commit 07dabf1d authored by Peter Hutterer's avatar Peter Hutterer
Browse files

xserver: add RemoveOption



Allow removing an option from the command list too.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent b80a12ca
......@@ -203,6 +203,16 @@ class XServer : public xorg::testing::Process {
*/
void SetOption(const std::string &key, const std::string &value = "");
/**
* Remove a previously set option.
*
* If an option was set through SetOption(), remove the option again. If
* the specified option has never been set, do nothing.
*
* @param [in] option Commandline option to remove
*/
void RemoveOption(const std::string &option);
/**
* Wait for a specific device to be added to the server.
*
......
......@@ -529,6 +529,10 @@ void xorg::testing::XServer::SetOption(const std::string &key, const std::string
d_->options[key] = value;
}
void xorg::testing::XServer::RemoveOption(const std::string &option) {
d_->options.erase(option);
}
const std::string& xorg::testing::XServer::GetLogFilePath() {
return d_->options["-logfile"];
}
......
process-test
process-test-helper
xserver-test
xserver-test-helper
device-test
......@@ -30,7 +30,8 @@ test_programs = process-test \
device-test
noinst_PROGRAMS = $(test_programs) \
process-test-helper
process-test-helper \
xserver-test-helper
noinst_DATA = PIXART-USB-OPTICAL-MOUSE.desc
GTEST_CPPFLAGS=-I$(top_srcdir)/gtest/include -I$(top_srcdir)/gtest
......@@ -57,6 +58,9 @@ xserver_test_SOURCES = xserver-test.cpp
xserver_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include
xserver_test_LDADD = $(tests_libraries)
xserver_test_helper_SOURCES = xserver-test-helper.cpp
xserver_test_helper_CPPFLAGS = $(AM_CPPFLAGS)
device_test_SOURCES = device-test.cpp
device_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include
device_test_LDADD = $(tests_libraries)
......
#include <string.h>
#include <stdlib.h>
/**
* Test helper. Exists with failure if "-fail yes" is passed
*/
int main(int argc, char **argv) {
for (int i = 0; i < argc; i++) {
if (strcmp(argv[i], "-fail") == 0)
exit(1);
/* test passes "-fail yes" and we expect both to be removed */
if (strcmp(argv[i], "yes") == 0)
exit(1);
}
return 0;
}
......@@ -274,6 +274,18 @@ TEST(XServer, KeepAlive)
ASSERT_EQ(errno, ESRCH);
}
TEST(XServer, RemoveOption)
{
XServer server;
server.SetOption("-fail", "yes");
server.Start(TEST_ROOT_DIR "/xserver-test-helper");
ASSERT_EQ(server.GetState(), Process::FINISHED_FAILURE);
server.RemoveOption("-fail");
server.Start(TEST_ROOT_DIR "/xserver-test-helper");
ASSERT_EQ(server.GetState(), Process::FINISHED_SUCCESS);
}
int main(int argc, char *argv[]) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
......
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