summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-12-22 17:29:15 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-12-22 17:42:11 +0100
commitfe62f3aa57097a157b52151f33d9ce9f90e839fd (patch)
tree3bc219ca00ccca646f961da0bddb70fb6a4d5e79
parentsptests/speventsystem01: Add test cases (diff)
downloadrtems-fe62f3aa57097a157b52151f33d9ce9f90e839fd.tar.bz2
libtests/rbheap01: Add test cases
-rw-r--r--testsuites/libtests/rbheap01/init.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/testsuites/libtests/rbheap01/init.c b/testsuites/libtests/rbheap01/init.c
index f6daa55a1f..239853fc83 100644
--- a/testsuites/libtests/rbheap01/init.c
+++ b/testsuites/libtests/rbheap01/init.c
@@ -20,6 +20,7 @@
#include <rtems.h>
#include <rtems/rbheap.h>
+#include <rtems/malloc.h>
/* forward declarations to avoid warnings */
static rtems_task Init(rtems_task_argument argument);
@@ -389,6 +390,45 @@ static void test_alloc_many_chunks(void)
TEST_PAGE_TREE(&control, indices_1, frees_1);
}
+static void test_alloc_misaligned(void)
+{
+ rtems_rbheap_control control;
+ void *p;
+
+ test_init_successful(&control);
+
+ p = rtems_rbheap_allocate(&control, PAGE_SIZE - 1);
+ rtems_test_assert(p != NULL);
+}
+
+static void test_alloc_with_malloc_extend(void)
+{
+ rtems_status_code sc;
+ rtems_rbheap_control control;
+ void *p;
+ void *opaque;
+
+ sc = rtems_rbheap_initialize(
+ &control,
+ area,
+ sizeof(area),
+ PAGE_SIZE,
+ rtems_rbheap_extend_descriptors_with_malloc,
+ NULL
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ opaque = rtems_heap_greedy_allocate(NULL, 0);
+
+ p = rtems_rbheap_allocate(&control, PAGE_SIZE);
+ rtems_test_assert(p == NULL);
+
+ rtems_heap_greedy_free(opaque);
+
+ p = rtems_rbheap_allocate(&control, PAGE_SIZE);
+ rtems_test_assert(p != NULL);
+}
+
static void test_free_null(void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
@@ -564,6 +604,8 @@ static void Init(rtems_task_argument arg)
test_alloc_huge_chunk();
test_alloc_one_chunk();
test_alloc_many_chunks();
+ test_alloc_misaligned();
+ test_alloc_with_malloc_extend();
test_free_null();
test_free_invalid();
test_free_double();