summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-02-26 09:04:11 -0500
committerStephen Gallagher <sgallagh@redhat.com>2010-03-04 12:41:30 -0500
commit9fb59763bce293c2490e0b9f8e97bb1f74ba0910 (patch)
treebebd5ddc3975da122a34a09a5781b26025b96720 /src/tests
parent07a2e0b66a1c4688825e07fa88d37886fec4770c (diff)
downloadsssd_unused-9fb59763bce293c2490e0b9f8e97bb1f74ba0910.tar.gz
sssd_unused-9fb59763bce293c2490e0b9f8e97bb1f74ba0910.tar.xz
sssd_unused-9fb59763bce293c2490e0b9f8e97bb1f74ba0910.zip
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
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/auth-tests.c3
-rw-r--r--src/tests/check_and_open-tests.c4
-rw-r--r--src/tests/common.c18
-rw-r--r--src/tests/common.h2
-rw-r--r--src/tests/fail_over-tests.c2
-rw-r--r--src/tests/files-tests.c3
-rw-r--r--src/tests/find_uid-tests.c4
-rw-r--r--src/tests/ipa_ldap_opt-tests.c4
-rw-r--r--src/tests/ipa_timerules-tests.c2
-rw-r--r--src/tests/krb5_utils-tests.c4
-rw-r--r--src/tests/refcount-tests.c2
-rw-r--r--src/tests/resolv-tests.c2
-rw-r--r--src/tests/stress-tests.c3
-rw-r--r--src/tests/strtonum-tests.c3
-rw-r--r--src/tests/sysdb-tests.c3
15 files changed, 58 insertions, 1 deletions
diff --git a/src/tests/auth-tests.c b/src/tests/auth-tests.c
index 71215bcd..64864090 100644
--- a/src/tests/auth-tests.c
+++ b/src/tests/auth-tests.c
@@ -37,6 +37,7 @@
#include "util/util.h"
#include "confdb/confdb.h"
#include "db/sysdb.h"
+#include "tests/common.h"
#define TESTS_PATH "tests_auth"
#define TEST_CONF_FILE "tests_conf.ldb"
@@ -319,6 +320,8 @@ int main(int argc, const char *argv[])
}
poptFreeContext(pc);
+ tests_set_cwd();
+
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 32cf09f3..7ec8f3bc 100644
--- a/src/tests/check_and_open-tests.c
+++ b/src/tests/check_and_open-tests.c
@@ -29,6 +29,7 @@
#include <sys/stat.h>
#include "util/util.h"
+#include "tests/common.h"
#define SUFFIX ".symlink"
@@ -208,6 +209,9 @@ Suite *check_and_open_suite (void)
int main(void)
{
int number_failed;
+
+ tests_set_cwd();
+
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/common.c b/src/tests/common.c
index 50dc61b1..4ae1f490 100644
--- a/src/tests/common.c
+++ b/src/tests/common.c
@@ -27,9 +27,9 @@
#include "tests/common.h"
#include "util/dlinklist.h"
-#include "util/util.h"
TALLOC_CTX *global_talloc_context = NULL;
+#include "util/util.h"
struct size_snapshot {
struct size_snapshot *prev;
@@ -107,3 +107,19 @@ leak_check_teardown(void)
}
check_leaks(global_talloc_context, 0);
}
+
+void
+tests_set_cwd(void)
+{
+ int ret;
+
+ 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);
+ }
+ }
+}
diff --git a/src/tests/common.h b/src/tests/common.h
index 5d4b0867..576d705b 100644
--- a/src/tests/common.h
+++ b/src/tests/common.h
@@ -42,4 +42,6 @@ void _check_leaks_pop(TALLOC_CTX *ctx, const char *location);
void leak_check_setup(void);
void leak_check_teardown(void);
+void tests_set_cwd(void);
+
#endif /* !__TESTS_COMMON_H__ */
diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c
index 4e97a1e2..1864a09b 100644
--- a/src/tests/fail_over-tests.c
+++ b/src/tests/fail_over-tests.c
@@ -300,6 +300,8 @@ main(int argc, const char *argv[])
poptFreeContext(pc);
debug_level = debug;
+ tests_set_cwd();
+
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 2ebe659d..2267a603 100644
--- a/src/tests/files-tests.c
+++ b/src/tests/files-tests.c
@@ -34,6 +34,7 @@
#include "config.h"
#include "tools/tools_util.h"
#include "util/util.h"
+#include "tests/common.h"
static char tpl_dir[] = "file-tests-dir-XXXXXX";
static char *dir_path;
@@ -312,6 +313,8 @@ int main(int argc, char *argv[])
poptFreeContext(pc);
debug_level = debug;
+ tests_set_cwd();
+
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 9eafadd4..8d1362f7 100644
--- a/src/tests/find_uid-tests.c
+++ b/src/tests/find_uid-tests.c
@@ -29,6 +29,7 @@
#include <check.h>
#include "util/find_uid.h"
+#include "tests/common.h"
START_TEST(test_check_if_uid_is_active_success)
@@ -115,6 +116,9 @@ int main(void)
{
debug_level = 255;
int number_failed;
+
+ tests_set_cwd();
+
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 215f94a4..4b4667a4 100644
--- a/src/tests/ipa_ldap_opt-tests.c
+++ b/src/tests/ipa_ldap_opt-tests.c
@@ -27,6 +27,7 @@
#include "providers/ipa/ipa_common.h"
#include "providers/ldap/sdap.h"
+#include "tests/common.h"
START_TEST(test_check_num_opts)
{
@@ -49,6 +50,9 @@ Suite *ipa_ldap_opt_suite (void)
int main(void)
{
int number_failed;
+
+ tests_set_cwd();
+
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 0a7be90b..29fc7e4a 100644
--- a/src/tests/ipa_timerules-tests.c
+++ b/src/tests/ipa_timerules-tests.c
@@ -569,6 +569,8 @@ int main(int argc, const char *argv[])
}
debug_level = debug;
+ tests_set_cwd();
+
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 362daf47..64cf9c3d 100644
--- a/src/tests/krb5_utils-tests.c
+++ b/src/tests/krb5_utils-tests.c
@@ -27,6 +27,7 @@
#include "providers/krb5/krb5_utils.h"
#include "providers/krb5/krb5_auth.h"
+#include "tests/common.h"
#define BASE "/abc/def"
@@ -296,6 +297,9 @@ Suite *krb5_utils_suite (void)
int main(void)
{
int number_failed;
+
+ tests_set_cwd();
+
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 db2a256e..5e85b6f8 100644
--- a/src/tests/refcount-tests.c
+++ b/src/tests/refcount-tests.c
@@ -220,6 +220,8 @@ int main(int argc, const char *argv[])
poptFreeContext(pc);
debug_level = debug;
+ tests_set_cwd();
+
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 e93d0f19..c0133b92 100644
--- a/src/tests/resolv-tests.c
+++ b/src/tests/resolv-tests.c
@@ -595,6 +595,8 @@ int main(int argc, const char *argv[])
poptFreeContext(pc);
debug_level = debug;
+ 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/stress-tests.c b/src/tests/stress-tests.c
index 94505318..3b537357 100644
--- a/src/tests/stress-tests.c
+++ b/src/tests/stress-tests.c
@@ -30,6 +30,7 @@
#include <errno.h>
#include "util/util.h"
+#include "tests/common.h"
#define DEFAULT_START 10
#define DEFAULT_STOP 20
@@ -247,6 +248,8 @@ int main(int argc, const char *argv[])
}
poptFreeContext(pc);
+ tests_set_cwd();
+
verbose = pc_verbosity;
if (pc_prefix) {
diff --git a/src/tests/strtonum-tests.c b/src/tests/strtonum-tests.c
index 7b9cf522..a7131c1b 100644
--- a/src/tests/strtonum-tests.c
+++ b/src/tests/strtonum-tests.c
@@ -25,6 +25,7 @@
#include <popt.h>
#include "util/util.h"
#include "util/strtonum.h"
+#include "tests/common.h"
/********************
* Utility routines *
@@ -445,6 +446,8 @@ int main(int argc, const char *argv[]) {
}
poptFreeContext(pc);
+ tests_set_cwd();
+
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 8b486b69..c6661aef 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -29,6 +29,7 @@
#include "util/util.h"
#include "confdb/confdb_setup.h"
#include "db/sysdb_private.h"
+#include "tests/common.h"
#define TESTS_PATH "tests_sysdb"
#define TEST_CONF_FILE "tests_conf.ldb"
@@ -3297,6 +3298,8 @@ int main(int argc, const char *argv[]) {
}
poptFreeContext(pc);
+ tests_set_cwd();
+
ret = unlink(TESTS_PATH"/"LOCAL_SYSDB_FILE);
if (ret != EOK && errno != ENOENT) {
fprintf(stderr, "Could not delete the test ldb file (%d) (%s)\n",