From 991f47098ceb2d812808f730d15f7fa21c79d33e Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 23 Nov 2016 22:28:21 +0100 Subject: [PATCH] Add a test for brk() and sbrk(). --- plat/qemuppc/tests/brk_c.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 plat/qemuppc/tests/brk_c.c diff --git a/plat/qemuppc/tests/brk_c.c b/plat/qemuppc/tests/brk_c.c new file mode 100644 index 000000000..aa0f7ef99 --- /dev/null +++ b/plat/qemuppc/tests/brk_c.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include "test.h" + +int main(int argc, const char* argv[]) +{ + void* p; + + ASSERT(-1 == (intptr_t)brk((void*)0xffffffff)); + ASSERT(ENOMEM == errno); + + p = sbrk(0); + ASSERT(p == sbrk(0)); + ASSERT(p == sbrk(8)); + ASSERT(p != sbrk(0)); + ASSERT(p != sbrk(-8)); + ASSERT(p == sbrk(0)); + + /* We assume the test environment has less than 2GB of RAM. */ + ASSERT(-1 == (intptr_t)sbrk(INT_MAX)); + ASSERT(-1 == (intptr_t)sbrk(INT_MIN)); + + finished(); +} +