summaryrefslogtreecommitdiff
path: root/source4/torture/local
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2010-04-11 21:44:20 +0200
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2010-04-11 21:49:02 +0200
commit1d3b00bfd7ddfa983a68ecf4b0033729a42e9baa (patch)
tree89359486ca45397dade5fd47b52c80b7b20fc481 /source4/torture/local
parent1fd6d9cd661692e6b0ac950127a0d5b80945bfad (diff)
downloadsamba-1d3b00bfd7ddfa983a68ecf4b0033729a42e9baa.tar.gz
samba-1d3b00bfd7ddfa983a68ecf4b0033729a42e9baa.tar.bz2
samba-1d3b00bfd7ddfa983a68ecf4b0033729a42e9baa.zip
s4:dbspeed torture - improve also the TDB code part
Always use the label "failed" on failures, always close the database context (child of "tmp_ctx") when deleting database file.
Diffstat (limited to 'source4/torture/local')
-rw-r--r--source4/torture/local/dbspeed.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c
index e6a965a37e..1541d0ec84 100644
--- a/source4/torture/local/dbspeed.c
+++ b/source4/torture/local/dbspeed.c
@@ -36,6 +36,7 @@ static bool tdb_add_record(struct tdb_wrap *tdbw, const char *fmt1,
{
TDB_DATA key, data;
int ret;
+
key.dptr = (uint8_t *)talloc_asprintf(tdbw, fmt1, i);
key.dsize = strlen((char *)key.dptr)+1;
data.dptr = (uint8_t *)talloc_asprintf(tdbw, fmt2, i+10000);
@@ -66,9 +67,8 @@ static bool test_tdb_speed(struct torture_context *torture, const void *_data)
tdbw = tdb_wrap_open(tmp_ctx, "test.tdb",
10000, 0, O_RDWR|O_CREAT|O_TRUNC, 0600);
if (!tdbw) {
- unlink("test.tdb");
- talloc_free(tmp_ctx);
- torture_fail(torture, "Failed to open test.tdb");
+ torture_result(torture, TORTURE_FAIL, "Failed to open test.tdb");
+ goto failed;
}
torture_comment(torture, "Adding %d SID records\n", torture_entries);
@@ -77,13 +77,13 @@ static bool test_tdb_speed(struct torture_context *torture, const void *_data)
if (!tdb_add_record(tdbw,
"S-1-5-21-53173311-3623041448-2049097239-%u",
"UID %u", i)) {
- torture_result(torture, TORTURE_FAIL, "Failed to add SID %d\n", i);
+ torture_result(torture, TORTURE_FAIL, "Failed to add SID %d!", i);
goto failed;
}
if (!tdb_add_record(tdbw,
"UID %u",
"S-1-5-21-53173311-3623041448-2049097239-%u", i)) {
- torture_result(torture, TORTURE_FAIL, "Failed to add UID %d\n", i);
+ torture_result(torture, TORTURE_FAIL, "Failed to add UID %d!", i);
goto failed;
}
}
@@ -100,7 +100,7 @@ static bool test_tdb_speed(struct torture_context *torture, const void *_data)
data = tdb_fetch(tdbw->tdb, key);
talloc_free(key.dptr);
if (data.dptr == NULL) {
- torture_result(torture, TORTURE_FAIL, "Failed to fetch SID %d\n", i);
+ torture_result(torture, TORTURE_FAIL, "Failed to find SID %d!", i);
goto failed;
}
free(data.dptr);
@@ -109,7 +109,7 @@ static bool test_tdb_speed(struct torture_context *torture, const void *_data)
data = tdb_fetch(tdbw->tdb, key);
talloc_free(key.dptr);
if (data.dptr == NULL) {
- torture_result(torture, TORTURE_FAIL, "Failed to fetch UID %d\n", i);
+ torture_result(torture, TORTURE_FAIL, "Failed to find UID %d!", i);
goto failed;
}
free(data.dptr);
@@ -118,14 +118,13 @@ static bool test_tdb_speed(struct torture_context *torture, const void *_data)
tdb_speed = count/timeval_elapsed(&tv);
torture_comment(torture, "tdb speed %.2f ops/sec\n", tdb_speed);
-
- unlink("test.tdb");
talloc_free(tmp_ctx);
+ unlink("test.tdb");
return true;
failed:
- unlink("test.tdb");
talloc_free(tmp_ctx);
+ unlink("test.tdb");
return false;
}