[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xorg-gtest: Changes to 'upstream-unstable'



 include/xorg/gtest/environment.h |   85 +++++++++++++++++++++++++++++----------
 src/Makefile.am                  |   14 ++++--
 src/defines.h                    |    2 
 src/environment.cpp              |   48 +++++++++++++++++-----
 src/libxorg-gtest.ver            |   15 ++++++
 src/libxorg-gtest_main.ver       |    7 +++
 src/main.cpp                     |   37 ++++++++--------
 7 files changed, 155 insertions(+), 53 deletions(-)

New commits:
commit 1f4bd9c267e70cf9ac8a57f90bf1795b0fa63d6c
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Sat Feb 4 11:47:35 2012 -0800

    Add symbol version scripts
    
    It would be nice to explicitly list each class method, but there's no
    documentation on how to do it, and everything I try fails. At least this
    ensures we don't ship visible symbols that are really part of GTest.
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Reviewed-by: Stephen Webb <stephen.webb@canonical.com>

diff --git a/src/Makefile.am b/src/Makefile.am
index 1daeeb8..579ed9c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,7 +26,11 @@ libxorg_gtest_main_la_CPPFLAGS = \
 	$(AM_CPPFLAGS) \
 	$(GTEST_CPPFLAGS)
 
-libxorg_gtest_la_LDFLAGS = $(X11_LIBS)
-libxorg_gtest_main_la_LDFLAGS = $(X11_LIBS)
+libxorg_gtest_la_LDFLAGS = $(X11_LIBS) -Wl,--version-script=libxorg-gtest.ver
+libxorg_gtest_main_la_LDFLAGS = \
+	$(X11_LIBS) \
+	-Wl,--version-script=libxorg-gtest_main.ver
 
 AM_CXXFLAGS = -I$(top_srcdir)/include
+
+EXTRA_DIST = libxorg-gtest.ver libxorg-gtest_main.ver
diff --git a/src/libxorg-gtest.ver b/src/libxorg-gtest.ver
new file mode 100644
index 0000000..e66c83a
--- /dev/null
+++ b/src/libxorg-gtest.ver
@@ -0,0 +1,15 @@
+XORG_GTEST_1.0 {
+    global:
+        extern "C++" {
+            xorg::testing::*;
+            "typeinfo for xorg::testing::Environment";
+            "typeinfo for xorg::testing::Test";
+            "typeinfo name for xorg::testing::Environment";
+            "typeinfo name for xorg::testing::Test";
+            "vtable for xorg::testing::Environment";
+            "vtable for xorg::testing::Test";
+        };
+
+    local:
+        *;
+};
diff --git a/src/libxorg-gtest_main.ver b/src/libxorg-gtest_main.ver
new file mode 100644
index 0000000..001ce91
--- /dev/null
+++ b/src/libxorg-gtest_main.ver
@@ -0,0 +1,7 @@
+XORG_GTEST_1.0 {
+    global:
+        main;
+
+    local:
+        *;
+};

commit 4216fddec31fed8b141f6d6f233c31e73e651fde
Author: Daniel d'Andrada <daniel.dandrada@canonical.com>
Date:   Mon Feb 6 09:29:46 2012 -0200

    Make Environment API property-based.
    
    Instead of shoving all parameters in the constructor.
    
    Signed-off-by: Daniel d'Andrada <daniel.dandrada@canonical.com>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/include/xorg/gtest/environment.h b/include/xorg/gtest/environment.h
index 3996507..843c451 100644
--- a/include/xorg/gtest/environment.h
+++ b/include/xorg/gtest/environment.h
@@ -47,16 +47,11 @@ namespace testing {
  * Either associate the environment manually
  * with the overall testing framework like
  * @code
- * std::string xorg_conf_path("conf/dummy.conf");
- * std::string xorg_log_file_path("/tmp/MyDummyXorg.log");
- * int xorg_display = 133;
- * std::string server("Xorg");
- *
- * xorg::testing::Environment* environment = new xorg::testing::Environment(
- *       xorg_conf_path,
- *       server,
- *       xorg_display);
- * environment->set_log_file(xorg_log_file_path);
+ * xorg::testing::Environment* environment = new xorg::testing::Environment;
+ * environment->set_server("Xorg");
+ * environment->set_display(133);
+ * environment->set_conf_file("conf/dummy.conf");
+ * environment->set_log_file("/tmp/MyDummyXorg.log");
  * testing::AddGlobalTestEnvironment(environment);
  * @endcode
  * or link to libxorg-gtest_main.
@@ -65,28 +60,78 @@ class Environment : public ::testing::Environment {
  public:
   /**
    * Constructs an object to provide a global X server dummy environment.
-   * @param path_to_conf Path to xserver configuration.
-   * @param path_to_server Path to xserver executable.
-   * @param display Display port of dummy xserver instance.
    */
-  Environment(const std::string& path_to_conf,
-              const std::string& path_to_server = "Xorg", int display = 133);
+  Environment();
 
   virtual ~Environment();
 
   /**
-   * Sets the path where the xserver log file will be created.
-   * @param path_to_log_file Path to xserver logfile.
+   * Sets the path where the server log file will be created.
+   *
+   * The path will be passed on to the server via the command line argument
+   * "-logfile". The default value is "/tmp/Xorg.GTest.log".
+   *
+   * @param path_to_log_file Path to server logfile.
    */
   void set_log_file(const std::string& path_to_log_file);
 
   /**
-   * Returns the path where the xserver log file will be created.
-   * Its default value is "/tmp/Xorg.GTest.log"
-   * @return Path to xserver logfile.
+   * Returns the path where the server log file will be created.
+   *
+   * @return Path to server logfile.
    */
   const std::string& log_file() const;
 
+  /**
+   * Sets the path to the desired server configuration file.
+   *
+   * The path will be passed on to the server via the command line argument
+   * "-config". The default value is "[datadir]/xorg/gtest/dummy.conf".
+   *
+   * @param path_conf_file Path to a Xorg X server .conf file.
+   */
+  void set_conf_file(const std::string& path_conf_file);
+
+  /**
+   * Returns the path of the server configuration file to be used.
+   *
+   * @return File path of the server configuration currently set
+   */
+  const std::string& conf_file() const;
+
+  /**
+   * Sets the path to the server executable
+   *
+   * The default value is "Xorg".
+   *
+   * @param path_to_server Path to an X.org server executable
+   */
+  void set_server(const std::string& path_to_server);
+
+  /**
+   * Returns the path of the server executable to be used.
+   *
+   * @return Path to server executable.
+   */
+  const std::string& server() const;
+
+  /**
+   * Sets the display number that the server will use.
+   *
+   * The display number will be passed on to the server via the command line.
+   * The default value is 133.
+   *
+   * @param diplay_num A display number.
+   */
+  void set_display(int display_num);
+
+  /**
+   * Returns the display number of the server instance.
+   *
+   * @return Display number of the server.
+   */
+  int display() const;
+
  protected:
   /**
    * Starts the dummy X server.
diff --git a/src/Makefile.am b/src/Makefile.am
index d1b5995..1daeeb8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,8 @@ libxorg_gtest_la_SOURCES = \
 
 libxorg_gtest_la_CPPFLAGS = \
 	$(AM_CPPFLAGS) \
-	$(GTEST_CPPFLAGS)
+	$(GTEST_CPPFLAGS) \
+	-DDUMMY_CONF_PATH="\"$(library_datadir)/dummy.conf\""
 
 libxorg_gtest_main_la_SOURCES = \
 	defines.h \
@@ -23,8 +24,7 @@ library_data_DATA = $(top_srcdir)/conf/dummy.conf
 
 libxorg_gtest_main_la_CPPFLAGS = \
 	$(AM_CPPFLAGS) \
-	$(GTEST_CPPFLAGS) \
-	-DDUMMY_CONF_PATH="\"$(library_datadir)/dummy.conf\""
+	$(GTEST_CPPFLAGS)
 
 libxorg_gtest_la_LDFLAGS = $(X11_LIBS)
 libxorg_gtest_main_la_LDFLAGS = $(X11_LIBS)
diff --git a/src/defines.h b/src/defines.h
index 6b5bcac..3bfc1da 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -2,5 +2,7 @@
 #define XORGGTEST_DEFINES
 
 #define DEFAULT_XORG_LOGFILE "/tmp/Xorg.GTest.log"
+#define DEFAULT_XORG_SERVER "Xorg"
+#define DEFAULT_DISPLAY 133
 
 #endif
diff --git a/src/environment.cpp b/src/environment.cpp
index a888454..10db3c7 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -36,22 +36,20 @@
 #include <X11/Xlib.h>
 
 struct xorg::testing::Environment::Private {
-  Private(const std::string& conf, const std::string& server, int display_num)
-      : path_to_conf(conf), path_to_log_file(DEFAULT_XORG_LOGFILE),
-        path_to_server(server), display(display_num) {
+  Private()
+      : path_to_conf(DUMMY_CONF_PATH), path_to_log_file(DEFAULT_XORG_LOGFILE),
+        path_to_server(DEFAULT_XORG_SERVER), display(DEFAULT_DISPLAY) {
   }
 
-  const std::string path_to_conf;
+  std::string path_to_conf;
   std::string path_to_log_file;
-  const std::string path_to_server;
-  const int display;
+  std::string path_to_server;
+  int display;
   Process process;
 };
 
-xorg::testing::Environment::Environment(const std::string& path_to_conf,
-                                        const std::string& path_to_server,
-                                        int display)
-    : d_(new Private(path_to_conf, path_to_server, display)) {
+xorg::testing::Environment::Environment()
+    : d_(new Private) {
 }
 
 xorg::testing::Environment::~Environment() {}
@@ -66,6 +64,36 @@ const std::string& xorg::testing::Environment::log_file() const
   return d_->path_to_log_file;
 }
 
+void xorg::testing::Environment::set_conf_file(const std::string& path_conf_file)
+{
+  d_->path_to_conf = path_conf_file;
+}
+
+const std::string& xorg::testing::Environment::conf_file() const
+{
+  return d_->path_to_conf;
+}
+
+void xorg::testing::Environment::set_server(const std::string& path_to_server)
+{
+  d_->path_to_server = path_to_server;
+}
+
+const std::string& xorg::testing::Environment::server() const
+{
+  return d_->path_to_server;
+}
+
+void xorg::testing::Environment::set_display(int display_num)
+{
+  d_->display = display_num;
+}
+
+int xorg::testing::Environment::display() const
+{
+  return d_->display;
+}
+
 void xorg::testing::Environment::SetUp() {
   static char display_string[6];
   snprintf(display_string, 6, ":%d", d_->display);
diff --git a/src/main.cpp b/src/main.cpp
index 10a94bd..7b482e7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -30,33 +30,28 @@ namespace {
 
 int help = false;
 int no_dummy_server = false;
-int xorg_conf = false;
-int xorg_display_opt = false;
+int xorg_conf_specified = false;
+int xorg_display_specified = false;
 int xorg_logfile_specified = false;
-int server = false;
+int server_specified = false;
 
 const struct option longopts[] = {
   { "help", no_argument, &help, true, },
   { "no-dummy-server", no_argument, &no_dummy_server, true, },
-  { "xorg-conf", required_argument, &xorg_conf, true, },
-  { "xorg-display", required_argument, &xorg_display_opt, true, },
+  { "xorg-conf", required_argument, &xorg_conf_specified, true, },
+  { "xorg-display", required_argument, &xorg_display_specified, true, },
   { "xorg-logfile", required_argument, &xorg_logfile_specified, true, },
-  { "server", required_argument, &server, true, },
+  { "server", required_argument, &server_specified, true, },
   { NULL, 0, NULL, 0 }
 };
 
 } // namespace
 
 int main(int argc, char *argv[]) {
-  /* Default Xorg dummy conf path. */
-  std::string xorg_conf_path(DUMMY_CONF_PATH);
+  std::string xorg_conf_path;
   std::string xorg_log_file_path;
-
-  /* Default X display */
-  int xorg_display = 133;
-
-  /* Default Xorg executable */
-  std::string server("Xorg");
+  int xorg_display = -1;
+  std::string server;
 
   testing::InitGoogleTest(&argc, argv);
 
@@ -109,10 +104,16 @@ int main(int argc, char *argv[]) {
   }
 
   if (!no_dummy_server) {
-    xorg::testing::Environment* environment = new xorg::testing::Environment(
-        xorg_conf_path,
-        server,
-        xorg_display);
+    xorg::testing::Environment* environment = new xorg::testing::Environment;
+
+    if (xorg_conf_specified)
+      environment->set_conf_file(xorg_conf_path);
+
+    if (server_specified)
+      environment->set_server(server);
+
+    if (xorg_display_specified)
+      environment->set_display(xorg_display);
 
     if (xorg_logfile_specified)
         environment->set_log_file(xorg_log_file_path);


Reply to: