This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "lib/tdb/include/tdb.h"
#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
-#include "lib/db_wrap.h"
-#include "torture/torture.h"
+#include "lib/ldb_wrap.h"
+#include "lib/tdb_wrap.h"
+#include "torture/smbtorture.h"
+#include "param/param.h"
float tdb_speed;
-static BOOL tdb_add_record(struct tdb_wrap *tdbw, const char *fmt1, const char *fmt2, int i)
+static bool tdb_add_record(struct tdb_wrap *tdbw, const char *fmt1,
+ const char *fmt2, int i)
{
TDB_DATA key, data;
int ret;
/*
test tdb speed
*/
-static BOOL test_tdb_speed(struct torture_context *torture, const void *_data)
+static bool test_tdb_speed(struct torture_context *torture, const void *_data)
{
struct timeval tv;
struct tdb_wrap *tdbw;
key.dptr = (uint8_t *)talloc_asprintf(tmp_ctx, "S-1-5-21-53173311-3623041448-2049097239-%u", i);
key.dsize = strlen((char *)key.dptr)+1;
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);
goto failed;
key.dptr = (uint8_t *)talloc_asprintf(tmp_ctx, "UID %u", i);
key.dsize = strlen((char *)key.dptr)+1;
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);
goto failed;
unlink("test.tdb");
talloc_free(tmp_ctx);
- return True;
+ return true;
failed:
unlink("test.tdb");
talloc_free(tmp_ctx);
- return False;
+ return false;
}
-static BOOL ldb_add_record(struct ldb_context *ldb, unsigned rid)
+static bool ldb_add_record(struct ldb_context *ldb, unsigned rid)
{
struct ldb_message *msg;
int ret;
msg = ldb_msg_new(ldb);
if (msg == NULL) {
- return False;
+ return false;
}
msg->dn = ldb_dn_new_fmt(msg, ldb, "SID=S-1-5-21-53173311-3623041448-2049097239-%u", rid);
if (msg->dn == NULL) {
- return False;
+ return false;
}
if (ldb_msg_add_fmt(msg, "UID", "%u", rid) != 0) {
- return False;
+ return false;
}
ret = ldb_add(ldb, msg);
/*
test ldb speed
*/
-static BOOL test_ldb_speed(struct torture_context *torture, const void *_data)
+static bool test_ldb_speed(struct torture_context *torture, const void *_data)
{
struct timeval tv;
struct ldb_context *ldb;
torture_comment(torture, "Testing ldb speed for sidmap\n");
- ldb = ldb_wrap_connect(tmp_ctx, "tdb://test.ldb",
+ ldb = ldb_wrap_connect(tmp_ctx, torture->ev, torture->lp_ctx, "tdb://test.ldb",
NULL, NULL, LDB_FLG_NOSYNC, NULL);
if (!ldb) {
unlink("./test.ldb");
unlink("./test.ldb");
talloc_free(tmp_ctx);
- return True;
+ return true;
failed:
unlink("./test.ldb");
talloc_free(tmp_ctx);
- return False;
+ return false;
}
struct torture_suite *torture_local_dbspeed(TALLOC_CTX *mem_ctx)
{
struct torture_suite *s = torture_suite_create(mem_ctx, "DBSPEED");
- torture_suite_add_simple_tcase(s, "tdb_speed", test_tdb_speed, NULL);
- torture_suite_add_simple_tcase(s, "ldb_speed", test_ldb_speed, NULL);
+ torture_suite_add_simple_tcase_const(s, "tdb_speed", test_tdb_speed,
+ NULL);
+ torture_suite_add_simple_tcase_const(s, "ldb_speed", test_ldb_speed,
+ NULL);
return s;
}