[PATCH xorg-gtest 08/11] Make default log path configurable

Peter Hutterer peter.hutterer at who-t.net
Mon Oct 29 18:38:30 PDT 2012


/tmp is fine in most cases, but make it configurable through a configure
option

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 configure.ac          |  6 ++++++
 m4/ac_define_dir.m4   | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/defines.h         |  2 +-
 test/xserver-test.cpp | 16 ++++++++--------
 xorg-gtest.pc.in      |  2 +-
 5 files changed, 65 insertions(+), 10 deletions(-)
 create mode 100644 m4/ac_define_dir.m4

diff --git a/configure.ac b/configure.ac
index e3afde3..8d52928 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,12 @@ XORG_ENABLE_INTEGRATION_TESTS([yes])
 XORG_WITH_DOXYGEN
 
 PKG_CHECK_MODULES(X11, x11 xi)
+
+AC_ARG_WITH(logfile-dir, [AS_HELP_STRING([--with-logfile-dir=/tmp]),
+                          [Base path for log files used as defaults and during tests (default: /tmp)]],
+                         [LOGFILE_DIR="$withval"], [LOGFILE_DIR="/tmp"])
+AC_DEFINE_DIR(LOGFILE_DIR, LOGFILE_DIR, [Log file path])
+AC_SUBST(DUMMY_CONF_PATH, ['${LOGFILE_DIR}'])
  
 # Check if we should include support for evemu
 AC_ARG_WITH([evemu],
diff --git a/m4/ac_define_dir.m4 b/m4/ac_define_dir.m4
new file mode 100644
index 0000000..db42d3e
--- /dev/null
+++ b/m4/ac_define_dir.m4
@@ -0,0 +1,49 @@
+# ===========================================================================
+#             http://autoconf-archive.cryp.to/ac_define_dir.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
+#
+# DESCRIPTION
+#
+#   This macro sets VARNAME to the expansion of the DIR variable, taking
+#   care of fixing up ${prefix} and such.
+#
+#   VARNAME is then offered as both an output variable and a C preprocessor
+#   symbol.
+#
+#   Example:
+#
+#      AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.])
+#
+# LAST MODIFICATION
+#
+#   2008-04-12
+#
+# COPYLEFT
+#
+#   Copyright (c) 2008 Stepan Kasal <kasal at ucw.cz>
+#   Copyright (c) 2008 Andreas Schwab <schwab at suse.de>
+#   Copyright (c) 2008 Guido U. Draheim <guidod at gmx.de>
+#   Copyright (c) 2008 Alexandre Oliva
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.
+
+AC_DEFUN([AC_DEFINE_DIR], [
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
+dnl refers to ${prefix}.  Thus we have to use `eval' twice.
+  eval ac_define_dir="\"[$]$2\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  AC_SUBST($1, "$ac_define_dir")
+  AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
+])
diff --git a/src/defines.h b/src/defines.h
index 3fb3304..dd0f9e4 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -1,7 +1,7 @@
 #ifndef XORGGTEST_DEFINES
 #define XORGGTEST_DEFINES
 
-#define DEFAULT_XORG_LOGFILE "/tmp/Xorg.GTest.log"
+#define DEFAULT_XORG_LOGFILE LOGFILE_DIR "/Xorg.GTest.log"
 #define DEFAULT_DISPLAY 133
 
 /* Allow user to override default Xorg server*/
diff --git a/test/xserver-test.cpp b/test/xserver-test.cpp
index 70402fc..cdf0bd9 100644
--- a/test/xserver-test.cpp
+++ b/test/xserver-test.cpp
@@ -13,7 +13,7 @@ using namespace xorg::testing;
 TEST(XServer, LogRemoval)
 {
   XORG_TESTCASE("X server startup and log file removal on success and error");
-  std::string logfile = "/tmp/xorg-testing-xserver_____________.log";
+  std::string logfile = LOGFILE_DIR "/xorg-testing-xserver_____________.log";
 
   /* make sure a previous failed test didn't leave it around */
   unlink(logfile.c_str());
@@ -63,7 +63,7 @@ TEST(XServer, WaitForSIGUSR1)
                 "succeed as we wait for the SIGUSR1 signal\n");
   for (int i = 0; i < 20; i++) {
     XServer server;
-    server.SetOption("-logfile", "/tmp/xorg-testing-xserver-sigusr1.log");
+    server.SetOption("-logfile", LOGFILE_DIR "/xorg-testing-xserver-sigusr1.log");
     server.SetOption("-config", DUMMY_CONF_PATH);
     server.SetOption("-noreset", "");
     server.Start();
@@ -104,7 +104,7 @@ TEST(XServer, WaitForDeviceEventMask)
   XORG_TESTCASE("The event mask is left as-is by WaitForDevice");
 
   XServer server;
-  server.SetOption("-logfile", "/tmp/Xorg-WaitForDevice.log");
+  server.SetOption("-logfile", LOGFILE_DIR "/Xorg-WaitForDevice.log");
   server.SetOption("-config", DUMMY_CONF_PATH);
   server.SetOption("-noreset", "");
   server.Start();
@@ -167,7 +167,7 @@ TEST(XServer, WaitForExistingDevice)
   xorg::testing::evemu::Device d(TEST_ROOT_DIR "PIXART-USB-OPTICAL-MOUSE.desc");
 
   XServer server;
-  server.SetOption("-logfile", "/tmp/Xorg-WaitForDevice.log");
+  server.SetOption("-logfile", LOGFILE_DIR "/Xorg-WaitForDevice.log");
   server.SetOption("-config", DUMMY_CONF_PATH);
   server.SetOption("-noreset", "");
   server.Start();
@@ -183,7 +183,7 @@ TEST(XServer, WaitForNewDevice)
   XORG_TESTCASE("WaitForDevice() waits for newly created dvice");
 
   XServer server;
-  server.SetOption("-logfile", "/tmp/Xorg-WaitForDevice.log");
+  server.SetOption("-logfile", LOGFILE_DIR "/Xorg-WaitForDevice.log");
   server.SetOption("-config", DUMMY_CONF_PATH);
   server.SetOption("-noreset", "");
   server.Start();
@@ -201,7 +201,7 @@ TEST(XServer, IOErrorException)
 {
   ASSERT_THROW({
   XServer server;
-  server.SetOption("-logfile", "/tmp/xorg-io-error-test.log");
+  server.SetOption("-logfile", LOGFILE_DIR "/xorg-io-error-test.log");
   server.SetOption("-config", DUMMY_CONF_PATH);
   server.SetOption("-noreset", "");
   server.Start();
@@ -229,7 +229,7 @@ TEST(XServer, KeepAlive)
     ASSERT_TRUE(getenv("XORG_GTEST_XSERVER_KEEPALIVE") != NULL);
 
     XServer server;
-    server.SetOption("-logfile", "/tmp/Xorg-keepalive.log");
+    server.SetOption("-logfile", LOGFILE_DIR "/Xorg-keepalive.log");
     server.SetOption("-config", DUMMY_CONF_PATH);
     server.SetOption("-noreset", "");
     server.Start();
@@ -285,7 +285,7 @@ TEST(XServer, RemoveOption)
 {
   XServer server;
   server.SetOption("-fail", "yes");
-  server.SetOption("-logfile", "/tmp/Xorg-remove-option.log");
+  server.SetOption("-logfile", LOGFILE_DIR "/Xorg-remove-option.log");
   server.Start(TEST_ROOT_DIR "/xserver-test-helper");
   ASSERT_EQ(server.GetState(), Process::FINISHED_FAILURE);
 
diff --git a/xorg-gtest.pc.in b/xorg-gtest.pc.in
index e88e06c..8fa18a6 100644
--- a/xorg-gtest.pc.in
+++ b/xorg-gtest.pc.in
@@ -2,7 +2,7 @@ prefix=@prefix@
 includedir=@includedir@
 sourcedir=@SOURCEDIR@
 datarootdir=@datarootdir@
-CPPflags=-I${includedir} -I${includedir}/xorg -I${sourcedir} -DDUMMY_CONF_PATH=\"@DUMMY_CONF_PATH@\"
+CPPflags=-I${includedir} -I${includedir}/xorg -I${sourcedir} -DDUMMY_CONF_PATH=\"@DUMMY_CONF_PATH@\" -DLOGFILE_DIR=\"@LOGFILE_DIR@\"
 
 Name: xorg-gtest
 Description: X.org Google Test Environment
-- 
1.7.11.7



More information about the xorg-devel mailing list