summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2013-04-11 10:00:14 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-05-02 20:12:30 +0200
commit9a0255c508ede92423a1f8a02c6c38328482c55f (patch)
treed3a831b2ff7a74507b309b79a2cd6b269a4054cc /src
parent2962b3d1e072ff2ebbe343095812dad697d6bf1d (diff)
downloadsssd-9a0255c508ede92423a1f8a02c6c38328482c55f.tar.gz
sssd-9a0255c508ede92423a1f8a02c6c38328482c55f.tar.bz2
sssd-9a0255c508ede92423a1f8a02c6c38328482c55f.zip
Default TEST_DIR to cwd, not empty string if not set explicitly
If configure isn't being run with argument --with-test-dir, then variable TEST_DIR will be defined, but its value will be empty (""). In this case opendir will fail with uncatched error "Directory does not exist, or name is an empty string". Finally function call dirfd will segfault because its argument is NULL. I changed default value of TEST_DIR (if --with-test-dir was not used). Function tests_set_cwd does not ignore return value of chdir, because TEST_DIR should not be the empty string.
Diffstat (limited to 'src')
-rw-r--r--src/conf_macros.m47
-rw-r--r--src/tests/common.c8
2 files changed, 6 insertions, 9 deletions
diff --git a/src/conf_macros.m4 b/src/conf_macros.m4
index 4ea4e936..26eb4acc 100644
--- a/src/conf_macros.m4
+++ b/src/conf_macros.m4
@@ -329,11 +329,12 @@ AC_DEFUN([WITH_TEST_DIR],
[AC_HELP_STRING([--with-test-dir=PATH],
[Directory used for make check temporary files [$builddir]]
)
- ]
+ ],
+ [TEST_DIR=$withval],
+ [TEST_DIR="."]
)
- TEST_DIR=$with_test_dir
AC_SUBST(TEST_DIR)
- AC_DEFINE_UNQUOTED(TEST_DIR, "$with_test_dir", [Directory used for 'make check' temporary files])
+ AC_DEFINE_UNQUOTED(TEST_DIR, "$TEST_DIR", [Directory used for 'make check' temporary files])
])
AC_DEFUN([WITH_NSCD],
diff --git a/src/tests/common.c b/src/tests/common.c
index 54c93e28..16c05165 100644
--- a/src/tests/common.c
+++ b/src/tests/common.c
@@ -33,12 +33,8 @@ tests_set_cwd(void)
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);
- }
+ fprintf(stderr, "Could not chdir to [%s].\n"
+ "Attempting to continue with current dir\n", TEST_DIR);
}
}