diff options
author | Sumit Bose <sbose@redhat.com> | 2010-02-02 17:22:34 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-02-03 10:35:19 -0500 |
commit | 45febf05db2be90441119d96a53e56be22dc1e96 (patch) | |
tree | 6156608bbf3245952c0c10544d80a0754472cd53 /server/tests | |
parent | 067fbea128ea5f6298feb37f9aaab347afd59d8a (diff) | |
download | sssd-45febf05db2be90441119d96a53e56be22dc1e96.tar.gz sssd-45febf05db2be90441119d96a53e56be22dc1e96.tar.bz2 sssd-45febf05db2be90441119d96a53e56be22dc1e96.zip |
Make krb5 and open checks work if forking is disabled
When CK_FORK is set to 'no' the fixtures are executed for every new test
inside of the same process. Global variables must be set to the expected
values by the fixtures.
check_and_open-tests.c: the filename template for mkstemp() was a
globally defined character string. After the first call to mkstemp() the
trailing XXXXXX are substituted by random values, a second call to
mkstemp() with this character string fails. This patch initialize the
filename template before mkstemp() is called with the help of strdup()
and the memory is freed in the teardown fixture.
krb5_utils-tests.c: this patch sets the just freed global talloc context
to NULL to make a consistency check in the setup fixture pass.
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/check_and_open-tests.c | 6 | ||||
-rw-r--r-- | server/tests/krb5_utils-tests.c | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/server/tests/check_and_open-tests.c b/server/tests/check_and_open-tests.c index 2e964557..b0d638b5 100644 --- a/server/tests/check_and_open-tests.c +++ b/server/tests/check_and_open-tests.c @@ -32,7 +32,8 @@ #define SUFFIX ".symlink" -char filename[] = "check_and_open-tests-XXXXXX"; +#define FILENAME_TEMPLATE "check_and_open-tests-XXXXXX" +char *filename; uid_t uid; gid_t gid; mode_t mode; @@ -42,6 +43,8 @@ void setup_check_and_open(void) { int ret; + filename = strdup(FILENAME_TEMPLATE); + fail_unless(filename != NULL, "strdup failed"); ret = mkstemp(filename); fail_unless(ret != -1, "mkstemp failed [%d][%s]", errno, strerror(errno)); close(ret); @@ -63,6 +66,7 @@ void teardown_check_and_open(void) fail_unless(filename != NULL, "unknown filename"); ret = unlink(filename); + free(filename); fail_unless(ret == 0, "unlink failed [%d][%s]", errno, strerror(errno)); } diff --git a/server/tests/krb5_utils-tests.c b/server/tests/krb5_utils-tests.c index c3d9f4cf..8676f3bf 100644 --- a/server/tests/krb5_utils-tests.c +++ b/server/tests/krb5_utils-tests.c @@ -92,6 +92,7 @@ void free_talloc_context(void) int ret; fail_unless(tmp_ctx != NULL, "Talloc context already freed."); ret = talloc_free(tmp_ctx); + tmp_ctx = NULL; fail_unless(ret == 0, "Connot free talloc context."); } |