X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fidtree%2Ftest%2Frun.c;h=a3b4fb63a877c1703d4628b612ed0b5501da832b;hb=4eb5f52c94d6c32f1b8347ee599906d60239e0d4;hp=bd12f4c3b2063513f909ddccffc4df015c4d8b12;hpb=184070eb4a4a2e130c0053eb82fd8c96a19e954f;p=ccan diff --git a/ccan/idtree/test/run.c b/ccan/idtree/test/run.c index bd12f4c3..a3b4fb63 100644 --- a/ccan/idtree/test/run.c +++ b/ccan/idtree/test/run.c @@ -2,7 +2,17 @@ #include #include -#define ALLOC_MAX 32 +#define ALLOC_MAX (2 * IDTREE_SIZE) + +static bool check_tal_parent(const tal_t *parent, const tal_t *ctx) +{ + while (ctx) { + if (ctx == parent) + return true; + ctx = tal_parent(ctx); + } + return false; +} int main(int argc, char *argv[]) { @@ -12,9 +22,9 @@ int main(int argc, char *argv[]) void *ctx; plan_tests(ALLOC_MAX * 5 + 2); - ctx = talloc_named_const(NULL, 1, "test root"); + ctx = tal(NULL, char); idtree = idtree_new(ctx); - ok1(talloc_find_parent_byname(idtree, "test root") == ctx); + ok1(check_tal_parent(ctx, idtree)); for (i = 0; i < ALLOC_MAX; i++) { int id = idtree_add(idtree, &allocated[i], ALLOC_MAX-1); @@ -42,6 +52,6 @@ int main(int argc, char *argv[]) for (i = 0; i < ALLOC_MAX; i++) { ok1(idtree_lookup(idtree, i) == &allocated[i]); } - talloc_free(ctx); + tal_free(ctx); exit(exit_status()); }