From 5dbb2db14e775b6b0f26e49ff5b7f9f22b3cf76a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Wed, 25 Jul 2012 09:59:17 +0200
Subject: [PATCH] tests: allow changing cwd in all tests

---
 Makefile.am                     |    6 +++++-
 src/tests/debug-tests.c         |    3 +++
 src/tests/krb5_child-test.c     |    3 +++
 src/tests/resolv-tests.c        |    3 +++
 src/tests/simple_access-tests.c |    3 +++
 5 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 3c66b6cfe0715395aeb06039ad1bea4cb9298fab..78b638de96c55db6c66cf08579233a0c51237ef0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -859,6 +859,7 @@ endif
 
 resolv_tests_SOURCES = \
     src/tests/resolv-tests.c \
+    src/tests/common.c \
     $(SSSD_RESOLV_TESTS_OBJ)
 resolv_tests_CFLAGS = \
     $(AM_CFLAGS) \
@@ -946,6 +947,7 @@ ad_ldap_opt_tests_LDADD = \
 
 simple_access_tests_SOURCES = \
     src/tests/simple_access-tests.c \
+    src/tests/common.c \
     src/providers/simple/simple_access.c
 simple_access_tests_CFLAGS = \
     $(AM_CFLAGS) \
@@ -967,7 +969,8 @@ util_tests_LDADD = \
     libsss_test_common.la
 
 debug_tests_SOURCES = \
-    src/tests/debug-tests.c
+    src/tests/debug-tests.c \
+    src/tests/common.c
 debug_tests_CFLAGS = \
     $(AM_CFLAGS) \
     $(CHECK_CFLAGS)
@@ -1054,6 +1057,7 @@ stress_tests_LDADD = \
 
 krb5_child_test_SOURCES = \
     src/tests/krb5_child-test.c \
+    src/tests/common.c \
     src/providers/krb5/krb5_utils.c \
     src/providers/krb5/krb5_child_handler.c \
     src/providers/krb5/krb5_become_user.c \
diff --git a/src/tests/debug-tests.c b/src/tests/debug-tests.c
index 40dd2e98b848b5a267a6c8464cb7f3275a92ee9c..a751d836c22c6547eaaea7ab8d9e1364be27fa97 100644
--- a/src/tests/debug-tests.c
+++ b/src/tests/debug-tests.c
@@ -28,6 +28,7 @@
 #include <errno.h>
 #include <string.h>
 #include "util/util.h"
+#include "tests/common.h"
 
 #define DEBUG_TEST_ERROR    -1
 #define DEBUG_TEST_NOK      1
@@ -1022,6 +1023,8 @@ int main(int argc, const char *argv[])
 {
     int number_failed;
 
+    tests_set_cwd();
+
     Suite *s = debug_suite();
     SRunner *sr = srunner_create(s);
 
diff --git a/src/tests/krb5_child-test.c b/src/tests/krb5_child-test.c
index b07592a46f3371166b4290305a13a16396a97dfc..95a43d5bdd536bee6795739e6d0de912b059510d 100644
--- a/src/tests/krb5_child-test.c
+++ b/src/tests/krb5_child-test.c
@@ -32,6 +32,7 @@
 
 #include "util/util.h"
 #include "src/tools/tools_util.h"
+#include "tests/common.h"
 
 /* Interfaces being tested */
 #include "providers/krb5/krb5_auth.h"
@@ -509,6 +510,8 @@ main(int argc, const char *argv[])
                "will prefer ccname\n"));
     }
 
+    tests_set_cwd();
+
     ret = setup_krb5_child_test(NULL, &ctx);
     if (ret != EOK) {
         poptPrintUsage(pc, stderr, 0);
diff --git a/src/tests/resolv-tests.c b/src/tests/resolv-tests.c
index b56dc9e872364cdb56a4191d204e5d6c5ba5ccf2..ad89aaf6d2ff31b720ec876b3271327e08c5cfea 100644
--- a/src/tests/resolv-tests.c
+++ b/src/tests/resolv-tests.c
@@ -33,6 +33,7 @@
 
 #include "tests/common.h"
 #include "util/util.h"
+#include "tests/common.h"
 
 /* Interface under test */
 #include "resolv/async_resolv.h"
@@ -862,6 +863,8 @@ int main(int argc, const char *argv[])
                "option to run the full suite of tests\n");
     }
 
+    tests_set_cwd();
+
     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/simple_access-tests.c b/src/tests/simple_access-tests.c
index 4f041d400c948eff6077a0698ad1b4a54cb28fcf..c61814eb54c1aa5138a1b45653f9384228c5456a 100644
--- a/src/tests/simple_access-tests.c
+++ b/src/tests/simple_access-tests.c
@@ -28,6 +28,7 @@
 
 #include "confdb/confdb.h"
 #include "providers/simple/simple_access.h"
+#include "tests/common.h"
 
 const char *ulist_1[] = {"u1", "u2", NULL};
 
@@ -197,6 +198,8 @@ int main(int argc, const char *argv[])
 
     CONVERT_AND_SET_DEBUG_LEVEL(debug_level);
 
+    tests_set_cwd();
+
     Suite *s = access_simple_suite();
     SRunner *sr = srunner_create(s);
     srunner_run_all(sr, CK_ENV);
-- 
1.7.6.5

