summaryrefslogtreecommitdiff
path: root/src/tests
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/tests
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/tests')
-rw-r--r--src/tests/common.c8
1 files changed, 2 insertions, 6 deletions
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);
}
}