-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All 'make check' tests will chdir() into this directory before
running the suite. This provides the option of having temporary
files generated in a tmpfs or ramdisk

e.g. ./configure --with-test-dir=/dev/shm

This is especially useful when your normal build directory is on a slow
and/or encrypted filesystem.
- -- 
Stephen Gallagher
RHCE 804006346421761

Delivering value year after year.
Red Hat ranks #1 in value among software vendors.
http://www.redhat.com/promo/vendor/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkuH86AACgkQeiVVYja6o6N4MgCfQl6Ben3h/aFZtzKy7g2oVFAL
6MYAnjz830c9o5pDIcFs0UTHdnDvrNXg
=iZUn
-----END PGP SIGNATURE-----
From 20060bbf9b5f6b4f2e6b3c11a56257466a94d31a Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgall...@redhat.com>
Date: Fri, 26 Feb 2010 09:04:11 -0500
Subject: [PATCH] Add --with-test-dir option to configure

All 'make check' tests will chdir() into this directory before
running the suite. This provides the option of having temporary
files generated in a tmpfs or ramdisk
---
 src/conf_macros.m4               |   12 ++++++++++++
 src/configure.ac                 |    4 ++++
 src/db/sysdb.c                   |    2 +-
 src/tests/auth-tests.c           |   10 ++++++++++
 src/tests/check_and_open-tests.c |   12 ++++++++++++
 src/tests/fail_over-tests.c      |   12 +++++++++++-
 src/tests/files-tests.c          |   12 +++++++++++-
 src/tests/find_uid-tests.c       |   13 ++++++++++++-
 src/tests/ipa_ldap_opt-tests.c   |   12 ++++++++++++
 src/tests/ipa_timerules-tests.c  |   10 ++++++++++
 src/tests/krb5_utils-tests.c     |   12 ++++++++++++
 src/tests/refcount-tests.c       |   12 +++++++++++-
 src/tests/resolv-tests.c         |   12 +++++++++++-
 src/tests/stress-tests.c         |   10 ++++++++++
 src/tests/strtonum-tests.c       |   12 +++++++++++-
 src/tests/sysdb-tests.c          |   10 ++++++++++
 16 files changed, 160 insertions(+), 7 deletions(-)

diff --git a/src/conf_macros.m4 b/src/conf_macros.m4
index 86ccf5d..6323db2 100644
--- a/src/conf_macros.m4
+++ b/src/conf_macros.m4
@@ -205,3 +205,15 @@ AC_DEFUN([WITH_SELINUX],
     AM_CONDITIONAL([BUILD_SELINUX], [test x"$with_selinux" = xyes])
   ])
 
+AC_DEFUN([WITH_TEST_DIR],
+  [ AC_ARG_WITH([test-dir],
+                [AC_HELP_STRING([--with-test-dir=PATH],
+                                [Directory used for make check temporary files [$builddir]]
+                               )
+                ]
+               )
+    TEST_DIR=$with_test_dir
+    AC_SUBST(TEST_DIR)
+    AC_DEFINE_UNQUOTED(TEST_DIR, "$with_test_dir", [Directory used for 'make check' temporary files])
+  ])
+
diff --git a/src/configure.ac b/src/configure.ac
index 4198ee9..d7a7a77 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -65,6 +65,7 @@ WITH_PUBCONF_PATH
 WITH_PIPE_PATH
 WITH_INIT_DIR
 WITH_SHADOW_UTILS_PATH
+WITH_TEST_DIR
 WITH_MANPAGES
 WITH_XML_CATALOG
 WITH_KRB5_PLUGIN_PATH
@@ -141,5 +142,8 @@ AM_CONDITIONAL([HAVE_DOXYGEN], [test x$DOXYGEN != xfalse ])
 
 AM_CONDITIONAL([HAVE_CHECK], [test x$have_check != x])
 
+abs_build_dir=`pwd`
+AC_DEFINE_UNQUOTED([ABS_BUILD_DIR], ["$abs_build_dir"], [Absolute path to the build directory])
+
 AC_CONFIG_FILES([Makefile doxy.config po/Makefile.in])
 AC_OUTPUT
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index b3f81a0..304490d 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -1542,7 +1542,7 @@ static int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
     }
 
 #ifdef SYSDB_TEST
-    ldb_set_modules_dir(ctx->ldb, "./.libs");
+    ldb_set_modules_dir(ctx->ldb, ABS_BUILD_DIR"/.libs");
 #endif
 
     ret = ldb_connect(ctx->ldb, ctx->ldb_file, 0, NULL);
diff --git a/src/tests/auth-tests.c b/src/tests/auth-tests.c
index 71215bc..adcbc02 100644
--- a/src/tests/auth-tests.c
+++ b/src/tests/auth-tests.c
@@ -319,6 +319,16 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     ret = clean_db_dir();
     if (ret != EOK) {
         fprintf(stderr, "Could not delete the db directory (%d) (%s)\n",
diff --git a/src/tests/check_and_open-tests.c b/src/tests/check_and_open-tests.c
index 32cf09f..b25cdd3 100644
--- a/src/tests/check_and_open-tests.c
+++ b/src/tests/check_and_open-tests.c
@@ -207,7 +207,19 @@ Suite *check_and_open_suite (void)
 
 int main(void)
 {
+  int ret;
   int number_failed;
+
+  ret = chdir(TEST_DIR);
+  if (ret == -1) {
+      if (strlen(TEST_DIR)) {
+          fprintf(stderr,
+                  "Could not chdir to [%s].\n"
+                  "Attempting to continue with current dir\n",
+                  TEST_DIR);
+      }
+  }
+
   Suite *s = check_and_open_suite ();
   SRunner *sr = srunner_create (s);
   /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c
index 4e97a1e..e3ecd68 100644
--- a/src/tests/fail_over-tests.c
+++ b/src/tests/fail_over-tests.c
@@ -269,7 +269,7 @@ create_suite(void)
 int
 main(int argc, const char *argv[])
 {
-    int opt;
+    int opt, ret;
     poptContext pc;
     int failure_count;
     Suite *suite;
@@ -300,6 +300,16 @@ main(int argc, const char *argv[])
     poptFreeContext(pc);
     debug_level = debug;
 
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     suite = create_suite();
     sr = srunner_create(suite);
     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
diff --git a/src/tests/files-tests.c b/src/tests/files-tests.c
index 2ebe659..28d78d3 100644
--- a/src/tests/files-tests.c
+++ b/src/tests/files-tests.c
@@ -292,7 +292,7 @@ static Suite *files_suite(void)
 int main(int argc, char *argv[])
 {
     int number_failed;
-    int opt;
+    int opt,ret;
     poptContext pc;
     int debug = 0;
 
@@ -312,6 +312,16 @@ int main(int argc, char *argv[])
     poptFreeContext(pc);
     debug_level = debug;
 
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     Suite *s = files_suite();
     SRunner *sr = srunner_create(s);
     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
diff --git a/src/tests/find_uid-tests.c b/src/tests/find_uid-tests.c
index 9eafadd..3055892 100644
--- a/src/tests/find_uid-tests.c
+++ b/src/tests/find_uid-tests.c
@@ -114,7 +114,18 @@ Suite *find_uid_suite (void)
 int main(void)
 {
     debug_level = 255;
-    int number_failed;
+    int ret, number_failed;
+
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     Suite *s = find_uid_suite ();
     SRunner *sr = srunner_create (s);
     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
diff --git a/src/tests/ipa_ldap_opt-tests.c b/src/tests/ipa_ldap_opt-tests.c
index 215f94a..2ac01e2 100644
--- a/src/tests/ipa_ldap_opt-tests.c
+++ b/src/tests/ipa_ldap_opt-tests.c
@@ -48,7 +48,19 @@ Suite *ipa_ldap_opt_suite (void)
 
 int main(void)
 {
+    int ret;
     int number_failed;
+
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     Suite *s = ipa_ldap_opt_suite ();
     SRunner *sr = srunner_create (s);
     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
diff --git a/src/tests/ipa_timerules-tests.c b/src/tests/ipa_timerules-tests.c
index 0a7be90..e9d509e 100644
--- a/src/tests/ipa_timerules-tests.c
+++ b/src/tests/ipa_timerules-tests.c
@@ -569,6 +569,16 @@ int main(int argc, const char *argv[])
     }
     debug_level = debug;
 
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     timelib_suite = create_timelib_suite();
     sr = srunner_create(timelib_suite);
     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
diff --git a/src/tests/krb5_utils-tests.c b/src/tests/krb5_utils-tests.c
index 362daf4..387a97b 100644
--- a/src/tests/krb5_utils-tests.c
+++ b/src/tests/krb5_utils-tests.c
@@ -295,7 +295,19 @@ Suite *krb5_utils_suite (void)
 
 int main(void)
 {
+  int ret;
   int number_failed;
+
+  ret = chdir(TEST_DIR);
+  if (ret == -1) {
+      if (strlen(TEST_DIR)) {
+          fprintf(stderr,
+                  "Could not chdir to [%s].\n"
+                  "Attempting to continue with current dir\n",
+                  TEST_DIR);
+      }
+  }
+
   Suite *s = krb5_utils_suite ();
   SRunner *sr = srunner_create (s);
   /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
diff --git a/src/tests/refcount-tests.c b/src/tests/refcount-tests.c
index db2a256..fb22302 100644
--- a/src/tests/refcount-tests.c
+++ b/src/tests/refcount-tests.c
@@ -194,7 +194,7 @@ Suite *create_suite(void)
 
 int main(int argc, const char *argv[])
 {
-    int opt;
+    int ret, opt;
     poptContext pc;
     int failure_count;
     Suite *suite;
@@ -220,6 +220,16 @@ int main(int argc, const char *argv[])
     poptFreeContext(pc);
     debug_level = debug;
 
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     suite = create_suite();
     sr = srunner_create(suite);
     srunner_set_fork_status(sr, CK_FORK);
diff --git a/src/tests/resolv-tests.c b/src/tests/resolv-tests.c
index e93d0f1..16316d0 100644
--- a/src/tests/resolv-tests.c
+++ b/src/tests/resolv-tests.c
@@ -557,7 +557,7 @@ Suite *create_resolv_suite(void)
 
 int main(int argc, const char *argv[])
 {
-    int opt;
+    int ret, opt;
     poptContext pc;
     int failure_count;
     Suite *resolv_suite;
@@ -595,6 +595,16 @@ int main(int argc, const char *argv[])
     poptFreeContext(pc);
     debug_level = debug;
 
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     resolv_suite = create_resolv_suite();
     sr = srunner_create(resolv_suite);
     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
diff --git a/src/tests/stress-tests.c b/src/tests/stress-tests.c
index 9450531..3653e8d 100644
--- a/src/tests/stress-tests.c
+++ b/src/tests/stress-tests.c
@@ -247,6 +247,16 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     verbose = pc_verbosity;
 
     if (pc_prefix) {
diff --git a/src/tests/strtonum-tests.c b/src/tests/strtonum-tests.c
index 7b9cf52..aa065a1 100644
--- a/src/tests/strtonum-tests.c
+++ b/src/tests/strtonum-tests.c
@@ -421,7 +421,7 @@ Suite *create_strtonum_suite(void)
 
 
 int main(int argc, const char *argv[]) {
-    int opt;
+    int ret, opt;
     poptContext pc;
     int failure_count;
     Suite *strtonum_suite;
@@ -445,6 +445,16 @@ int main(int argc, const char *argv[]) {
     }
     poptFreeContext(pc);
 
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     strtonum_suite = create_strtonum_suite();
     sr = srunner_create(strtonum_suite);
     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 8b486b6..360f7ea 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -3297,6 +3297,16 @@ int main(int argc, const char *argv[]) {
     }
     poptFreeContext(pc);
 
+    ret = chdir(TEST_DIR);
+    if (ret == -1) {
+        if (strlen(TEST_DIR)) {
+            fprintf(stderr,
+                    "Could not chdir to [%s].\n"
+                    "Attempting to continue with current dir\n",
+                    TEST_DIR);
+        }
+    }
+
     ret = unlink(TESTS_PATH"/"LOCAL_SYSDB_FILE);
     if (ret != EOK && errno != ENOENT) {
         fprintf(stderr, "Could not delete the test ldb file (%d) (%s)\n",
-- 
1.6.6.1

Attachment: 0001-Add-with-test-dir-option-to-configure.patch.sig
Description: PGP signature

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to