diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-08-05 05:43:47 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:15:22 -0500 |
commit | 14d322332185b311d7843508cc73684700cbae33 (patch) | |
tree | c1babccf5fb53e6746ea926ce2e016bb42319a8f /source4 | |
parent | 1ea8c378e2e9847f008a0bf89fb7c028f5b5263a (diff) | |
download | samba-14d322332185b311d7843508cc73684700cbae33.tar.gz samba-14d322332185b311d7843508cc73684700cbae33.tar.bz2 samba-14d322332185b311d7843508cc73684700cbae33.zip |
r17413: add a new case for the this:
top->level1->level2->level3
level3 has a deny destructor
talloc_free(level1)
result: top->level3
metze
(This used to be commit 3be930b81d2caf5e13105efa02280c4fc45181cb)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/talloc/testsuite.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c index 2b04f66fc4..947540d940 100644 --- a/source4/lib/talloc/testsuite.c +++ b/source4/lib/talloc/testsuite.c @@ -95,6 +95,19 @@ static double timeval_elapsed(struct timeval *tv) } \ } while (0) +#define CHECK_PARENT(ptr, parent) do { \ + if (talloc_parent(ptr) != (parent)) { \ + printf(__location__ " failed: '%s' has wrong parent: got %p expected %p\n", \ + #ptr, \ + talloc_parent(ptr), \ + (parent)); \ + talloc_report_full(ptr, stdout); \ + talloc_report_full(parent, stdout); \ + talloc_report_full(NULL, stdout); \ + return False; \ + } \ +} while (0) + /* test references @@ -771,7 +784,12 @@ static BOOL test_unref_reparent(void) c1 = talloc_named_const(p1, 1, "child"); talloc_reference(p2, c1); + CHECK_PARENT(c1, p1); + talloc_free(p1); + + CHECK_PARENT(c1, p2); + talloc_unlink(p2, c1); CHECK_SIZE(root, 1); @@ -888,6 +906,28 @@ static BOOL test_loop(void) return True; } +static BOOL test_free_parent_deny_child(void) +{ + char *top = talloc_new(NULL); + char *level1; + char *level2; + char *level3; + + printf("TESTING 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); + talloc_free(level1); + talloc_set_destructor(level3, NULL); + + CHECK_PARENT(level3, top); + + talloc_free(top); + + return True; +} BOOL torture_local_talloc(struct torture_context *torture) { @@ -909,6 +949,7 @@ BOOL torture_local_talloc(struct torture_context *torture) ret &= test_type(); ret &= test_lifeless(); ret &= test_loop(); + ret &= test_free_parent_deny_child(); if (ret) { ret &= test_speed(); } |