s3:torture: add traverse testing to LOCAL-RBTREE
authorStefan Metzmacher <metze@samba.org>
Tue, 24 Nov 2015 23:13:17 +0000 (00:13 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 27 Nov 2015 12:16:59 +0000 (13:16 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11375
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11394

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Nov 27 13:16:59 CET 2015 on sn-devel-104

source3/torture/torture.c

index ef75d2140c4caec235cb83069806d674cb0ff549..6c34e4ccd1ebbf483ce403ed921f3ccf452a005e 100644 (file)
@@ -8347,11 +8347,29 @@ static bool rbt_testval(struct db_context *db, const char *key,
        return ret;
 }
 
+static int local_rbtree_traverse_read(struct db_record *rec, void *private_data)
+{
+       int *count2 = (int *)private_data;
+       (*count2)++;
+       return 0;
+}
+
+static int local_rbtree_traverse_delete(struct db_record *rec, void *private_data)
+{
+       int *count2 = (int *)private_data;
+       (*count2)++;
+       dbwrap_record_delete(rec);
+       return 0;
+}
+
 static bool run_local_rbtree(int dummy)
 {
        struct db_context *db;
        bool ret = false;
        int i;
+       NTSTATUS status;
+       int count = 0;
+       int count2 = 0;
 
        db = db_open_rbt(NULL);
 
@@ -8394,6 +8412,27 @@ static bool run_local_rbtree(int dummy)
        }
 
        ret = true;
+       count = 0; count2 = 0;
+       status = dbwrap_traverse_read(db, local_rbtree_traverse_read,
+                                     &count2, &count);
+       printf("%s: read1: %d %d, %s\n", __func__, count, count2, nt_errstr(status));
+       if ((count != count2) || (count != 1000)) {
+               ret = false;
+       }
+       count = 0; count2 = 0;
+       status = dbwrap_traverse(db, local_rbtree_traverse_delete,
+                                &count2, &count);
+       printf("%s: delete: %d %d, %s\n", __func__, count, count2, nt_errstr(status));
+       if ((count != count2) || (count != 1000)) {
+               ret = false;
+       }
+       count = 0; count2 = 0;
+       status = dbwrap_traverse_read(db, local_rbtree_traverse_read,
+                                     &count2, &count);
+       printf("%s: read2: %d %d, %s\n", __func__, count, count2, nt_errstr(status));
+       if ((count != count2) || (count != 0)) {
+               ret = false;
+       }
 
  done:
        TALLOC_FREE(db);