talloc: Add tests for talloc_parent() after realloc() of the parent
authorAndrew Bartlett <abartlet@samba.org>
Sun, 27 Nov 2016 22:47:41 +0000 (11:47 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 1 Dec 2016 04:54:22 +0000 (05:54 +0100)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/talloc/testsuite.c

index 7f98f4b4668b5df9a73eb9496791f4445e60cfc6..835d38be9ce22d076c685ae98c444aa22b11fd42 100644 (file)
@@ -610,7 +610,7 @@ static bool test_realloc_child(void)
        void *root;
        struct el2 {
                const char *name;
-       } *el2
+       } *el2, *el2_2, *el2_3;
        struct el1 {
                int count;
                struct el2 **list, **list2, **list3;
@@ -634,13 +634,22 @@ static bool test_realloc_child(void)
        el1->list3[0]->name = talloc_strdup(el1->list3[0], "testing2");
        
        el2 = talloc(el1->list, struct el2);
-       el2 = talloc(el1->list2, struct el2);
-       el2 = talloc(el1->list3, struct el2);
-       (void)el2;
+       CHECK_PARENT("el2", el2, el1->list);
+       el2_2 = talloc(el1->list2, struct el2);
+       CHECK_PARENT("el2", el2_2, el1->list2);
+       el2_3 = talloc(el1->list3, struct el2);
+       CHECK_PARENT("el2", el2_3, el1->list3);
 
        el1->list = talloc_realloc(el1, el1->list, struct el2 *, 100);
+       CHECK_PARENT("el1_after_realloc", el1->list, el1);
        el1->list2 = talloc_realloc(el1, el1->list2, struct el2 *, 200);
+       CHECK_PARENT("el1_after_realloc", el1->list2, el1);
        el1->list3 = talloc_realloc(el1, el1->list3, struct el2 *, 300);
+       CHECK_PARENT("el1_after_realloc", el1->list3, el1);
+
+       CHECK_PARENT("el2", el2, el1->list);
+       CHECK_PARENT("el2", el2_2, el1->list2);
+       CHECK_PARENT("el2", el2_3, el1->list3);
 
        talloc_free(root);