... master4-talloc
authorStefan Metzmacher <metze@samba.org>
Mon, 19 Jan 2009 06:08:16 +0000 (07:08 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 17 May 2018 08:15:19 +0000 (10:15 +0200)
lib/talloc/testsuite.c

index 0776f20b1f934eed45060ef3f6ea028f7e9f3f09..3c9b6d68ccacb7dc213946f22a7c35b8649b258a 100644 (file)
@@ -59,6 +59,7 @@ static double private_timeval_elapsed(struct timeval *tv)
 #define torture_assert(test, expr, str) if (!(expr)) { \
        printf("failure: %s [\n%s: Expression %s failed: %s\n]\n", \
                test, __location__, #expr, str); \
+       abort(); \
        return false; \
 }
 
@@ -67,6 +68,7 @@ static double private_timeval_elapsed(struct timeval *tv)
        } else if (strcmp(arg1, arg2)) {                        \
                printf("failure: %s [\n%s: Expected %s, got %s: %s\n]\n", \
                   test, __location__, arg1, arg2, desc); \
+       abort(); \
                return false; \
        }
 
@@ -77,6 +79,7 @@ static double private_timeval_elapsed(struct timeval *tv)
                       (unsigned)talloc_total_size(ptr), \
                       (unsigned)tsize); \
                talloc_report_full(ptr, stdout); \
+               abort(); \
                return false; \
        } \
 } while (0)
@@ -88,6 +91,7 @@ static double private_timeval_elapsed(struct timeval *tv)
                       (unsigned)talloc_total_blocks(ptr), \
                       (unsigned)tblocks); \
                talloc_report_full(ptr, stdout); \
+               abort(); \
                return false; \
        } \
 } while (0)
@@ -101,6 +105,7 @@ static double private_timeval_elapsed(struct timeval *tv)
                talloc_report_full(ptr, stdout); \
                talloc_report_full(parent, stdout); \
                talloc_report_full(NULL, stdout); \
+               abort(); \
                return false; \
        } \
 } while (0)
@@ -161,15 +166,15 @@ static bool test_ref1(void)
        talloc_unlink(r1, p2);
        talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS("ref1", p1, 5);
+       CHECK_BLOCKS("ref1", p1, 4);
        CHECK_BLOCKS("ref1", p2, 1);
-       CHECK_BLOCKS("ref1", r1, 1);
+       CHECK_BLOCKS("ref1", r1, 2);
 
        fprintf(stderr, "Freeing p1\n");
        talloc_free(p1);
        talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS("ref1", r1, 1);
+       CHECK_BLOCKS("ref1", r1, 2);
 
        fprintf(stderr, "Freeing r1\n");
        talloc_free(r1);
@@ -216,9 +221,9 @@ static bool test_ref2(void)
        talloc_unlink(r1, ref);
        talloc_report_full(root, stderr);
 
-       CHECK_BLOCKS("ref2", p1, 5);
+       CHECK_BLOCKS("ref2", p1, 4);
        CHECK_BLOCKS("ref2", p2, 1);
-       CHECK_BLOCKS("ref2", r1, 1);
+       CHECK_BLOCKS("ref2", r1, 2);
 
        fprintf(stderr, "Freeing p2\n");
        talloc_free(p2);
@@ -403,17 +408,23 @@ static bool test_misc(void)
        torture_assert("misc", !p1, "failed: large talloc allowed\n");
 
        p1 = talloc_strdup(root, "foo");
+       CHECK_BLOCKS("misc", p1, 1);
+       CHECK_BLOCKS("misc", root, 2);
+       CHECK_BLOCKS("misc", talloc_parent(root), 3);
        talloc_increase_ref_count(p1);
        talloc_increase_ref_count(p1);
        talloc_increase_ref_count(p1);
        CHECK_BLOCKS("misc", p1, 1);
        CHECK_BLOCKS("misc", root, 2);
+       CHECK_BLOCKS("misc", NULL, 6);
        talloc_unlink(NULL, p1);
        CHECK_BLOCKS("misc", p1, 1);
-       CHECK_BLOCKS("misc", root, 2);
+       CHECK_BLOCKS("misc", root, 1);
+       CHECK_BLOCKS("misc", NULL, 5);
        talloc_unlink(NULL, p1);
        CHECK_BLOCKS("misc", p1, 1);
        CHECK_BLOCKS("misc", root, 2);
+       CHECK_BLOCKS("misc", NULL, 4);
        p2 = talloc_strdup(p1, "foo");
        torture_assert("misc", talloc_unlink(root, p2) == -1,
                                   "failed: talloc_unlink() of non-reference context should return -1\n");