ack/tests/plat/brk_c.c
David Given 8a58614aef Rework the tests to run on pc86; lots of test fixes for the brk() test, which
was nearly useless; lots of fixes to qemuppc and pc86 sbrk(), which was broken;
change the pc86 console to echo output to the serial port (needed for running
tests on qemu).
2016-11-26 11:23:25 +01:00

51 lines
842 B
C

#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[])
{
char* o;
char* p;
errno = 0;
ASSERT(-1 == brk((void*)-1));
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));
errno = 0;
o = sbrk(INT_MAX);
if (o == (char*)-1)
ASSERT(ENOMEM == errno);
else
{
ASSERT(0 == errno);
p = sbrk(0);
ASSERT(p > o);
brk(o);
}
errno = 0;
o = sbrk(INT_MIN);
if (o == (char*)-1)
ASSERT(ENOMEM == errno);
else
{
ASSERT(0 == errno);
p = sbrk(0);
ASSERT(p < o);
brk(o);
}
finished();
}