ldb:ldb tools - ldbtest - convert other result values to LDB codes as well
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 2 Mar 2011 21:28:27 +0000 (22:28 +0100)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Fri, 4 Mar 2011 07:51:45 +0000 (08:51 +0100)
I've forgotten this in my first patchset.

Reviewed by: Tridge

source4/lib/ldb/tools/ldbtest.c

index 28c0674fdfb4d57d8f9b60e7e656908d5f373c18..15c1e8b61eeb1d99a3c3e289c170feca4ab07574 100644 (file)
@@ -66,7 +66,7 @@ static void add_records(struct ldb_context *ldb,
 #if 0
         if (ldb_lock(ldb, "transaction") != 0) {
                 printf("transaction lock failed\n");
-                exit(1);
+                exit(LDB_ERR_OPERATIONS_ERROR);
         }
 #endif
        for (i=0;i<count;i++) {
@@ -128,7 +128,7 @@ static void add_records(struct ldb_context *ldb,
 
                if (ldb_add(ldb, &msg) != 0) {
                        printf("Add of %s failed - %s\n", name, ldb_errstring(ldb));
-                       exit(1);
+                       exit(LDB_ERR_OPERATIONS_ERROR);
                }
 
                printf("adding uid %s\r", name);
@@ -139,7 +139,7 @@ static void add_records(struct ldb_context *ldb,
 #if 0
         if (ldb_unlock(ldb, "transaction") != 0) {
                 printf("transaction unlock failed\n");
-                exit(1);
+                exit(LDB_ERR_OPERATIONS_ERROR);
         }
 #endif
        printf("\n");
@@ -185,7 +185,7 @@ static void modify_records(struct ldb_context *ldb,
 
                if (ldb_modify(ldb, &msg) != 0) {
                        printf("Modify of %s failed - %s\n", name, ldb_errstring(ldb));
-                       exit(1);
+                       exit(LDB_ERR_OPERATIONS_ERROR);
                }
 
                printf("Modifying uid %s\r", name);
@@ -215,7 +215,7 @@ static void delete_records(struct ldb_context *ldb,
 
                if (ldb_delete(ldb, dn) != 0) {
                        printf("Delete of %s failed - %s\n", ldb_dn_get_linearized(dn), ldb_errstring(ldb));
-                       exit(1);
+                       exit(LDB_ERR_OPERATIONS_ERROR);
                }
                talloc_free(name);
        }
@@ -239,12 +239,12 @@ static void search_uid(struct ldb_context *ldb, struct ldb_dn *basedn,
 
                if (ret != LDB_SUCCESS || (uid < nrecords && res->count != 1)) {
                        printf("Failed to find %s - %s\n", expr, ldb_errstring(ldb));
-                       exit(1);
+                       exit(LDB_ERR_OPERATIONS_ERROR);
                }
 
                if (uid >= nrecords && res->count > 0) {
                        printf("Found %s !? - %d\n", expr, ret);
-                       exit(1);
+                       exit(LDB_ERR_OPERATIONS_ERROR);
                }
 
                printf("Testing uid %d/%d - %d  \r", i, uid, res->count);
@@ -265,7 +265,7 @@ static void start_test(struct ldb_context *ldb, unsigned int nrecords,
        basedn = ldb_dn_new(ldb, ldb, options->basedn);
        if ( ! ldb_dn_validate(basedn)) {
                printf("Invalid base DN\n");
-               exit(1);
+               exit(LDB_ERR_OPERATIONS_ERROR);
        }
 
        printf("Adding %d records\n", nrecords);
@@ -330,7 +330,7 @@ static void start_test_index(struct ldb_context **ldb)
 
        if (ldb_add(*ldb, msg) != 0) {
                printf("Add of %s failed - %s\n", ldb_dn_get_linearized(msg->dn), ldb_errstring(*ldb));
-               exit(1);
+               exit(LDB_ERR_OPERATIONS_ERROR);
        }
 
        basedn = ldb_dn_new(*ldb, *ldb, options->basedn);
@@ -345,12 +345,12 @@ static void start_test_index(struct ldb_context **ldb)
 
        if (ldb_add(*ldb, msg) != 0) {
                printf("Add of %s failed - %s\n", ldb_dn_get_linearized(msg->dn), ldb_errstring(*ldb));
-               exit(1);
+               exit(LDB_ERR_OPERATIONS_ERROR);
        }
 
        if (talloc_free(*ldb) != 0) {
                printf("failed to free/close ldb database");
-               exit(1);
+               exit(LDB_ERR_OPERATIONS_ERROR);
        }
 
        (*ldb) = ldb_init(options, NULL);
@@ -358,7 +358,7 @@ static void start_test_index(struct ldb_context **ldb)
        ret = ldb_connect(*ldb, options->url, flags, NULL);
        if (ret != 0) {
                printf("failed to connect to %s\n", options->url);
-               exit(1);
+               exit(LDB_ERR_OPERATIONS_ERROR);
        }
 
        basedn = ldb_dn_new(*ldb, *ldb, options->basedn);
@@ -368,11 +368,11 @@ static void start_test_index(struct ldb_context **ldb)
        ret = ldb_search(*ldb, *ldb, &res, basedn, LDB_SCOPE_SUBTREE, NULL, "uid=test");
        if (ret != LDB_SUCCESS) { 
                printf("Search with (uid=test) filter failed!\n");
-               exit(1);
+               exit(LDB_ERR_OPERATIONS_ERROR);
        }
        if(res->count != 1) {
                printf("Should have found 1 record - found %d\n", res->count);
-               exit(1);
+               exit(LDB_ERR_OPERATIONS_ERROR);
        }
 
        indexlist = ldb_dn_new(*ldb, *ldb, "@INDEXLIST");
@@ -380,7 +380,7 @@ static void start_test_index(struct ldb_context **ldb)
        if (ldb_delete(*ldb, msg->dn) != 0 ||
            ldb_delete(*ldb, indexlist) != 0) {
                printf("cleanup failed - %s\n", ldb_errstring(*ldb));
-               exit(1);
+               exit(LDB_ERR_OPERATIONS_ERROR);
        }
 
        printf("Finished index test\n");