summaryrefslogtreecommitdiff
path: root/source4/torture/drs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-11-27 14:42:05 +1100
committerAndrew Tridgell <tridge@samba.org>2009-11-27 16:05:06 +1100
commit0920e0b63b806c8ed4839271048dd4924ed02b2b (patch)
tree83a95553b86c02bf81de3b906072313fb0808101 /source4/torture/drs
parentd78921d78ca0a9211f044092b9a7f29bcfdd5397 (diff)
downloadsamba-0920e0b63b806c8ed4839271048dd4924ed02b2b.tar.gz
samba-0920e0b63b806c8ed4839271048dd4924ed02b2b.tar.bz2
samba-0920e0b63b806c8ed4839271048dd4924ed02b2b.zip
s4-drstest: don't use getenv("LDB_URL") in test suites
I was stumped for a while as to why the drs test suite was failing for me. It turned out that it looked for LDB_URL in the environment, and used it if set. I had it set in my terminal, and it was happily munching on my sam.ldb while testing. Quite a cute bug really :-)
Diffstat (limited to 'source4/torture/drs')
-rw-r--r--source4/torture/drs/unit/prefixmap_tests.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/source4/torture/drs/unit/prefixmap_tests.c b/source4/torture/drs/unit/prefixmap_tests.c
index 497723012f..03f30de106 100644
--- a/source4/torture/drs/unit/prefixmap_tests.c
+++ b/source4/torture/drs/unit/prefixmap_tests.c
@@ -625,27 +625,19 @@ static bool torture_drs_unit_dsdb_create_prefix_mapping(struct torture_context *
*/
static bool torture_drs_unit_ldb_setup(struct torture_context *tctx, struct drsut_prefixmap_data *priv)
{
- int fd = -1;
int ldb_err;
char *ldb_url;
bool bret = true;
TALLOC_CTX* mem_ctx;
+ char *tempdir;
+ NTSTATUS status;
mem_ctx = talloc_new(priv);
- /* try to find to make temporary LDB_ULR */
- ldb_url = getenv("LDB_URL");
- if (!ldb_url) {
- const char *temp_dir;
- temp_dir = getenv("TEST_DATA_PREFIX");
- if (!temp_dir) {
- temp_dir = "/tmp";
- }
- ldb_url = talloc_asprintf(priv, "%s/drs_XXXXXX", temp_dir);
- fd = mkstemp(ldb_url);
- torture_assert(tctx, fd != -1,
- talloc_asprintf(mem_ctx, "mkstemp() failed: %s", strerror(errno)));
- }
+ status = torture_temp_dir(tctx, "drs_", &tempdir);
+ torture_assert_ntstatus_ok(tctx, status, "creating temp dir");
+
+ ldb_url = talloc_asprintf(priv, "%s/drs_test.ldb", tempdir);
/* create LDB */
priv->ldb_ctx = ldb_init(priv, tctx->ev);
@@ -671,10 +663,7 @@ static bool torture_drs_unit_ldb_setup(struct torture_context *tctx, struct drsu
}
DONE:
- if (fd != -1) {
- close(fd);
- unlink(ldb_url);
- }
+ unlink(ldb_url);
talloc_free(mem_ctx);
return bret;
}