diff options
author | Thomas Voß <thomas.voss@rub.de> | 2011-12-16 11:44:34 +0100 |
---|---|---|
committer | Thomas Voß <thomas.voss@rub.de> | 2011-12-16 11:44:34 +0100 |
commit | 37906b3c6431e470a07bbf5fd26784f5116b141c (patch) | |
tree | e154a01c77c09d903a3f0a926ce47534556cbf62 | |
parent | 67c98e96ab8ee10e2d399d1ed4fd1f20e3daffd5 (diff) | |
parent | 5f10cf0d7bc2492e53bba8dc2105c8a9b8445a18 (diff) |
Merged in lp:~chasedouglas/xorg-gtest/fixes.
-rw-r--r-- | Makefile.am | 9 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | doc/Makefile.am | 12 | ||||
-rw-r--r-- | examples/Makefile.am | 6 | ||||
-rw-r--r-- | include/xorg/gtest/environment.h | 10 | ||||
-rw-r--r-- | include/xorg/gtest/process.h | 44 | ||||
-rw-r--r-- | include/xorg/gtest/test.h | 11 | ||||
-rw-r--r-- | m4/gtest.m4 | 7 | ||||
-rw-r--r-- | src/environment.cpp | 2 | ||||
-rw-r--r-- | src/process.cpp | 2 |
10 files changed, 59 insertions, 47 deletions
diff --git a/Makefile.am b/Makefile.am index b0319ac..b79c16c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,10 @@ libxorg_gtest_la_SOURCES = \ src/process.cpp \ src/test.cpp +libxorg_gtest_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(GTEST_CPPFLAGS) + libxorg_gtest_main_la_SOURCES = \ src/main.cpp @@ -19,7 +23,10 @@ library_include_HEADERS = \ library_datadir = $(datadir)/xorg/gtest library_data_DATA = conf/dummy.conf -libxorg_gtest_main_la_CPPFLAGS = $(AM_CPPFLAGS) -DDUMMY_CONF_PATH="\"$(library_datadir)/dummy.conf\"" +libxorg_gtest_main_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(GTEST_CPPFLAGS) \ + -DDUMMY_CONF_PATH="\"$(library_datadir)/dummy.conf\"" libxorg_gtest_la_LDFLAGS = $(X11_LIBS) libxorg_gtest_main_la_LDFLAGS = $(X11_LIBS) diff --git a/configure.ac b/configure.ac index 6b56e3f..9e58dc4 100644 --- a/configure.ac +++ b/configure.ac @@ -34,8 +34,7 @@ AC_CHECK_GTEST AS_IF([test "x$ac_cv_lib_gtest_main" != xyes], AC_MSG_ERROR([package 'gtest' not found])) -AC_SUBST([GTEST_LDFLAGS]) -AC_SUBST([GTEST_CXXFLAGS]) +AC_SUBST([GTEST_CPPFLAGS]) AC_SUBST(DUMMY_CONF_PATH, "$datadir/xorg/gtest/dummy.conf") diff --git a/doc/Makefile.am b/doc/Makefile.am index 87e850f..4e809e1 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -21,11 +21,9 @@ ## <http://www.gnu.org/licenses/>. ## -dist_doc_DATA = \ +EXTRA_DIST = \ Doxyfile -# dist_man_MANS = geistest.1 - doc-html: doc-html-doxygen doc-man: doc-man-doxygen @@ -41,9 +39,11 @@ doc-man-doxygen: doc-pdf-doxygen: doxygen -install-data-local: api/html - $(INSTALL) -d $(DESTDIR)$(docdir) - cp -a api/html $(DESTDIR)$(docdir) +install-data-local: + if [ -d api/html ]; then \ + $(INSTALL) -d $(DESTDIR)$(docdir); \ + cp -a api/html $(DESTDIR)$(docdir); \ + fi clean-local: -rm -rf *.pdf *.html api diff --git a/examples/Makefile.am b/examples/Makefile.am index 9bb5ee7..3f6a8cc 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -22,4 +22,8 @@ noinst_PROGRAMS = xorg_gtest_example xorg_gtest_example_SOURCES = xorg-gtest.cpp -xorg_gtest_example_LDFLAGS = -lxorg-gtest -lxorg-gtest_main -lgtest -lpthread -lX11
\ No newline at end of file +xorg_gtest_example_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(GTEST_CPPFLAGS) + +xorg_gtest_example_LDFLAGS = -lxorg-gtest -lxorg-gtest_main -lgtest -lpthread -lX11 diff --git a/include/xorg/gtest/environment.h b/include/xorg/gtest/environment.h index 8d3901b..fd550e7 100644 --- a/include/xorg/gtest/environment.h +++ b/include/xorg/gtest/environment.h @@ -71,11 +71,13 @@ class Environment : public ::testing::Environment { const std::string& path_to_server = "Xorg", int display = 133); virtual ~Environment(); + + protected: /** * Starts the dummy X server. * - * Reimplemented from ::testing::Environment. Should only be called by subclasses. - * See Google %Test documentation for details. + * Reimplemented from ::testing::Environment. See Google %Test documentation + * for details. * * @throws std::runtime_error if a dummy X server cannot be started. * @@ -88,8 +90,8 @@ class Environment : public ::testing::Environment { /** * Stops the dummy X server. * - * Reimplemented from ::testing::Environment. Should only be called by subclasses. - * See Google %Test documentation for details. + * Reimplemented from ::testing::Environment. See Google %Test documentation + * for details. * * @post Dummy X server stopped. */ diff --git a/include/xorg/gtest/process.h b/include/xorg/gtest/process.h index 9cd207e..4359f21 100644 --- a/include/xorg/gtest/process.h +++ b/include/xorg/gtest/process.h @@ -56,6 +56,29 @@ namespace testing { class Process { public: /** + * Helper function to adjust the environment of the current process. + * + * @param [in] name Name of the environment variable. + * @param [in] value Value of the environment variable. + * @param [in] overwrite Whether to overwrite the value of existing env + * variables. + * + * @throws std::runtime_error if adjusting the environment does not succeed. + */ + static void SetEnv(const std::string& name, const std::string& value, + bool overwrite); + + /** + * Helper function to query the environment of the current process. + * + * @param [in] name The name of the environment variable. + * @param [out] exists If not NULL, the variable will be set to true if the + * environment variable exists and to false otherwise. + * @returns The value of the environment variable, or an empty string. + */ + static std::string GetEnv(const std::string& name, bool* exists = NULL); + + /** * Creates a child-process that is in a terminated state. */ Process(); @@ -115,27 +138,6 @@ class Process { bool Kill(); /** - * Adjusts the environment of the child process. - * - * @param [in] name Name of the environment variable. - * @param [in] value Value of the environment variable. - * @param [in] overwrite Whether to overwrite the value of existing env variables. - * - * @throws std::runtime_error if adjusting the environment does not succeed. - */ - void SetEnv(const std::string& name, const std::string& value, bool overwrite); - - /** - * Queries the environment of the child process. - * - * @param [in] name The name of the environment variable. - * @param [out] exists If not NULL, the variable will be set to true if the - * environment variable exists and to false otherwise. - * @returns The value of the environment variable, or an empty string. - */ - std::string GetEnv(const std::string& name, bool* exists = NULL) const; - - /** * Accesses the pid of the child process. * * @returns The pid of the child process or -1. diff --git a/include/xorg/gtest/test.h b/include/xorg/gtest/test.h index 64e1dda..1d6d1ea 100644 --- a/include/xorg/gtest/test.h +++ b/include/xorg/gtest/test.h @@ -49,12 +49,13 @@ class Test : public ::testing::Test { virtual ~Test(); + protected: /** * Tries to connect to an X server instance. * * Fails if no X server is running. Updates the display object. - * Reimplemented from ::testing::Test, should only be called by subclasses. - * See Google %Test documentation for details. + * Reimplemented from ::testing::Test. See Google %Test documentation for + * details. * * @post Subsequent calls to Display() return a valid pointer or NULL if an error occured. * @@ -65,15 +66,13 @@ class Test : public ::testing::Test { /** * Closes the display. * - * Reimplemented from ::testing::Test, should only be called by subclasses. - * See Google %Test documentation for details. + * Reimplemented from ::testing::Test. See Google %Test documentation for + * details. * * @post Subsequent calls to Display() return NULL. */ virtual void TearDown(); - protected: - /** * Accesses the display representing an Xlib connection. * diff --git a/m4/gtest.m4 b/m4/gtest.m4 index 6c3fc28..cd41b21 100644 --- a/m4/gtest.m4 +++ b/m4/gtest.m4 @@ -8,17 +8,16 @@ AC_DEFUN([AC_CHECK_GTEST], AC_ARG_WITH([gtest-include-path], [AS_HELP_STRING([--with-gtest-include-path], [location of the Google test headers, defaults to /usr/include])], - [GTEST_CXXFLAGS="-I$withval"], - [GTEST_CXXFLAGS='-I/usr/include']) + [GTEST_CPPFLAGS="-I$withval"]) AC_ARG_WITH([gtest-lib-path], [AS_HELP_STRING([--with-gtest-lib-path], [location of the Google test libraries])], [GTEST_LDFLAGS="-L$withval -lpthread"], - [GTEST_LDFLAGS='-lgtest -lpthread']) + [GTEST_LDFLAGS='-lpthread']) AC_LANG_PUSH(C++) - AC_CHECK_LIB([gtest], [main], [:], [:], [-lpthread]) + AC_CHECK_LIB([gtest], [main], [:], [:], [$GTEST_LDFLAGS]) AC_LANG_POP ]) # AC_CHECK_GTEST diff --git a/src/environment.cpp b/src/environment.cpp index 0b392ca..b00eaf9 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -60,7 +60,7 @@ void xorg::testing::Environment::SetUp() { d_->process.Start(d_->path_to_server, d_->path_to_server.c_str(), display_string, "-config", d_->path_to_conf.c_str(), NULL); - setenv("DISPLAY", display_string, true); + Process::SetEnv("DISPLAY", display_string, true); for (int i = 0; i < 10; ++i) { Display* display = XOpenDisplay(NULL); diff --git a/src/process.cpp b/src/process.cpp index 05a808a..bfe067d 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -115,7 +115,7 @@ void xorg::testing::Process::SetEnv(const std::string& name, } std::string xorg::testing::Process::GetEnv(const std::string& name, - bool* exists) const { + bool* exists) { const char* var = getenv(name.c_str()); if (exists != NULL) *exists = (var != NULL); |