Skip strcmp() on 2 NULL pointers.
[samba.git] / source4 / lib / talloc / testsuite.c
index a37f8c197e3a4f95b5144c73eb35a69c4c56b968..3f06eee5667d4b285afdcdbf6c1c986c297c6815 100644 (file)
@@ -12,7 +12,7 @@
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
-   version 2 of the License, or (at your option) any later version.
+   version 3 of the License, or (at your option) any later version.
 
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-
-#include <sys/time.h>
-#include <time.h>
-
+#include "replace.h"
+#include "system/time.h"
 #include "talloc.h"
 
-#ifndef False
-#define False 0
-#endif
-#ifndef True
-#define True 1
-#endif
-#ifndef BOOL
-#define BOOL int
-#endif
-
 static struct timeval timeval_current(void)
 {
        struct timeval tv;
@@ -62,7 +41,21 @@ static double timeval_elapsed(struct timeval *tv)
               (tv2.tv_usec - tv->tv_usec)*1.0e-6;
 }
 
-#if SAMBA_VERSION_MAJOR<4
+#define torture_assert(test, expr, str) if (!(expr)) { \
+       printf("failure: %s [\n%s: Expression %s failed: %s\n]\n", \
+               test, __location__, #expr, str); \
+       return false; \
+}
+
+#define torture_assert_str_equal(test, arg1, arg2, desc) \
+       if (arg1 == NULL && arg2 == NULL) {                             \
+       } else if (strcmp(arg1, arg2)) {                        \
+               printf("failure: %s [\n%s: Expected %s, got %s: %s\n]\n", \
+                  test, __location__, arg1, arg2, desc); \
+               return false; \
+       }
+
+#if _SAMBA_BUILD_==3
 #ifdef malloc
 #undef malloc
 #endif
@@ -71,25 +64,38 @@ static double timeval_elapsed(struct timeval *tv)
 #endif
 #endif
 
-#define CHECK_SIZE(ptr, tsize) do { \
+#define CHECK_SIZE(test, ptr, tsize) do { \
        if (talloc_total_size(ptr) != (tsize)) { \
-               printf(__location__ " failed: wrong '%s' tree size: got %u  expected %u\n", \
-                      #ptr, \
+               printf("failed: %s [\nwrong '%s' tree size: got %u  expected %u\n]\n", \
+                      test, #ptr, \
                       (unsigned)talloc_total_size(ptr), \
                       (unsigned)tsize); \
                talloc_report_full(ptr, stdout); \
-               return False; \
+               return false; \
        } \
 } while (0)
 
-#define CHECK_BLOCKS(ptr, tblocks) do { \
+#define CHECK_BLOCKS(test, ptr, tblocks) do { \
        if (talloc_total_blocks(ptr) != (tblocks)) { \
-               printf(__location__ " failed: wrong '%s' tree blocks: got %u  expected %u\n", \
-                      #ptr, \
+               printf("failed: %s [\nwrong '%s' tree blocks: got %u  expected %u\n]\n", \
+                      test, #ptr, \
                       (unsigned)talloc_total_blocks(ptr), \
                       (unsigned)tblocks); \
                talloc_report_full(ptr, stdout); \
-               return False; \
+               return false; \
+       } \
+} while (0)
+
+#define CHECK_PARENT(test, ptr, parent) do { \
+       if (talloc_parent(ptr) != (parent)) { \
+               printf("failed: %s [\n'%s' has wrong parent: got %p  expected %p\n]\n", \
+                      test, #ptr, \
+                      talloc_parent(ptr), \
+                      (parent)); \
+               talloc_report_full(ptr, stdout); \
+               talloc_report_full(parent, stdout); \
+               talloc_report_full(NULL, stdout); \
+               return false; \
        } \
 } while (0)
 
@@ -97,11 +103,11 @@ static double timeval_elapsed(struct timeval *tv)
 /*
   test references 
 */
-static BOOL test_ref1(void)
+static bool test_ref1(void)
 {
        void *root, *p1, *p2, *ref, *r1;
 
-       printf("TESTING SINGLE REFERENCE FREE\n");
+       printf("test: ref1\n# SINGLE REFERENCE FREE\n");
 
        root = talloc_named_const(NULL, 0, "root");
        p1 = talloc_named_const(root, 1, "p1");
@@ -112,53 +118,52 @@ static BOOL test_ref1(void)
 
        r1 = talloc_named_const(root, 1, "r1"); 
        ref = talloc_reference(r1, p2);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 5);
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(r1, 2);
+       CHECK_BLOCKS("ref1", p1, 5);
+       CHECK_BLOCKS("ref1", p2, 1);
+       CHECK_BLOCKS("ref1", r1, 2);
 
-       printf("Freeing p2\n");
+       fprintf(stderr, "Freeing p2\n");
        talloc_free(p2);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 5);
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(r1, 1);
+       CHECK_BLOCKS("ref1", p1, 5);
+       CHECK_BLOCKS("ref1", p2, 1);
+       CHECK_BLOCKS("ref1", r1, 1);
 
-       printf("Freeing p1\n");
+       fprintf(stderr, "Freeing p1\n");
        talloc_free(p1);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(r1, 1);
+       CHECK_BLOCKS("ref1", r1, 1);
 
-       printf("Freeing r1\n");
+       fprintf(stderr, "Freeing r1\n");
        talloc_free(r1);
-       talloc_report_full(NULL, stdout);
+       talloc_report_full(NULL, stderr);
 
-       printf("Testing NULL\n");
+       fprintf(stderr, "Testing NULL\n");
        if (talloc_reference(root, NULL)) {
-               return False;
+               return false;
        }
 
-       CHECK_BLOCKS(root, 1);
+       CHECK_BLOCKS("ref1", root, 1);
 
-       CHECK_SIZE(root, 0);
+       CHECK_SIZE("ref1", root, 0);
 
        talloc_free(root);
-
-       return True;
+       printf("success: ref1\n");
+       return true;
 }
 
 /*
   test references 
 */
-static BOOL test_ref2(void)
+static bool test_ref2(void)
 {
        void *root, *p1, *p2, *ref, *r1;
 
-       printf("TESTING DOUBLE REFERENCE FREE\n");
-
+       printf("test: ref2\n# DOUBLE REFERENCE FREE\n");
        root = talloc_named_const(NULL, 0, "root");
        p1 = talloc_named_const(root, 1, "p1");
        talloc_named_const(p1, 1, "x1");
@@ -168,90 +173,91 @@ static BOOL test_ref2(void)
 
        r1 = talloc_named_const(root, 1, "r1"); 
        ref = talloc_reference(r1, p2);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 5);
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(r1, 2);
+       CHECK_BLOCKS("ref2", p1, 5);
+       CHECK_BLOCKS("ref2", p2, 1);
+       CHECK_BLOCKS("ref2", r1, 2);
 
-       printf("Freeing ref\n");
+       fprintf(stderr, "Freeing ref\n");
        talloc_free(ref);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 5);
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(r1, 1);
+       CHECK_BLOCKS("ref2", p1, 5);
+       CHECK_BLOCKS("ref2", p2, 1);
+       CHECK_BLOCKS("ref2", r1, 1);
 
-       printf("Freeing p2\n");
+       fprintf(stderr, "Freeing p2\n");
        talloc_free(p2);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 4);
-       CHECK_BLOCKS(r1, 1);
+       CHECK_BLOCKS("ref2", p1, 4);
+       CHECK_BLOCKS("ref2", r1, 1);
 
-       printf("Freeing p1\n");
+       fprintf(stderr, "Freeing p1\n");
        talloc_free(p1);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(r1, 1);
+       CHECK_BLOCKS("ref2", r1, 1);
 
-       printf("Freeing r1\n");
+       fprintf(stderr, "Freeing r1\n");
        talloc_free(r1);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_SIZE(root, 0);
+       CHECK_SIZE("ref2", root, 0);
 
        talloc_free(root);
-
-       return True;
+       printf("success: ref2\n");
+       return true;
 }
 
 /*
   test references 
 */
-static BOOL test_ref3(void)
+static bool test_ref3(void)
 {
        void *root, *p1, *p2, *ref, *r1;
 
-       printf("TESTING PARENT REFERENCE FREE\n");
+       printf("test: ref3\n# PARENT REFERENCE FREE\n");
 
        root = talloc_named_const(NULL, 0, "root");
        p1 = talloc_named_const(root, 1, "p1");
        p2 = talloc_named_const(root, 1, "p2");
        r1 = talloc_named_const(p1, 1, "r1");
        ref = talloc_reference(p2, r1);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 2);
-       CHECK_BLOCKS(p2, 2);
-       CHECK_BLOCKS(r1, 1);
+       CHECK_BLOCKS("ref3", p1, 2);
+       CHECK_BLOCKS("ref3", p2, 2);
+       CHECK_BLOCKS("ref3", r1, 1);
 
-       printf("Freeing p1\n");
+       fprintf(stderr, "Freeing p1\n");
        talloc_free(p1);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p2, 2);
-       CHECK_BLOCKS(r1, 1);
+       CHECK_BLOCKS("ref3", p2, 2);
+       CHECK_BLOCKS("ref3", r1, 1);
 
-       printf("Freeing p2\n");
+       fprintf(stderr, "Freeing p2\n");
        talloc_free(p2);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_SIZE(root, 0);
+       CHECK_SIZE("ref3", root, 0);
 
        talloc_free(root);
 
-       return True;
+       printf("success: ref3\n");
+       return true;
 }
 
 /*
   test references 
 */
-static BOOL test_ref4(void)
+static bool test_ref4(void)
 {
        void *root, *p1, *p2, *ref, *r1;
 
-       printf("TESTING REFERRER REFERENCE FREE\n");
+       printf("test: ref4\n# REFERRER REFERENCE FREE\n");
 
        root = talloc_named_const(NULL, 0, "root");
        p1 = talloc_named_const(root, 1, "p1");
@@ -262,45 +268,46 @@ static BOOL test_ref4(void)
 
        r1 = talloc_named_const(root, 1, "r1"); 
        ref = talloc_reference(r1, p2);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 5);
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(r1, 2);
+       CHECK_BLOCKS("ref4", p1, 5);
+       CHECK_BLOCKS("ref4", p2, 1);
+       CHECK_BLOCKS("ref4", r1, 2);
 
-       printf("Freeing r1\n");
+       fprintf(stderr, "Freeing r1\n");
        talloc_free(r1);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 5);
-       CHECK_BLOCKS(p2, 1);
+       CHECK_BLOCKS("ref4", p1, 5);
+       CHECK_BLOCKS("ref4", p2, 1);
 
-       printf("Freeing p2\n");
+       fprintf(stderr, "Freeing p2\n");
        talloc_free(p2);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 4);
+       CHECK_BLOCKS("ref4", p1, 4);
 
-       printf("Freeing p1\n");
+       fprintf(stderr, "Freeing p1\n");
        talloc_free(p1);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_SIZE(root, 0);
+       CHECK_SIZE("ref4", root, 0);
 
        talloc_free(root);
 
-       return True;
+       printf("success: ref4\n");
+       return true;
 }
 
 
 /*
   test references 
 */
-static BOOL test_unlink1(void)
+static bool test_unlink1(void)
 {
        void *root, *p1, *p2, *ref, *r1;
 
-       printf("TESTING UNLINK\n");
+       printf("test: unlink\n# UNLINK\n");
 
        root = talloc_named_const(NULL, 0, "root");
        p1 = talloc_named_const(root, 1, "p1");
@@ -311,29 +318,30 @@ static BOOL test_unlink1(void)
 
        r1 = talloc_named_const(p1, 1, "r1");   
        ref = talloc_reference(r1, p2);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 7);
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(r1, 2);
+       CHECK_BLOCKS("unlink", p1, 7);
+       CHECK_BLOCKS("unlink", p2, 1);
+       CHECK_BLOCKS("unlink", r1, 2);
 
-       printf("Unreferencing r1\n");
+       fprintf(stderr, "Unreferencing r1\n");
        talloc_unlink(r1, p2);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS(p1, 6);
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(r1, 1);
+       CHECK_BLOCKS("unlink", p1, 6);
+       CHECK_BLOCKS("unlink", p2, 1);
+       CHECK_BLOCKS("unlink", r1, 1);
 
-       printf("Freeing p1\n");
+       fprintf(stderr, "Freeing p1\n");
        talloc_free(p1);
-       talloc_report_full(root, stdout);
+       talloc_report_full(root, stderr);
 
-       CHECK_SIZE(root, 0);
+       CHECK_SIZE("unlink", root, 0);
 
        talloc_free(root);
 
-       return True;
+       printf("success: unlink\n");
+       return true;
 }
 
 static int fail_destructor(void *ptr)
@@ -344,203 +352,173 @@ static int fail_destructor(void *ptr)
 /*
   miscellaneous tests to try to get a higher test coverage percentage
 */
-static BOOL test_misc(void)
+static bool test_misc(void)
 {
        void *root, *p1;
        char *p2;
        double *d;
+       const char *name;
 
-       printf("TESTING MISCELLANEOUS\n");
+       printf("test: misc\n# MISCELLANEOUS\n");
 
        root = talloc_new(NULL);
 
        p1 = talloc_size(root, 0x7fffffff);
-       if (p1) {
-               printf("failed: large talloc allowed\n");
-               return False;
-       }
+       torture_assert("misc", !p1, "failed: large talloc allowed\n");
 
        p1 = talloc_strdup(root, "foo");
        talloc_increase_ref_count(p1);
        talloc_increase_ref_count(p1);
        talloc_increase_ref_count(p1);
-       CHECK_BLOCKS(p1, 1);
-       CHECK_BLOCKS(root, 2);
+       CHECK_BLOCKS("misc", p1, 1);
+       CHECK_BLOCKS("misc", root, 2);
        talloc_free(p1);
-       CHECK_BLOCKS(p1, 1);
-       CHECK_BLOCKS(root, 2);
+       CHECK_BLOCKS("misc", p1, 1);
+       CHECK_BLOCKS("misc", root, 2);
        talloc_unlink(NULL, p1);
-       CHECK_BLOCKS(p1, 1);
-       CHECK_BLOCKS(root, 2);
+       CHECK_BLOCKS("misc", p1, 1);
+       CHECK_BLOCKS("misc", root, 2);
        p2 = talloc_strdup(p1, "foo");
-       if (talloc_unlink(root, p2) != -1) {
-               printf("failed: talloc_unlink() of non-reference context should return -1\n");
-               return False;
-       }
-       if (talloc_unlink(p1, p2) != 0) {
-               printf("failed: talloc_unlink() of parent should succeed\n");
-               return False;
-       }
+       torture_assert("misc", talloc_unlink(root, p2) == -1,
+                                  "failed: talloc_unlink() of non-reference context should return -1\n");
+       torture_assert("misc", talloc_unlink(p1, p2) == 0,
+               "failed: talloc_unlink() of parent should succeed\n");
        talloc_free(p1);
-       CHECK_BLOCKS(p1, 1);
-       CHECK_BLOCKS(root, 2);
+       CHECK_BLOCKS("misc", p1, 1);
+       CHECK_BLOCKS("misc", root, 2);
 
-       talloc_set_name(p1, "my name is %s", "foo");
-       if (strcmp(talloc_get_name(p1), "my name is foo") != 0) {
-               printf("failed: wrong name after talloc_set_name\n");
-               return False;
-       }
-       CHECK_BLOCKS(p1, 2);
-       CHECK_BLOCKS(root, 3);
+       name = talloc_set_name(p1, "my name is %s", "foo");
+       torture_assert_str_equal("misc", talloc_get_name(p1), "my name is foo",
+               "failed: wrong name after talloc_set_name(my name is foo)");
+       CHECK_BLOCKS("misc", p1, 2);
+       CHECK_BLOCKS("misc", root, 3);
 
        talloc_set_name_const(p1, NULL);
-       if (strcmp(talloc_get_name(p1), "UNNAMED") != 0) {
-               printf("failed: wrong name after talloc_set_name(NULL)\n");
-               return False;
-       }
-       CHECK_BLOCKS(p1, 2);
-       CHECK_BLOCKS(root, 3);
-       
+       torture_assert_str_equal ("misc", talloc_get_name(p1), "UNNAMED",
+               "failed: wrong name after talloc_set_name(NULL)");
+       CHECK_BLOCKS("misc", p1, 2);
+       CHECK_BLOCKS("misc", root, 3);
 
-       if (talloc_free(NULL) != -1) {
-               printf("talloc_free(NULL) should give -1\n");
-               return False;
-       }
+       torture_assert("misc", talloc_free(NULL) == -1, 
+                                  "talloc_free(NULL) should give -1\n");
 
        talloc_set_destructor(p1, fail_destructor);
-       if (talloc_free(p1) != -1) {
-               printf("Failed destructor should cause talloc_free to fail\n");
-               return False;
-       }
+       torture_assert("misc", talloc_free(p1) == -1, 
+               "Failed destructor should cause talloc_free to fail\n");
        talloc_set_destructor(p1, NULL);
 
-       talloc_report(root, stdout);
+       talloc_report(root, stderr);
 
 
-       p2 = talloc_zero_size(p1, 20);
-       if (p2[19] != 0) {
-               printf("Failed to give zero memory\n");
-               return False;
-       }
+       p2 = (char *)talloc_zero_size(p1, 20);
+       torture_assert("misc", p2[19] == 0, "Failed to give zero memory\n");
        talloc_free(p2);
 
-       if (talloc_strdup(root, NULL) != NULL) {
-               printf("failed: strdup on NULL should give NULL\n");
-               return False;
-       }
+       torture_assert("misc", talloc_strdup(root, NULL) == NULL,
+               "failed: strdup on NULL should give NULL\n");
 
        p2 = talloc_strndup(p1, "foo", 2);
-       if (strcmp("fo", p2) != 0) {
-               printf("failed: strndup doesn't work\n");
-               return False;
-       }
-       p2 = talloc_asprintf_append(p2, "o%c", 'd');
-       if (strcmp("food", p2) != 0) {
-               printf("failed: talloc_asprintf_append doesn't work\n");
-               return False;
-       }
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(p1, 3);
-
-       p2 = talloc_asprintf_append(NULL, "hello %s", "world");
-       if (strcmp("hello world", p2) != 0) {
-               printf("failed: talloc_asprintf_append doesn't work\n");
-               return False;
-       }
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(p1, 3);
+       torture_assert("misc", strcmp("fo", p2) == 0, 
+                                  "strndup doesn't work\n");
+       p2 = talloc_asprintf_append_buffer(p2, "o%c", 'd');
+       torture_assert("misc", strcmp("food", p2) == 0, 
+                                  "talloc_asprintf_append_buffer doesn't work\n");
+       CHECK_BLOCKS("misc", p2, 1);
+       CHECK_BLOCKS("misc", p1, 3);
+
+       p2 = talloc_asprintf_append_buffer(NULL, "hello %s", "world");
+       torture_assert("misc", strcmp("hello world", p2) == 0,
+               "talloc_asprintf_append_buffer doesn't work\n");
+       CHECK_BLOCKS("misc", p2, 1);
+       CHECK_BLOCKS("misc", p1, 3);
        talloc_free(p2);
 
        d = talloc_array(p1, double, 0x20000000);
-       if (d) {
-               printf("failed: integer overflow not detected\n");
-               return False;
-       }
+       torture_assert("misc", !d, "failed: integer overflow not detected\n");
 
        d = talloc_realloc(p1, d, double, 0x20000000);
-       if (d) {
-               printf("failed: integer overflow not detected\n");
-               return False;
-       }
+       torture_assert("misc", !d, "failed: integer overflow not detected\n");
 
        talloc_free(p1);
-       CHECK_BLOCKS(root, 1);
+       CHECK_BLOCKS("misc", root, 1);
 
        p1 = talloc_named(root, 100, "%d bytes", 100);
-       CHECK_BLOCKS(p1, 2);
-       CHECK_BLOCKS(root, 3);
+       CHECK_BLOCKS("misc", p1, 2);
+       CHECK_BLOCKS("misc", root, 3);
        talloc_unlink(root, p1);
 
        p1 = talloc_init("%d bytes", 200);
        p2 = talloc_asprintf(p1, "my test '%s'", "string");
-       CHECK_BLOCKS(p1, 3);
-       CHECK_SIZE(p2, 17);
-       CHECK_BLOCKS(root, 1);
+       torture_assert_str_equal("misc", p2, "my test 'string'",
+               "failed: talloc_asprintf(\"my test '%%s'\", \"string\") gave: \"%s\"");
+       CHECK_BLOCKS("misc", p1, 3);
+       CHECK_SIZE("misc", p2, 17);
+       CHECK_BLOCKS("misc", root, 1);
        talloc_unlink(NULL, p1);
 
        p1 = talloc_named_const(root, 10, "p1");
-       p2 = talloc_named_const(root, 20, "p2");
-       talloc_reference(p1, p2);
-       talloc_report_full(root, stdout);
+       p2 = (char *)talloc_named_const(root, 20, "p2");
+       (void)talloc_reference(p1, p2);
+       talloc_report_full(root, stderr);
        talloc_unlink(root, p2);
-       talloc_report_full(root, stdout);
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(p1, 2);
-       CHECK_BLOCKS(root, 3);
+       talloc_report_full(root, stderr);
+       CHECK_BLOCKS("misc", p2, 1);
+       CHECK_BLOCKS("misc", p1, 2);
+       CHECK_BLOCKS("misc", root, 3);
        talloc_unlink(p1, p2);
        talloc_unlink(root, p1);
 
        p1 = talloc_named_const(root, 10, "p1");
-       p2 = talloc_named_const(root, 20, "p2");
-       talloc_reference(NULL, p2);
-       talloc_report_full(root, stdout);
+       p2 = (char *)talloc_named_const(root, 20, "p2");
+       (void)talloc_reference(NULL, p2);
+       talloc_report_full(root, stderr);
        talloc_unlink(root, p2);
-       talloc_report_full(root, stdout);
-       CHECK_BLOCKS(p2, 1);
-       CHECK_BLOCKS(p1, 1);
-       CHECK_BLOCKS(root, 2);
+       talloc_report_full(root, stderr);
+       CHECK_BLOCKS("misc", p2, 1);
+       CHECK_BLOCKS("misc", p1, 1);
+       CHECK_BLOCKS("misc", root, 2);
        talloc_unlink(NULL, p2);
        talloc_unlink(root, p1);
 
        /* Test that talloc_unlink is a no-op */
 
-       if (talloc_unlink(root, NULL) != -1) {
-               printf("failed: talloc_unlink(root, NULL) == -1\n");
-               return False;
-       }
+       torture_assert("misc", talloc_unlink(root, NULL) == -1,
+               "failed: talloc_unlink(root, NULL) == -1\n");
 
-       talloc_report(root, stdout);
-       talloc_report(NULL, stdout);
+       talloc_report(root, stderr);
+       talloc_report(NULL, stderr);
 
-       CHECK_SIZE(root, 0);
+       CHECK_SIZE("misc", root, 0);
 
        talloc_free(root);
 
-       CHECK_SIZE(NULL, 0);
+       CHECK_SIZE("misc", NULL, 0);
 
        talloc_enable_leak_report();
        talloc_enable_leak_report_full();
 
-       return True;
+       printf("success: misc\n");
+
+       return true;
 }
 
 
 /*
   test realloc
 */
-static BOOL test_realloc(void)
+static bool test_realloc(void)
 {
        void *root, *p1, *p2;
 
-       printf("TESTING REALLOC\n");
+       printf("test: realloc\n# REALLOC\n");
 
        root = talloc_new(NULL);
 
        p1 = talloc_size(root, 10);
-       CHECK_SIZE(p1, 10);
+       CHECK_SIZE("realloc", p1, 10);
 
        p1 = talloc_realloc_size(NULL, p1, 20);
-       CHECK_SIZE(p1, 20);
+       CHECK_SIZE("realloc", p1, 20);
 
        talloc_new(p1);
 
@@ -550,55 +528,52 @@ static BOOL test_realloc(void)
 
        p2 = talloc_realloc_size(p1, p2, 40);
 
-       CHECK_SIZE(p2, 40);
-       CHECK_SIZE(root, 60);
-       CHECK_BLOCKS(p1, 4);
+       CHECK_SIZE("realloc", p2, 40);
+       CHECK_SIZE("realloc", root, 60);
+       CHECK_BLOCKS("realloc", p1, 4);
 
        p1 = talloc_realloc_size(NULL, p1, 20);
-       CHECK_SIZE(p1, 60);
+       CHECK_SIZE("realloc", p1, 60);
 
        talloc_increase_ref_count(p2);
-       if (talloc_realloc_size(NULL, p2, 5) != NULL) {
-               printf("failed: talloc_realloc() on a referenced pointer should fail\n");
-               return False;
-       }
-       CHECK_BLOCKS(p1, 4);
+       torture_assert("realloc", talloc_realloc_size(NULL, p2, 5) == NULL,
+               "failed: talloc_realloc() on a referenced pointer should fail\n");
+       CHECK_BLOCKS("realloc", p1, 4);
 
        talloc_realloc_size(NULL, p2, 0);
        talloc_realloc_size(NULL, p2, 0);
-       CHECK_BLOCKS(p1, 3);
+       CHECK_BLOCKS("realloc", p1, 3);
 
-       if (talloc_realloc_size(NULL, p1, 0x7fffffff) != NULL) {
-               printf("failed: oversize talloc should fail\n");
-               return False;
-       }
+       torture_assert("realloc", talloc_realloc_size(NULL, p1, 0x7fffffff) == NULL,
+               "failed: oversize talloc should fail\n");
 
        talloc_realloc_size(NULL, p1, 0);
 
-       CHECK_BLOCKS(root, 1);
-       CHECK_SIZE(root, 0);
+       CHECK_BLOCKS("realloc", root, 1);
+       CHECK_SIZE("realloc", root, 0);
 
        talloc_free(root);
 
-       return True;
-}
+       printf("success: realloc\n");
 
+       return true;
+}
 
 /*
   test realloc with a child
 */
-static BOOL test_realloc_child(void)
+static bool test_realloc_child(void)
 {
        void *root;
+       struct el2 {
+               const char *name;
+       } *el2; 
        struct el1 {
                int count;
-               struct el2 {
-                       const char *name;
-               } **list, **list2, **list3;
+               struct el2 **list, **list2, **list3;
        } *el1;
-       struct el2 *el2;
 
-       printf("TESTING REALLOC WITH CHILD\n");
+       printf("test: REALLOC WITH CHILD\n");
 
        root = talloc_new(NULL);
 
@@ -625,14 +600,14 @@ static BOOL test_realloc_child(void)
 
        talloc_free(root);
 
-       return True;
+       printf("success: REALLOC WITH CHILD\n");
+       return true;
 }
 
-
 /*
   test type checking
 */
-static BOOL test_type(void)
+static bool test_type(void)
 {
        void *root;
        struct el1 {
@@ -643,7 +618,7 @@ static BOOL test_type(void)
        };
        struct el1 *el1;
 
-       printf("TESTING talloc type checking\n");
+       printf("test: type\n# talloc type checking\n");
 
        root = talloc_new(NULL);
 
@@ -651,113 +626,139 @@ static BOOL test_type(void)
 
        el1->count = 1;
 
-       if (talloc_get_type(el1, struct el1) != el1) {
-               printf("type check failed on el1\n");
-               return False;
-       }
-       if (talloc_get_type(el1, struct el2) != NULL) {
-               printf("type check failed on el1 with el2\n");
-               return False;
-       }
+       torture_assert("type", talloc_get_type(el1, struct el1) == el1,
+               "type check failed on el1\n");
+       torture_assert("type", talloc_get_type(el1, struct el2) == NULL,
+               "type check failed on el1 with el2\n");
        talloc_set_type(el1, struct el2);
-       if (talloc_get_type(el1, struct el2) != (struct el2 *)el1) {
-               printf("type set failed on el1 with el2\n");
-               return False;
-       }
+       torture_assert("type", talloc_get_type(el1, struct el2) == (struct el2 *)el1,
+               "type set failed on el1 with el2\n");
 
        talloc_free(root);
 
-       return True;
+       printf("success: type\n");
+       return true;
 }
 
 /*
   test steal
 */
-static BOOL test_steal(void)
+static bool test_steal(void)
 {
        void *root, *p1, *p2;
 
-       printf("TESTING STEAL\n");
+       printf("test: steal\n# STEAL\n");
 
        root = talloc_new(NULL);
 
        p1 = talloc_array(root, char, 10);
-       CHECK_SIZE(p1, 10);
+       CHECK_SIZE("steal", p1, 10);
 
        p2 = talloc_realloc(root, NULL, char, 20);
-       CHECK_SIZE(p1, 10);
-       CHECK_SIZE(root, 30);
+       CHECK_SIZE("steal", p1, 10);
+       CHECK_SIZE("steal", root, 30);
 
-       if (talloc_steal(p1, NULL) != NULL) {
-               printf("failed: stealing NULL should give NULL\n");
-               return False;
-       }
+       torture_assert("steal", talloc_steal(p1, NULL) == NULL,
+               "failed: stealing NULL should give NULL\n");
 
-       if (talloc_steal(p1, p1) != p1) {
-               printf("failed: stealing to ourselves is a nop\n");
-               return False;
-       }
-       CHECK_BLOCKS(root, 3);
-       CHECK_SIZE(root, 30);
+       torture_assert("steal", talloc_steal(p1, p1) == p1,
+               "failed: stealing to ourselves is a nop\n");
+       CHECK_BLOCKS("steal", root, 3);
+       CHECK_SIZE("steal", root, 30);
 
        talloc_steal(NULL, p1);
        talloc_steal(NULL, p2);
-       CHECK_BLOCKS(root, 1);
-       CHECK_SIZE(root, 0);
+       CHECK_BLOCKS("steal", root, 1);
+       CHECK_SIZE("steal", root, 0);
 
        talloc_free(p1);
        talloc_steal(root, p2);
-       CHECK_BLOCKS(root, 2);
-       CHECK_SIZE(root, 20);
+       CHECK_BLOCKS("steal", root, 2);
+       CHECK_SIZE("steal", root, 20);
        
        talloc_free(p2);
 
-       CHECK_BLOCKS(root, 1);
-       CHECK_SIZE(root, 0);
+       CHECK_BLOCKS("steal", root, 1);
+       CHECK_SIZE("steal", root, 0);
 
        talloc_free(root);
 
        p1 = talloc_size(NULL, 3);
-       talloc_report_full(NULL, stdout);
-       CHECK_SIZE(NULL, 3);
+       talloc_report_full(NULL, stderr);
+       CHECK_SIZE("steal", NULL, 3);
        talloc_free(p1);
 
-       return True;
+       printf("success: steal\n");
+       return true;
+}
+
+/*
+  test move
+*/
+static bool test_move(void)
+{
+       void *root;
+       struct t_move {
+               char *p;
+               int *x;
+       } *t1, *t2;
+
+       printf("test: move\n# MOVE\n");
+
+       root = talloc_new(NULL);
+
+       t1 = talloc(root, struct t_move);
+       t2 = talloc(root, struct t_move);
+       t1->p = talloc_strdup(t1, "foo");
+       t1->x = talloc(t1, int);
+       *t1->x = 42;
+
+       t2->p = talloc_move(t2, &t1->p);
+       t2->x = talloc_move(t2, &t1->x);
+       torture_assert("move", t1->p == NULL && t1->x == NULL &&
+           strcmp(t2->p, "foo") == 0 && *t2->x == 42,
+               "talloc move failed");
+
+       talloc_free(root);
+
+       printf("success: move\n");
+
+       return true;
 }
 
 /*
   test talloc_realloc_fn
 */
-static BOOL test_realloc_fn(void)
+static bool test_realloc_fn(void)
 {
        void *root, *p1;
 
-       printf("TESTING talloc_realloc_fn\n");
+       printf("test: realloc_fn\n# talloc_realloc_fn\n");
 
        root = talloc_new(NULL);
 
        p1 = talloc_realloc_fn(root, NULL, 10);
-       CHECK_BLOCKS(root, 2);
-       CHECK_SIZE(root, 10);
+       CHECK_BLOCKS("realloc_fn", root, 2);
+       CHECK_SIZE("realloc_fn", root, 10);
        p1 = talloc_realloc_fn(root, p1, 20);
-       CHECK_BLOCKS(root, 2);
-       CHECK_SIZE(root, 20);
+       CHECK_BLOCKS("realloc_fn", root, 2);
+       CHECK_SIZE("realloc_fn", root, 20);
        p1 = talloc_realloc_fn(root, p1, 0);
-       CHECK_BLOCKS(root, 1);
-       CHECK_SIZE(root, 0);
+       CHECK_BLOCKS("realloc_fn", root, 1);
+       CHECK_SIZE("realloc_fn", root, 0);
 
        talloc_free(root);
 
-
-       return True;
+       printf("success: realloc_fn\n");
+       return true;
 }
 
 
-static BOOL test_unref_reparent(void)
+static bool test_unref_reparent(void)
 {
        void *root, *p1, *p2, *c1;
 
-       printf("TESTING UNREFERENCE AFTER PARENT FREED\n");
+       printf("test: unref_reparent\n# UNREFERENCE AFTER PARENT FREED\n");
 
        root = talloc_named_const(NULL, 0, "root");
        p1 = talloc_named_const(root, 1, "orig parent");
@@ -766,115 +767,386 @@ static BOOL test_unref_reparent(void)
        c1 = talloc_named_const(p1, 1, "child");
        talloc_reference(p2, c1);
 
+       CHECK_PARENT("unref_reparent", c1, p1);
+
        talloc_free(p1);
+
+       CHECK_PARENT("unref_reparent", c1, p2);
+
        talloc_unlink(p2, c1);
 
-       CHECK_SIZE(root, 1);
+       CHECK_SIZE("unref_reparent", root, 1);
 
        talloc_free(p2);
        talloc_free(root);
 
-       return True;
+       printf("success: unref_reparent\n");
+       return true;
 }
 
 /*
   measure the speed of talloc versus malloc
 */
-static BOOL test_speed(void)
+static bool test_speed(void)
 {
        void *ctx = talloc_new(NULL);
        unsigned count;
+       const int loop = 1000;
+       int i;
        struct timeval tv;
 
-       printf("MEASURING TALLOC VS MALLOC SPEED\n");
+       printf("test: speed\n# TALLOC VS MALLOC SPEED\n");
 
        tv = timeval_current();
        count = 0;
        do {
                void *p1, *p2, *p3;
-               p1 = talloc_size(ctx, count);
-               p2 = talloc_strdup(p1, "foo bar");
-               p3 = talloc_size(p1, 300);
-               talloc_free(p1);
-               count += 3;
+               for (i=0;i<loop;i++) {
+                       p1 = talloc_size(ctx, loop % 100);
+                       p2 = talloc_strdup(p1, "foo bar");
+                       p3 = talloc_size(p1, 300);
+                       talloc_free(p1);
+               }
+               count += 3 * loop;
        } while (timeval_elapsed(&tv) < 5.0);
 
-       printf("talloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
+       fprintf(stderr, "talloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
 
        talloc_free(ctx);
 
+       ctx = talloc_pool(NULL, 1024);
+
        tv = timeval_current();
        count = 0;
        do {
                void *p1, *p2, *p3;
-               p1 = malloc(count);
-               p2 = strdup("foo bar");
-               p3 = malloc(300);
-               free(p1);
-               free(p2);
-               free(p3);
-               count += 3;
+               for (i=0;i<loop;i++) {
+                       p1 = talloc_size(ctx, loop % 100);
+                       p2 = talloc_strdup(p1, "foo bar");
+                       p3 = talloc_size(p1, 300);
+                       talloc_free_children(ctx);
+               }
+               count += 3 * loop;
        } while (timeval_elapsed(&tv) < 5.0);
 
-       printf("malloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
+       talloc_free(ctx);
 
-       return True;    
-}
+       fprintf(stderr, "talloc_pool: %.0f ops/sec\n", count/timeval_elapsed(&tv));
+
+       tv = timeval_current();
+       count = 0;
+       do {
+               void *p1, *p2, *p3;
+               for (i=0;i<loop;i++) {
+                       p1 = malloc(loop % 100);
+                       p2 = strdup("foo bar");
+                       p3 = malloc(300);
+                       free(p1);
+                       free(p2);
+                       free(p3);
+               }
+               count += 3 * loop;
+       } while (timeval_elapsed(&tv) < 5.0);
+       fprintf(stderr, "malloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
+
+       printf("success: speed\n");
 
+       return true;
+}
 
-BOOL test_lifeless(void)
+static bool test_lifeless(void)
 {
-       char *top = talloc_new(NULL);
+       void *top = talloc_new(NULL);
        char *parent, *child; 
-       char *child_owner = talloc_new(NULL);
+       void *child_owner = talloc_new(NULL);
 
-       printf("TESTING TALLOC_UNLINK LOOP\n");
+       printf("test: lifeless\n# TALLOC_UNLINK LOOP\n");
 
        parent = talloc_strdup(top, "parent");
        child = talloc_strdup(parent, "child");  
-       talloc_reference(child, parent);
-       talloc_reference(child_owner, child); 
+       (void)talloc_reference(child, parent);
+       (void)talloc_reference(child_owner, child); 
+       talloc_report_full(top, stderr);
        talloc_unlink(top, parent);
        talloc_free(child);
-       talloc_report_full(top, stdout);
+       talloc_report_full(top, stderr);
        talloc_free(top);
-       return True;
+       talloc_free(child_owner);
+       talloc_free(child);
+
+       printf("success: lifeless\n");
+       return true;
 }
 
+static int loop_destructor_count;
 
-BOOL torture_local_talloc(void) 
+static int test_loop_destructor(char *ptr)
 {
-       BOOL ret = True;
+       loop_destructor_count++;
+       return 0;
+}
+
+static bool test_loop(void)
+{
+       void *top = talloc_new(NULL);
+       char *parent;
+       struct req1 {
+               char *req2, *req3;
+       } *req1;
+
+       printf("test: loop\n# TALLOC LOOP DESTRUCTION\n");
+
+       parent = talloc_strdup(top, "parent");
+       req1 = talloc(parent, struct req1);
+       req1->req2 = talloc_strdup(req1, "req2");  
+       talloc_set_destructor(req1->req2, test_loop_destructor);
+       req1->req3 = talloc_strdup(req1, "req3");
+       (void)talloc_reference(req1->req3, req1);
+       talloc_report_full(top, stderr);
+       talloc_free(parent);
+       talloc_report_full(top, stderr);
+       talloc_report_full(NULL, stderr);
+       talloc_free(top);
+
+       torture_assert("loop", loop_destructor_count == 1, 
+                                  "FAILED TO FIRE LOOP DESTRUCTOR\n");
+       loop_destructor_count = 0;
+
+       printf("success: loop\n");
+       return true;
+}
+
+static int fail_destructor_str(char *ptr)
+{
+       return -1;
+}
+
+static bool test_free_parent_deny_child(void)
+{
+       void *top = talloc_new(NULL);
+       char *level1;
+       char *level2;
+       char *level3;
+
+       printf("test: free_parent_deny_child\n# TALLOC FREE PARENT DENY CHILD\n");
+
+       level1 = talloc_strdup(top, "level1");
+       level2 = talloc_strdup(level1, "level2");
+       level3 = talloc_strdup(level2, "level3");
+
+       talloc_set_destructor(level3, fail_destructor_str);
+       talloc_free(level1);
+       talloc_set_destructor(level3, NULL);
+
+       CHECK_PARENT("free_parent_deny_child", level3, top);
+
+       talloc_free(top);
+
+       printf("success: free_parent_deny_child\n");
+       return true;
+}
+
+static bool test_talloc_ptrtype(void)
+{
+       void *top = talloc_new(NULL);
+       struct struct1 {
+               int foo;
+               int bar;
+       } *s1, *s2, **s3, ***s4;
+       const char *location1;
+       const char *location2;
+       const char *location3;
+       const char *location4;
+
+       printf("test: ptrtype\n# TALLOC PTRTYPE\n");
+
+       s1 = talloc_ptrtype(top, s1);location1 = __location__;
+
+       if (talloc_get_size(s1) != sizeof(struct struct1)) {
+               printf("failure: ptrtype [\n"
+                 "talloc_ptrtype() allocated the wrong size %lu (should be %lu)\n"
+                 "]\n", (unsigned long)talloc_get_size(s1),
+                          (unsigned long)sizeof(struct struct1));
+               return false;
+       }
+
+       if (strcmp(location1, talloc_get_name(s1)) != 0) {
+               printf("failure: ptrtype [\n"
+                 "talloc_ptrtype() sets the wrong name '%s' (should be '%s')\n]\n",
+                       talloc_get_name(s1), location1);
+               return false;
+       }
+
+       s2 = talloc_array_ptrtype(top, s2, 10);location2 = __location__;
+
+       if (talloc_get_size(s2) != (sizeof(struct struct1) * 10)) {
+               printf("failure: ptrtype [\n"
+                          "talloc_array_ptrtype() allocated the wrong size "
+                      "%lu (should be %lu)\n]\n",
+                       (unsigned long)talloc_get_size(s2),
+                   (unsigned long)(sizeof(struct struct1)*10));
+               return false;
+       }
+
+       if (strcmp(location2, talloc_get_name(s2)) != 0) {
+               printf("failure: ptrtype [\n"
+               "talloc_array_ptrtype() sets the wrong name '%s' (should be '%s')\n]\n",
+                       talloc_get_name(s2), location2);
+               return false;
+       }
+
+       s3 = talloc_array_ptrtype(top, s3, 10);location3 = __location__;
+
+       if (talloc_get_size(s3) != (sizeof(struct struct1 *) * 10)) {
+               printf("failure: ptrtype [\n"
+                          "talloc_array_ptrtype() allocated the wrong size "
+                      "%lu (should be %lu)\n]\n",
+                          (unsigned long)talloc_get_size(s3),
+                      (unsigned long)(sizeof(struct struct1 *)*10));
+               return false;
+       }
+
+       torture_assert_str_equal("ptrtype", location3, talloc_get_name(s3),
+               "talloc_array_ptrtype() sets the wrong name");
+
+       s4 = talloc_array_ptrtype(top, s4, 10);location4 = __location__;
+
+       if (talloc_get_size(s4) != (sizeof(struct struct1 **) * 10)) {
+               printf("failure: ptrtype [\n"
+                     "talloc_array_ptrtype() allocated the wrong size "
+                      "%lu (should be %lu)\n]\n",
+                          (unsigned long)talloc_get_size(s4),
+                      (unsigned long)(sizeof(struct struct1 **)*10));
+               return false;
+       }
+
+       torture_assert_str_equal("ptrtype", location4, talloc_get_name(s4),
+               "talloc_array_ptrtype() sets the wrong name");
+
+       talloc_free(top);
+
+       printf("success: ptrtype\n");
+       return true;
+}
+
+static int _test_talloc_free_in_destructor(void **ptr)
+{
+       talloc_free(*ptr);
+       return 0;
+}
+
+static bool test_talloc_free_in_destructor(void)
+{
+       void *level0;
+       void *level1;
+       void *level2;
+       void *level3;
+       void *level4;
+       void **level5;
+
+       printf("test: free_in_destructor\n# TALLOC FREE IN DESTRUCTOR\n");
+
+       level0 = talloc_new(NULL);
+       level1 = talloc_new(level0);
+       level2 = talloc_new(level1);
+       level3 = talloc_new(level2);
+       level4 = talloc_new(level3);
+       level5 = talloc(level4, void *);
+
+       *level5 = level3;
+       (void)talloc_reference(level0, level3);
+       (void)talloc_reference(level3, level3);
+       (void)talloc_reference(level5, level3);
+
+       talloc_set_destructor(level5, _test_talloc_free_in_destructor);
+
+       talloc_free(level1);
+
+       talloc_free(level0);
+
+       printf("success: free_in_destructor\n");
+       return true;
+}
+
+static bool test_autofree(void)
+{
+#if _SAMBA_BUILD_ < 4
+       /* autofree test would kill smbtorture */
+       void *p;
+       printf("test: autofree\n# TALLOC AUTOFREE CONTEXT\n");
+
+       p = talloc_autofree_context();
+       talloc_free(p);
+
+       p = talloc_autofree_context();
+       talloc_free(p);
+
+       printf("success: autofree\n");
+#endif
+       return true;
+}
+
+static bool test_pool(void)
+{
+       void *pool;
+       void *p1, *p2, *p3, *p4;
+
+       pool = talloc_pool(NULL, 1024);
+
+       p1 = talloc_size(pool, 80);
+       p2 = talloc_size(pool, 20);
+       p3 = talloc_size(p1, 50);
+       p4 = talloc_size(p3, 1000);
+
+       talloc_free(pool);
+
+       return true;
+}
+
+struct torture_context;
+bool torture_local_talloc(struct torture_context *tctx)
+{
+       bool ret = true;
+
+       setlinebuf(stdout);
+
+       talloc_disable_null_tracking();
+       talloc_enable_null_tracking();
 
        ret &= test_ref1();
        ret &= test_ref2();
        ret &= test_ref3();
        ret &= test_ref4();
-       ret &= test_unlink1();
+       ret &= test_unlink1(); 
        ret &= test_misc();
        ret &= test_realloc();
-       ret &= test_realloc_child();
-       ret &= test_steal();
+       ret &= test_realloc_child(); 
+       ret &= test_steal(); 
+       ret &= test_move(); 
        ret &= test_unref_reparent();
-       ret &= test_realloc_fn();
+       ret &= test_realloc_fn(); 
        ret &= test_type();
-       ret &= test_lifeless();
+       ret &= test_lifeless(); 
+       ret &= test_loop();
+       ret &= test_free_parent_deny_child(); 
+       ret &= test_talloc_ptrtype();
+       ret &= test_talloc_free_in_destructor();
+       ret &= test_pool();
+
        if (ret) {
                ret &= test_speed();
        }
+       ret &= test_autofree();
 
        return ret;
 }
 
-
-
-#if !defined(_SAMBA_BUILD_) || ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9))
- int main(void)
+#if _SAMBA_BUILD_ < 4
+int main(void)
 {
-       if (!torture_local_talloc()) {
-               printf("ERROR: TESTSUIE FAILED\n");
+       bool ret = torture_local_talloc(NULL);
+       if (!ret)
                return -1;
-       }
        return 0;
 }
 #endif