Add a test for brk() and sbrk().

This commit is contained in:
David Given 2016-11-23 22:28:21 +01:00
parent 6cd2a9ba81
commit 991f47098c

View 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();
}