diff --git a/build.lua b/build.lua index 584449834..2b5ec62a0 100644 --- a/build.lua +++ b/build.lua @@ -14,6 +14,7 @@ vars.plats = { "rpi", } vars.plats_with_tests = { + "linuxppc", "qemuppc", "pc86", } diff --git a/plat/linux/libsys/sbrk.c b/plat/linux/libsys/sbrk.c index 7aeeecb86..f790a17cb 100644 --- a/plat/linux/libsys/sbrk.c +++ b/plat/linux/libsys/sbrk.c @@ -26,7 +26,6 @@ void* sbrk(int increment) { char* old; char* new; - char* actual; if (!current) current = (char*) _syscall(__NR_brk, 0, 0, 0); @@ -35,15 +34,21 @@ void* sbrk(int increment) return current; old = current; + new = old + increment; - actual = (char*) _syscall(__NR_brk, (quad) new, 0, 0); - if (actual < new) - { - errno = ENOMEM; - return OUT_OF_MEMORY; - } + if ((increment > 0) && (new <= old)) + goto out_of_memory; + else if ((increment < 0) && (new >= old)) + goto out_of_memory; + + if (brk(new) < 0) + goto out_of_memory; - current = actual; return old; + +out_of_memory: + errno = ENOMEM; + return OUT_OF_MEMORY; } + diff --git a/plat/linuxppc/tests/build.lua b/plat/linuxppc/tests/build.lua new file mode 100644 index 000000000..7601ab0be --- /dev/null +++ b/plat/linuxppc/tests/build.lua @@ -0,0 +1,7 @@ +include("tests/plat/build.lua") + +plat_testsuite { + name = "tests", + plat = "linuxppc", + method = "qemu-ppc" +} diff --git a/tests/plat/brk_c.c b/tests/plat/brk_c.c index 9a07c7d3b..434cec50b 100644 --- a/tests/plat/brk_c.c +++ b/tests/plat/brk_c.c @@ -10,10 +10,6 @@ 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)); diff --git a/tests/plat/lib/test.c b/tests/plat/lib/test.c index d05417326..df00e1089 100644 --- a/tests/plat/lib/test.c +++ b/tests/plat/lib/test.c @@ -6,6 +6,7 @@ void finished(void) { static const char s[] = "@@FINISHED\n"; write(1, s, sizeof(s)); + _exit(0); } void writehex(uint32_t code) diff --git a/tests/plat/testdriver.sh b/tests/plat/testdriver.sh index 29d9063eb..f5ca187a3 100755 --- a/tests/plat/testdriver.sh +++ b/tests/plat/testdriver.sh @@ -31,6 +31,20 @@ case $method in | ( read dummy && kill $(cat $pidfile) ) ;; + + qemu-*) + if ! hash $method 2>/dev/null; then + echo "Warning: $method not installed, skipping test" + exit 0 + fi + + $method $img > $result + ;; + + *) + echo "Error: $method not known by testdriver" + exit 1 + ;; esac ( grep -q @@FAIL $result || ! grep -q @@FINISHED $result ) && cat $result && exit 1