Author: metze Date: 2006-08-05 05:43:47 +0000 (Sat, 05 Aug 2006) New Revision: 17413
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17413 Log: add a new case for the this: top->level1->level2->level3 level3 has a deny destructor talloc_free(level1) result: top->level3 metze Modified: branches/SAMBA_4_0/source/lib/talloc/testsuite.c Changeset: Modified: branches/SAMBA_4_0/source/lib/talloc/testsuite.c =================================================================== --- branches/SAMBA_4_0/source/lib/talloc/testsuite.c 2006-08-05 05:03:10 UTC (rev 17412) +++ branches/SAMBA_4_0/source/lib/talloc/testsuite.c 2006-08-05 05:43:47 UTC (rev 17413) @@ -95,7 +95,20 @@ } \ } 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 @@ 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,7 +906,29 @@ 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) { BOOL ret = True; @@ -909,6 +949,7 @@ ret &= test_type(); ret &= test_lifeless(); ret &= test_loop(); + ret &= test_free_parent_deny_child(); if (ret) { ret &= test_speed(); }
