X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftalloc%2Ftest%2Frun.c;h=c501a7f9f4862d96afc4f21e3986f7885b6f060d;hp=ad70a51ec77761059470347acbbdaa4cbf5d3e37;hb=HEAD;hpb=f933b8c3246e3fbfe362cb1db73a4ef774725709 diff --git a/ccan/talloc/test/run.c b/ccan/talloc/test/run.c index ad70a51e..c501a7f9 100644 --- a/ccan/talloc/test/run.c +++ b/ccan/talloc/test/run.c @@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "talloc/talloc.c" +#include #include -#include "tap/tap.h" +#include #define torture_assert(test, expr, str) \ ok(expr, "%s [\n%s: Expression %s failed: %s\n]\n", \ @@ -438,14 +438,14 @@ static bool test_realloc(const struct torture_context *ctx) "failed: talloc_realloc() on a referenced pointer should fail\n"); CHECK_BLOCKS("realloc", p1, 4); - talloc_realloc_size(NULL, p2, 0); - talloc_realloc_size(NULL, p2, 0); + ok1(talloc_realloc_size(NULL, p2, 0) == NULL); + ok1(talloc_realloc_size(NULL, p2, 0) == NULL); CHECK_BLOCKS("realloc", p1, 3); torture_assert("realloc", talloc_realloc_size(NULL, p1, 0x7fffffff) == NULL, "failed: oversize talloc should fail\n"); - talloc_realloc_size(NULL, p1, 0); + p1 = talloc_realloc_size(NULL, p1, 0); CHECK_BLOCKS("realloc", root, 1); CHECK_SIZE("realloc", root, 0); @@ -937,7 +937,7 @@ static void *normal_realloc(const void *parent, void *ptr, size_t size) } allocations[i] = realloc(ptr, size); - /* Not guarenteed by realloc. */ + /* Not guaranteed by realloc. */ if (!size) allocations[i] = NULL; @@ -948,7 +948,7 @@ int main(void) { struct torture_context *ctx; - plan_tests(284); + plan_tests(289); ctx = talloc_add_external(NULL, normal_realloc, test_lock, test_unlock); torture_local_talloc(NULL); @@ -979,6 +979,10 @@ int main(void) ok(allocations_used() == 0, "%u allocations still used?", allocations_used()); + /* This closes the leak, but make sure we're not freeing unexpected. */ + ok1(!talloc_chunk_from_ptr(null_context)->child); + talloc_disable_null_tracking(); + return exit_status(); }