From 6cd2a9ba81788cf89ae2ff1c7fcf4b5c4c715181 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 23 Nov 2016 22:22:04 +0100 Subject: [PATCH] Add a test for calloc(). --- plat/qemuppc/tests/calloc_c.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 plat/qemuppc/tests/calloc_c.c diff --git a/plat/qemuppc/tests/calloc_c.c b/plat/qemuppc/tests/calloc_c.c new file mode 100644 index 000000000..518aa7e49 --- /dev/null +++ b/plat/qemuppc/tests/calloc_c.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include "test.h" + +int main(int argc, const char* argv[]) +{ + const char* p; + int i; + + ASSERT(0 == calloc(0, 0)); + ASSERT(0 == calloc(0, 1)); + ASSERT(0 == calloc(1, 0)); + ASSERT(0 == calloc(SIZE_MAX/2, 3)); + ASSERT(0 == calloc(SIZE_MAX/2, 2)); + ASSERT(0 != calloc(1, 1)); + + p = calloc(10, 1); + for (i=0; i<10; i++) + ASSERT(0 == p[i]); + + finished(); +}