Add a test for brk() and sbrk().
This commit is contained in:
parent
6cd2a9ba81
commit
991f47098c
28
plat/qemuppc/tests/brk_c.c
Normal file
28
plat/qemuppc/tests/brk_c.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#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();
|
||||
}
|
||||
|
Loading…
Reference in a new issue