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

xorg-gtest: Changes to 'debian-experimental'



 .gitignore                                          |    5 
 COPYING                                             |    1 
 Makefile.am                                         |    2 
 README                                              |   23 
 aclocal/xorg-gtest.m4                               |   46 
 configure.ac                                        |   40 
 data/Makefile.am                                    |    4 
 data/X11/xorg.conf.d/99-virtual-test-devices.conf   |    6 
 data/xorg/gtest/dummy.conf                          |   10 
 debian/changelog                                    |    5 
 debian/control                                      |    7 
 debian/copyright                                    |   33 
 debian/libxorg-gtest-data.install                   |    1 
 debian/libxorg-gtest-dev.install                    |    2 
 debian/libxorg-gtest-doc.install                    |    1 
 debian/patches/0001-fix-example-failures.patch      |   42 
 debian/patches/0002-fix-valgrind-test-failure.patch |   20 
 debian/patches/0003-symbol-lookup.patch             |   38 
 debian/patches/series                               |    5 
 debian/rules                                        |    5 
 debian/source/format                                |    2 
 doc/Doxyfile                                        | 1720 -
 doc/Doxyfile.in                                     | 1834 +
 doc/Makefile.am                                     |   12 
 examples/Makefile.am                                |   37 
 examples/xorg-gtest-environment-example.cpp         |  101 
 examples/xorg-gtest-example.cpp                     |  103 
 gtest/Makefile.am                                   |   28 
 gtest/README                                        |    8 
 gtest/include/Makefile.am                           |   25 
 gtest/include/gtest/gtest-spi.h                     |  232 
 gtest/include/gtest/gtest.h                         |19537 ++++++++++++++++++++
 gtest/src/gtest-all.cc                              | 9118 +++++++++
 gtest/src/gtest_main.cc                             |   39 
 include/Makefile.am                                 |    9 
 include/xorg/gtest/environment.h                    |  179 
 include/xorg/gtest/evemu/device.h                   |   91 
 include/xorg/gtest/evemu/xorg-gtest-device.h        |  120 
 include/xorg/gtest/process.h                        |  166 
 include/xorg/gtest/test.h                           |  104 
 include/xorg/gtest/xorg-gtest-environment.h         |  234 
 include/xorg/gtest/xorg-gtest-process.h             |  253 
 include/xorg/gtest/xorg-gtest-test.h                |  115 
 include/xorg/gtest/xorg-gtest-xserver.h             |  295 
 include/xorg/gtest/xorg-gtest.h                     |   20 
 m4/ac_define_dir.m4                                 |   49 
 m4/gtest.m4                                         |   22 
 src/Makefile-xorg-gtest.am                          |   11 
 src/Makefile.am                                     |    2 
 src/defines.h                                       |    2 
 src/device.cpp                                      |  158 
 src/environment.cpp                                 |  136 
 src/process.cpp                                     |  171 
 src/test.cpp                                        |   29 
 src/xorg-gtest-all.cpp                              |    1 
 src/xorg-gtest_main.cpp                             |   91 
 src/xserver.cpp                                     |  587 
 test/.gitignore                                     |    5 
 test/Makefile.am                                    |   87 
 test/PIXART-USB-OPTICAL-MOUSE.desc                  |   41 
 test/device-test.cpp                                |   33 
 test/process-test-helper.cpp                        |   10 
 test/process-test.cpp                               |  379 
 test/xserver-test-helper.cpp                        |   19 
 test/xserver-test.cpp                               |  382 
 xorg-gtest.pc.in                                    |    2 
 66 files changed, 34403 insertions(+), 2492 deletions(-)

New commits:
commit 4ff2bd9bb843d1bbf87a1ed466845876dd81951c
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Thu Jan 31 16:12:04 2013 +0100

    update to recent ubuntu packaging, and then some

diff --git a/.gitignore b/.gitignore
index 6bceeb1..8d8da97 100644
--- a/.gitignore
+++ b/.gitignore
@@ -79,3 +79,4 @@ core
 doc/api
 doc/Doxyfile
 examples/xorg-gtest-environment-example
+!debian/patches/*
diff --git a/debian/changelog b/debian/changelog
index 89ddd84..7413e3d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-xorg-gtest (0.2.0-1) UNRELEASED; urgency=low
+xorg-gtest (0.7.0-1) UNRELEASED; urgency=low
 
   [ Daniel d'Andrada ]
   * Initial release
@@ -6,4 +6,7 @@ xorg-gtest (0.2.0-1) UNRELEASED; urgency=low
   [ Chase Douglas ]
   * Update to xorg-gtest-0.2.0
 
+  [ Maarten Lankhorst ]
+  * Update to xorg-gtest-0.7.0 from ubuntu's packaging
+
  -- Chase Douglas <chase.douglas@ubuntu.com>  Mon, 19 Mar 2012 17:29:10 -0700
diff --git a/debian/control b/debian/control
index 3f91e24..c6ea143 100644
--- a/debian/control
+++ b/debian/control
@@ -8,13 +8,15 @@ Build-Depends: automake,
                libgtest-dev,
                libtool,
                libx11-dev,
+               libxi-dev,
                pkg-config,
-               quilt,
+               valgrind,
                xserver-xorg-core,
                xserver-xorg-dev,
                xserver-xorg-video-dummy,
+               libevemu-dev (>= 1.0.10),
                xutils-dev (>= 1:7.7~1)
-Standards-Version: 3.9.3
+Standards-Version: 3.9.4
 Section: libs
 Vcs-Git: git://anongit.freedesktop.org/~cndougla/xorg-gtest
 Vcs-Browser: http://cgit.freedesktop.org/~cndougla/xorg-gtest
@@ -24,6 +26,7 @@ Section: libdevel
 Architecture: all
 Depends: libgtest-dev,
          libxorg-gtest-data (= ${source:Version}),
+         xserver-xorg-video-dummy,
          xutils-dev (>= 1:7.7~1),
          ${misc:Depends}
 Description: X.Org dummy testing environment for Google Test - headers
diff --git a/debian/copyright b/debian/copyright
index 845c7bd..7d79e3f 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,9 +1,10 @@
-Format: http://dep.debian.net/deps/dep5
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0
 Upstream-Name: xorg-gtest
 Source: http://cgit.freedesktop.org/xorg/test/xorg-gtest
 
 Files: *
 Copyright: 2011-2012 Canonical Ltd.
+           2012      Red Hat, Inc.
 License: GPL-3+
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
@@ -18,3 +19,33 @@ License: GPL-3+
  On Debian systems, the full text of the GNU General Public
  License version 3 can be found in the file
  `/usr/share/common-licenses/GPL-3'.
+
+Files: gtest/*
+Copyright: 2005-2008 Google Inc
+License: BSD-3-clause
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ .
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of Google Inc. nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/debian/libxorg-gtest-data.install b/debian/libxorg-gtest-data.install
index e1e90e6..cfc2bcf 100644
--- a/debian/libxorg-gtest-data.install
+++ b/debian/libxorg-gtest-data.install
@@ -1 +1,2 @@
+usr/share/X11/xorg.conf.d/99-virtual-test-devices.conf
 usr/share/xorg/gtest
diff --git a/debian/libxorg-gtest-dev.install b/debian/libxorg-gtest-dev.install
index a37d50f..bf476ab 100644
--- a/debian/libxorg-gtest-dev.install
+++ b/debian/libxorg-gtest-dev.install
@@ -1,4 +1,4 @@
-usr/include
+usr/include/xorg
 usr/lib
 usr/share/aclocal
 usr/src
diff --git a/debian/libxorg-gtest-doc.install b/debian/libxorg-gtest-doc.install
index 0e373be..7276ecd 100644
--- a/debian/libxorg-gtest-doc.install
+++ b/debian/libxorg-gtest-doc.install
@@ -1,2 +1 @@
 usr/share/doc
-usr/share/man
diff --git a/debian/patches/0001-fix-example-failures.patch b/debian/patches/0001-fix-example-failures.patch
new file mode 100644
index 0000000..4ea2e48
--- /dev/null
+++ b/debian/patches/0001-fix-example-failures.patch
@@ -0,0 +1,42 @@
+Description: Fix 'make check' failures on some hardware due to timing issues.
+Author: Stephen M. Webb <stephen.webb@canonical.com>
+--- a/examples/Makefile.am
++++ b/examples/Makefile.am
+@@ -59,7 +59,10 @@
+ TESTS = $(noinst_PROGRAMS)
+ endif
+ xorg_gtest_example_SOURCES = xorg-gtest-example.cpp
+-xorg_gtest_example_CPPFLAGS = -I$(top_srcdir)/include $(AM_CPPFLAGS)
++xorg_gtest_example_CPPFLAGS = \
++	-I$(top_srcdir)/include \
++	$(AM_CPPFLAGS) \
++	-DDUMMY_CONF_PATH="\"$(abs_top_srcdir)/data/xorg/gtest/dummy.conf\""
+ xorg_gtest_example_LDADD = \
+                            libgtest.a \
+                            libxorg-gtest.a \
+--- a/examples/xorg-gtest-example.cpp
++++ b/examples/xorg-gtest-example.cpp
+@@ -24,6 +24,7 @@
+ TEST(XServer, StartServer) {
+   XServer server;
+   server.SetOption("-logfile", LOGFILE_DIR "/xserver-startserver.log");
++  server.SetOption("-config",  DUMMY_CONF_PATH);
+   server.Start();
+ 
+   ASSERT_EQ(server.GetState(), Process::RUNNING);
+@@ -40,6 +41,7 @@
+ TEST(XServer, DisplayConnection) {
+   XServer server;
+   server.SetOption("-logfile", LOGFILE_DIR "/xserver-display-connection.log");
++  server.SetOption("-config",  DUMMY_CONF_PATH);
+   server.Start();
+ 
+   Display *dpy = XOpenDisplay(server.GetDisplayString().c_str());
+@@ -69,6 +71,7 @@
+     log << ".log";
+ 
+     server.SetOption("-logfile", log.str());
++    server.SetOption("-config",  DUMMY_CONF_PATH);
+     server.Start();
+ 
+     /* set up Display() */
diff --git a/debian/patches/0002-fix-valgrind-test-failure.patch b/debian/patches/0002-fix-valgrind-test-failure.patch
new file mode 100644
index 0000000..4c9d9db
--- /dev/null
+++ b/debian/patches/0002-fix-valgrind-test-failure.patch
@@ -0,0 +1,20 @@
+Description: Accommodate the situation in which valgrind is a wrapper script.
+Author: Stephen M. Webb <stephen.webb@canonical.com>
+--- a/test/process-test.cpp
++++ b/test/process-test.cpp
+@@ -355,6 +355,15 @@
+   } while(strstr(buff, program_invocation_short_name));
+ 
+   const char * arg = buff + strlen(buff) + 1;
++
++  /* accommodate the case that valgrind has a shell script wrapper */
++  if (0 == strcmp(buff, "/bin/sh")) {
++    if (0 == strcmp(arg, "-e")) {
++      arg += strlen(arg) + 1;
++    }
++    arg += strlen(arg) + 1;
++  }
++
+   std::vector<std::string>::const_iterator it = valgrind_args.begin();
+ 
+   it++; /* first one is "valgrind" */
diff --git a/debian/patches/0003-symbol-lookup.patch b/debian/patches/0003-symbol-lookup.patch
new file mode 100644
index 0000000..a8ea134
--- /dev/null
+++ b/debian/patches/0003-symbol-lookup.patch
@@ -0,0 +1,38 @@
+diff --git a/src/xserver.cpp b/src/xserver.cpp
+index def6a89..a36ca7e 100644
+--- a/src/xserver.cpp
++++ b/src/xserver.cpp
+@@ -436,19 +436,27 @@ static int _x_io_error_handler(Display *dpy)
+ 
+ void xorg::testing::XServer::RegisterXIOErrorHandler()
+ {
+-  XIOErrorHandler old_handler;
+-  old_handler = XSetIOErrorHandler(_x_io_error_handler);
++  XIOErrorHandler old_handler, def_handler;
+ 
+-  if (old_handler != _XDefaultIOError)
++  old_handler = XSetIOErrorHandler(NULL);
++  def_handler = XSetIOErrorHandler(_x_io_error_handler);
++
++  if (old_handler != def_handler &&
++      old_handler != _XDefaultIOError &&
++      old_handler != _x_io_error_handler)
+     XSetIOErrorHandler(old_handler);
+ }
+ 
+ void xorg::testing::XServer::RegisterXErrorHandler()
+ {
+-  XErrorHandler old_handler;
+-  old_handler = XSetErrorHandler(_x_error_handler);
++  XErrorHandler old_handler, def_handler;
++
++  old_handler = XSetErrorHandler(NULL);
++  def_handler = XSetErrorHandler(_x_error_handler);
+ 
+-  if (old_handler != _XDefaultError)
++  if (old_handler != def_handler &&
++      old_handler != _XDefaultError &&
++      old_handler != _x_error_handler)
+     XSetErrorHandler(old_handler);
+ }
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 6928140..a2e2c72 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,4 @@
-# No patches
+0001-fix-example-failures.patch
+0002-fix-valgrind-test-failure.patch
+0003-symbol-lookup.patch
+
diff --git a/debian/rules b/debian/rules
index dbc39af..4bb4b0d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,7 +4,7 @@
 #export DH_VERBOSE=1
 
 %:
-	dh $@ --parallel --with quilt,autoreconf
+	dh $@ --parallel --with autoreconf
 
 # Install xorg-gtest.pc file in architecture independent directory
 override_dh_auto_configure:
@@ -14,4 +14,5 @@ override_dh_auto_build:
 	dh_auto_build -- all doc
 
 override_dh_install:
-	dh_install --fail-missing
+	rm -rf debian/tmp/usr/include/gtest
+	dh_install --fail-missing -Xjquery.js
diff --git a/debian/source/format b/debian/source/format
index d3827e7..163aaf8 100644
--- a/debian/source/format
+++ b/debian/source/format
@@ -1 +1 @@
-1.0
+3.0 (quilt)

commit 0db8b0ec59f9b4cb736a0bb5e06c87397b98468d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Dec 14 08:54:49 2012 +1000

    xorg-gtest 0.7.0
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index efd96f5..6f2a698 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([X.org Testing Environment for Google Test],
-        [0.6.0],
+        [0.7.0],
         [],
         [xorg-gtest])
 AC_CONFIG_SRCDIR([Makefile.am])

commit 51713bc675aac5f257db8b3e87c0226b30b6e173
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Dec 18 16:17:53 2012 +1000

    xserver: usecs are usecs, not millis
    
    oops.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/xserver.cpp b/src/xserver.cpp
index 2aff401..def6a89 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -108,7 +108,7 @@ bool xorg::testing::XServer::WaitForEvent(::Display *display, time_t timeout)
 
         struct timeval timeval = {
             static_cast<time_t>(timeout / 1000),
-            static_cast<time_t>(timeout % 1000),
+            static_cast<time_t>(timeout % 1000) * 1000,
         };
 
         int ret;

commit 843755154ee49a49f2816fe833007c44be92727a
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Dec 14 11:02:12 2012 +1000

    xserver: increase default Terminate/Kill timeout to 2 seconds
    
    My box here takes just under 1200 ms to terminate a full server, which is
    just over the current default timeout of 1000, causing the examples to fail.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h
index 4802003..efe46e1 100644
--- a/include/xorg/gtest/xorg-gtest-xserver.h
+++ b/include/xorg/gtest/xorg-gtest-xserver.h
@@ -101,7 +101,7 @@ class XServer : public xorg::testing::Process {
      * @returns true if termination succeeded and, if a timout is given, the
      *          process shut down within that timeout. false otherwise.
      */
-    virtual bool Terminate(unsigned int timeout = 1000);
+    virtual bool Terminate(unsigned int timeout = 2000);
 
     /**
      * Kills the server. With a vengeance.
@@ -113,7 +113,7 @@ class XServer : public xorg::testing::Process {
      * @returns true if kill succeeded and, if a timout is given, the
      *          process shut down within that timeout. false otherwise.
      */
-    virtual bool Kill(unsigned int timeout = 1000);
+    virtual bool Kill(unsigned int timeout = 2000);
 
     /**
      * Remove the log file used by this server. By default, this function

commit a40e0de9d1fac358c08153eba08de7cfa35421cd
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Dec 14 10:32:03 2012 +1000

    process: if the wait fails because the child is still running, reset errno
    
    Prevent callers from getting odd errors if they notice the wait fails
    because the child is still running and errno is still on whatever it was
    before.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/process.cpp b/src/process.cpp
index af8b0f8..9580569 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -176,8 +176,12 @@ bool xorg::testing::Process::WaitForExit(unsigned int timeout) {
       d_->state = FINISHED_FAILURE;
     }
     return true;
-  } else
+  } else {
+    /* prevent callers from getting odd erros if they check for errno */
+    if (pid == 0)
+      errno = 0;
     return (pid == -1 && errno == ECHILD);
+  }
 }
 
 bool xorg::testing::Process::KillSelf(int signal, unsigned int timeout) {

commit 47f7797011c7c4f9d7bc5d06837c4a7891941ac0
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Dec 14 10:29:38 2012 +1000

    process: drop a few SCOPED_TRACE
    
    SCOPED_TRACE will only print if the current scope fails and this can never
    happen here. Change one message to standard printf, drop the others.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/process.cpp b/src/process.cpp
index 43ac0d6..af8b0f8 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -155,18 +155,15 @@ bool xorg::testing::Process::WaitForExit(unsigned int timeout) {
     struct timespec sig_timeout = {timeout / 1000,
                                    (timeout % 1000) * 1000000L};
 
-    if (sigtimedwait(&sig_mask, NULL, &sig_timeout) != SIGCHLD && errno != EAGAIN) {
-      SCOPED_TRACE("INFO: Failure waiting for SIGCHLD: " +
-                   std::string(strerror(errno)) + ". I slept instead.");
+    if (sigtimedwait(&sig_mask, NULL, &sig_timeout) != SIGCHLD && errno != EAGAIN)
       usleep(timeout * 1000);
-    }
 
     if (!sigismember(&sig_mask, SIGCHLD)) {
       if (sigprocmask(SIG_UNBLOCK, &sig_mask, NULL) == -1)
-        SCOPED_TRACE("WARNING: Failed to unblock SIGCHLD. Tests may behave funny.\n");
+        std::cout << "WARNING: Failed to unblock SIGCHLD. Tests may behave funny.\n";
     }
+
   } else { /* oops, can't wait for SIGCHLD, sleep instead */
-    SCOPED_TRACE("INFO: Failed to set SIGCHLD mask, sleeping instead.\n");
     usleep(timeout * 1000);
   }
 

commit b19d74930587abfb8a3fb1d4afbf18949c10637b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Dec 14 10:07:33 2012 +1000

    examples: Document two variables to silence doxygen
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/examples/xorg-gtest-environment-example.cpp b/examples/xorg-gtest-environment-example.cpp
index 92d777f..a0b9dde 100644
--- a/examples/xorg-gtest-environment-example.cpp
+++ b/examples/xorg-gtest-environment-example.cpp
@@ -91,6 +91,7 @@ public:
   }
 
 protected:
+  /** Example property that we'll use in the test */
   Atom example_prop;
 };
 
diff --git a/examples/xorg-gtest-example.cpp b/examples/xorg-gtest-example.cpp
index ac6dfba..00481fc 100644
--- a/examples/xorg-gtest-example.cpp
+++ b/examples/xorg-gtest-example.cpp
@@ -81,6 +81,7 @@ public:
     server.RemoveLogFile();
   }
 protected:
+  /** The X server instance */
   XServer server;
 };
 

commit b8be34ba0e218725a0b4641e918c954a0f817cb7
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Dec 14 10:04:50 2012 +1000

    test: restore error handler after test
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/test/xserver-test.cpp b/test/xserver-test.cpp
index 822bb23..5e24ae7 100644
--- a/test/xserver-test.cpp
+++ b/test/xserver-test.cpp
@@ -263,7 +263,8 @@ TEST(XServer, NondefaultErrorHandler)
   pid_t pid = fork();
 
   if (pid == 0) {
-    XSetErrorHandler(_test_error_handler);
+    XErrorHandler old_handler;
+    old_handler = XSetErrorHandler(_test_error_handler);
 
     XServer server;
     server.SetOption("-logfile", LOGFILE_DIR "/xorg-error-handler-test.log");
@@ -276,6 +277,7 @@ TEST(XServer, NondefaultErrorHandler)
     XColor color;
     XQueryColor(dpy, 0, &color);
     XSync(dpy, False);
+    XSetErrorHandler(old_handler);
     exit(error_handler_triggered ? 0 : 1);
   }
 

commit e3623da72cb87b0f3c11284af7a42d561a9014e3
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Dec 14 10:00:05 2012 +1000

    test: wait a bit for the server to finish
    
    Every so-often, the server doesn't terminate fast enough and we fail the
    test. Put a wait loop in.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/test/xserver-test.cpp b/test/xserver-test.cpp
index 7f949ef..822bb23 100644
--- a/test/xserver-test.cpp
+++ b/test/xserver-test.cpp
@@ -358,10 +358,15 @@ TEST(XServer, KeepAlive)
 
 TEST(XServer, RemoveOption)
 {
+  int i = 0;
   XServer server;
   server.SetOption("-fail", "yes");
   server.SetOption("-logfile", LOGFILE_DIR "/Xorg-remove-option.log");
   server.Start(TEST_ROOT_DIR "/xserver-test-helper");
+
+  while(i++ < 10 && server.GetState() == Process::RUNNING)
+    usleep(50000);
+
   ASSERT_EQ(server.GetState(), Process::FINISHED_FAILURE);
 
   server.RemoveOption("-fail");

commit b5843afd7250446d5e3ebaee2055b7f1b281df2e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Dec 14 09:39:26 2012 +1000

    test: unset environment variable after use
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/test/xserver-test.cpp b/test/xserver-test.cpp
index 32792e6..7f949ef 100644
--- a/test/xserver-test.cpp
+++ b/test/xserver-test.cpp
@@ -315,6 +315,8 @@ TEST(XServer, KeepAlive)
     server.Kill();
     ASSERT_EQ(server.GetState(), Process::RUNNING);
 
+    unsetenv("XORG_GTEST_XSERVER_KEEPALIVE");
+
     char *buffer;
     ASSERT_GT(asprintf(&buffer, "%d", server.Pid()), 0);
     ASSERT_EQ(write(pipefd[1], buffer, strlen(buffer)), (int)strlen(buffer));

commit a6a57dd418989f38a46625e33e39c7d58522610a
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Nov 23 11:16:17 2012 +1000

    xserver: default to -1/-1 for extension/opcode
    
    No need to specify those when waiting for core or extension events that are
    not GenericEvents.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h
index 11fc93d..4802003 100644
--- a/include/xorg/gtest/xorg-gtest-xserver.h
+++ b/include/xorg/gtest/xorg-gtest-xserver.h
@@ -250,7 +250,7 @@ class XServer : public xorg::testing::Process {
      *
      * @return Whether an event is available
      */
-    static bool WaitForEventOfType(::Display *display, int type, int extension, int evtype, time_t timeout = 1000);
+    static bool WaitForEventOfType(::Display *display, int type, int extension = -1, int evtype = -1, time_t timeout = 1000);
 
     /**
      * Install a default XIOErrorHandler. That error handler will throw an

commit c82885534d9658e56b4b221d8f36efef570cbd25
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Nov 22 11:40:21 2012 +1000

    Add support for starting a process through valgrind
    
    export XORG_GTEST_USE_VALGRIND="valgrind --leak-check=full"
    ./run-some-test
    
    But really, can be used with any wrapper binary. Given that valgrind is the
    main use-case here, keep the USE_VALGRIND naming instead of something more
    generic like USE_PROCESS_WRAPPER or so.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/README b/README
index 53475db..2409bdb 100644
--- a/README
+++ b/README
@@ -85,3 +85,7 @@ XORG_GTEST_XSERVER_KEEPALIVE
 XORG_GTEST_CHILD_STDOUT
   If set to any value, Process::Start() will _not_ close stdout/stdin/stderr
   for the forked child.
+XORG_GTEST_USE_VALGRIND
+  Set to the valgrind command to use when starting a process. Options must
+  be space-separated, e.g. "valgrind --leak-check=full --someotherarg"
+  Not limited to valgrind, you can specify any executable here.
diff --git a/src/process.cpp b/src/process.cpp
index a743346..43ac0d6 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -100,13 +100,22 @@ void xorg::testing::Process::Start(const std::string &program, const std::vector
     std::vector<char*> args;
     std::vector<std::string>::const_iterator it;
 
+    char *valgrind = getenv("XORG_GTEST_USE_VALGRIND");
+    if (valgrind) {
+      char *tok = strtok(valgrind, " ");
+      while(tok) {
+        args.push_back(strdup(tok));
+        tok = strtok(NULL, " ");
+      }
+    }
+
     args.push_back(strdup(program.c_str()));
 
     for (it = argv.begin(); it != argv.end(); it++)
       args.push_back(strdup(it->c_str()));
     args.push_back(NULL);
 
-    execvp(program.c_str(), &args[0]);
+    execvp(args[0], &args[0]);
 
     d_->state = ERROR;
     throw std::runtime_error("Failed to start process");
diff --git a/test/process-test.cpp b/test/process-test.cpp
index 59f96c2..3446fe1 100644
--- a/test/process-test.cpp
+++ b/test/process-test.cpp
@@ -1,3 +1,6 @@
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 #include <errno.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -264,6 +267,112 @@ TEST(Process, ForkedChildDoubleStart)
   }
 }
 
+class ProcessValgrindWrapper : public ::testing::Test,
+                               public ::testing::WithParamInterface<std::string> {
+public:
+  virtual void SetUp() {
+    CheckForValgrind();
+  }
+
+  virtual void CheckForValgrind() {
+    Process valgrind;
+
+    /* check if valgrind actually exists */
+    valgrind.Start("valgrind", "--version", NULL);
+    int status;
+    ASSERT_EQ(waitpid(valgrind.Pid(), &status, 0), valgrind.Pid());
+    ASSERT_TRUE(WIFEXITED(status));
+    ASSERT_EQ(WEXITSTATUS(status), 0) << "valgrind failed to start\n";
+  }
+};
+
+TEST_P(ProcessValgrindWrapper, ValgrindWrapper)
+{
+  XORG_TESTCASE("Use the valgrind wrapper to start valgrind");
+
+  std::string executable = GetParam();
+
+  /* now set the env and fire up valgrind */
+  setenv("XORG_GTEST_USE_VALGRIND", executable.c_str(), 1);
+  Process p;
+  p.Start("ls", NULL);
+  unsetenv("XORG_GTEST_USE_VALGRIND");
+
+  /* Check /proc/<pid>/comm to make sure valgrind
+     was started. But comm takes a while to update, it's first our binary
+     then valgrind, then memcheck-amd64 (or whatever applies)
+  */
+  char buff[1024] = {0};
+  char fname[128];
+  sprintf(fname, "/proc/%d/comm", p.Pid());
+
+  do {
+    FILE *fp = fopen(fname, "r");
+    ASSERT_TRUE(fp);
+    fgets(buff, sizeof(buff), fp);
+    fclose(fp);
+  } while(strstr(buff, program_invocation_short_name));
+
+  if (executable.compare("valgrind") == 0)
+    ASSERT_TRUE(strstr(buff, "memcheck") || strstr(buff, "valgrind"));
+  else
+    ASSERT_TRUE(strstr(buff, executable.c_str()));
+}
+
+class ProcessValgrindArgsWrapper : public ProcessValgrindWrapper {};
+
+TEST_P(ProcessValgrindArgsWrapper, ValgrindWrapperWithArgs)
+{
+  XORG_TESTCASE("Use the valgrind wrapper with additional args to start valgrind");
+
+  std::string vargs = GetParam();
+  std::vector<std::string> valgrind_args;
+  char *all_args = strdup(vargs.c_str());
+  char *tok = strtok(all_args, " ");
+  while(tok) {
+    valgrind_args.push_back(std::string(tok));
+    tok = strtok(NULL, " ");
+  }
+  free(all_args);
+
+  /* now set the env and fire up valgrind */
+  setenv("XORG_GTEST_USE_VALGRIND", vargs.c_str(), 1);
+  Process p;
+  p.Start(TEST_ROOT_DIR "process-test-helper", NULL);
+  unsetenv("XORG_GTEST_USE_VALGRIND");
+
+  ASSERT_EQ(p.GetState(), Process::RUNNING);
+
+  char buff[1024] = {0};
+  char fname[128];
+  sprintf(fname, "/proc/%d/cmdline", p.Pid());
+
+  do {
+    FILE *fp = fopen(fname, "r");
+    ASSERT_TRUE(fp);
+    fgets(buff, sizeof(buff), fp);
+    fclose(fp);
+  } while(strstr(buff, program_invocation_short_name));
+
+  const char * arg = buff + strlen(buff) + 1;
+  std::vector<std::string>::const_iterator it = valgrind_args.begin();
+
+  it++; /* first one is "valgrind" */
+
+  while(strlen(arg) && it != valgrind_args.end()) {
+    ASSERT_EQ(it->compare(arg), 0);
+    arg += strlen(arg) + 1;
+    it++;
+  }
+
+  ASSERT_EQ(it, valgrind_args.end());
+  p.Kill(100);
+}
+
+INSTANTIATE_TEST_CASE_P(, ProcessValgrindWrapper, ::testing::Values("valgrind", "ls"));
+INSTANTIATE_TEST_CASE_P(, ProcessValgrindArgsWrapper,
+                        ::testing::Values("valgrind --leak-check=full", "valgrind -q --trace-children=yes", "valgrind "));
+
 int main(int argc, char *argv[]) {
   testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();

commit 60f2cfd3b4aa3bea60a26cdc4cc6a169d8669999
Author: Keith Packard <keithp@keithp.com>
Date:   Tue Dec 4 20:32:56 2012 -0800

    Fix CFLAGS to find correct header files
    
    Need to actually use X11_CFLAGS and EVEMU_CFLAGS in CPPFLAGS, CXXFLAGS
    (and presumably CFLAGS if that were relevant).
    
    Also must search local directories before system directories for our
    header files, otherwise installed versions will override local
    versions which would be bad.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index 8d52928..efd96f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,6 +51,8 @@ AS_IF([test "x$have_evemu" = xyes], [AC_DEFINE([HAVE_EVEMU])])
 AC_SUBST(SOURCEDIR, ['${prefix}/src/xorg-gtest'])
 AC_SUBST(DUMMY_CONF_PATH, ['${datarootdir}/xorg/gtest/dummy.conf'])
 
+AC_SUBST(BASE_CPPFLAGS, ['$(X11_CFLAGS) $(EVEMU_CFLAGS)'])
+
 # Check if we can build integration tests
 AS_IF([test "x$enable_integration_tests" != xno],
       [AC_MSG_CHECKING([for X.org server])]
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 84b4dbb..b3ab863 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -39,18 +39,18 @@ libgtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
 # build xorg-gtest as static lib
 libxorg_gtest_a_SOURCES = $(top_srcdir)/src/xorg-gtest-all.cpp
 libxorg_gtest_a_CPPFLAGS = \
-	$(AM_CPPFLAGS) \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir) \
+	$(AM_CPPFLAGS) \
 	-DDUMMY_CONF_PATH="\"$(abs_top_srcdir)/data/xorg/gtest/dummy.conf\""
 libxorg_gtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
 
 # build xorg-gtest's main as separate lib for those that need it
 libxorg_gtest_main_a_SOURCES = $(top_srcdir)/src/xorg-gtest_main.cpp
 libxorg_gtest_main_a_CPPFLAGS = \
-	$(AM_CPPFLAGS) \
 	-I$(top_srcdir)/include \
-	-I$(top_srcdir)
+	-I$(top_srcdir) \
+	$(AM_CPPFLAGS)
 libxorg_gtest_main_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
 
 noinst_PROGRAMS = xorg-gtest-environment-example xorg-gtest-example
@@ -59,7 +59,7 @@ if ENABLE_XORG_GTEST_TESTS
 TESTS = $(noinst_PROGRAMS)
 endif
 xorg_gtest_example_SOURCES = xorg-gtest-example.cpp
-xorg_gtest_example_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include
+xorg_gtest_example_CPPFLAGS = -I$(top_srcdir)/include $(AM_CPPFLAGS)
 xorg_gtest_example_LDADD = \
                            libgtest.a \
                            libxorg-gtest.a \
@@ -69,7 +69,7 @@ xorg_gtest_example_LDADD = \
 
 xorg_gtest_environment_example_SOURCES = xorg-gtest-environment-example.cpp
 
-xorg_gtest_environment_example_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include
+xorg_gtest_environment_example_CPPFLAGS = -I$(top_srcdir)/include $(AM_CPPFLAGS)
 
 xorg_gtest_environment_example_LDADD = \
 	libgtest.a \
diff --git a/test/Makefile.am b/test/Makefile.am
index be0fc31..a8ec35a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -36,8 +36,8 @@ dist_noinst_DATA = PIXART-USB-OPTICAL-MOUSE.desc
 
 GTEST_CPPFLAGS=-I$(top_srcdir)/gtest/include -I$(top_srcdir)/gtest
 
-AM_CPPFLAGS = $(GTEST_CPPFLAGS)
-AM_CXXFLAGS = $(BASE_CXXFLAGS) \
+AM_CPPFLAGS = $(GTEST_CPPFLAGS) $(BASE_CPPFLAGS)
+AM_CXXFLAGS = $(BASE_CXXFLAGS) $(BASE_CPPFLAGS) \
 	      -DTEST_ROOT_DIR=\"$(abs_top_srcdir)/test/\"
 
 tests_libraries = \
@@ -48,14 +48,14 @@ tests_libraries = \
 	$(EVEMU_LIBS)
 
 process_test_SOURCES = process-test.cpp
-process_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include
+process_test_CPPFLAGS = -I$(top_srcdir)/include $(AM_CPPFLAGS)
 process_test_LDADD =  $(tests_libraries)
 
 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 = -I$(top_srcdir)/include $(AM_CPPFLAGS) \
 			-DDUMMY_CONF_PATH="\"$(abs_top_srcdir)/data/xorg/gtest/dummy.conf\""
 xserver_test_LDADD =  $(tests_libraries)
 

commit 0197de16f185416d353e71c4b4fc2a70a964f9f8
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Nov 6 11:38:16 2012 +1000

    xserver: install default X error handler
    
    Xlib's default error handler prints the error and calls exit(1). Tests that
    accidentally trigger an error thus quit without cleaning up properly.
    
    Install a default error handler that prints the basic info and continue with
    the test. Clients that expect to trigger errors should set a custom error
    handler.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@ubuntu.com>

diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h
index 8bf7996..11fc93d 100644
--- a/include/xorg/gtest/xorg-gtest-xserver.h
+++ b/include/xorg/gtest/xorg-gtest-xserver.h
@@ -265,6 +265,19 @@ class XServer : public xorg::testing::Process {
      */
     static void RegisterXIOErrorHandler();
 
+    /**
+     * Install a default XErrorHandler. That error handler will cause a test
+     * failure if called.
+     *
+     * This function is called automatically by XServer::Start(). Usually,
+     * you will not need to call this function unless your test does not
+     * instantiate and Start() an XServer object.
+     *
+     * This function will only install a new error handler if the currently
+     * installed XErrorHandler is not the default handler used by Xlib.
+     */
+    static void RegisterXErrorHandler();
+
   private:
     struct Private;
     std::auto_ptr<Private> d_;
diff --git a/src/xserver.cpp b/src/xserver.cpp
index ad018a1..2aff401 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -394,6 +394,40 @@ const std::string& xorg::testing::XServer::GetVersion(void) {
   return d_->version;
 }
 
+static int _x_error_handler(Display *dpy, XErrorEvent *err)
+{
+  std::stringstream error;
+  switch(err->error_code) {
+    case BadRequest: error << "BadRequest"; break;
+    case BadValue: error << "BadValue"; break;
+    case BadWindow: error << "BadWindow"; break;
+    case BadPixmap: error << "BadPixmap"; break;
+    case BadAtom: error << "BadAtom"; break;
+    case BadCursor: error << "BadCursor"; break;
+    case BadFont: error << "BadFont"; break;


Reply to: