diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-08-29 17:31:01 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-08-29 17:31:01 +0000 |
commit | 79bedccb6c48dfadc47ac91549ba0043d3ab9e53 (patch) | |
tree | e8209d3d033294e95d50207d392d7655a6b143bf /test/testheap.c | |
parent | 5eff277ef42641d64c066fa69b3a6a84cce8053f (diff) | |
download | ChibiOS-79bedccb6c48dfadc47ac91549ba0043d3ab9e53.tar.gz ChibiOS-79bedccb6c48dfadc47ac91549ba0043d3ab9e53.tar.bz2 ChibiOS-79bedccb6c48dfadc47ac91549ba0043d3ab9e53.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@416 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/testheap.c')
-rw-r--r-- | test/testheap.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/testheap.c b/test/testheap.c index c719818f6..775902dd3 100644 --- a/test/testheap.c +++ b/test/testheap.c @@ -38,9 +38,15 @@ static void heap1_teardown(void) { static void heap1_execute(void) {
void *p1, *p2, *p3;
+ size_t n, sz;
/* Test skipped if the heap is already fragmented. */
- if (chHeapNotFragmented()) {
+
+ if ((n = chHeapStatus(&sz)) == 1) {
+ test_print("--- Size : ");
+ test_printn(sz);
+ test_println(" bytes, not fragmented");
+
/* Same order */
p1 = chHeapAlloc(SIZE);
p2 = chHeapAlloc(SIZE);
@@ -48,7 +54,7 @@ static void heap1_execute(void) { chHeapFree(p1); /* Does not merge */
chHeapFree(p2); /* Merges backward */
chHeapFree(p3); /* Merges both sides */
- test_assert(chHeapNotFragmented(), "heap fragmented #1");
+ test_assert(chHeapStatus(&n) == 1, "heap fragmented #1");
/* Reverse order */
p1 = chHeapAlloc(SIZE);
@@ -57,7 +63,14 @@ static void heap1_execute(void) { chHeapFree(p3); /* Merges forward */
chHeapFree(p2); /* Merges forward */
chHeapFree(p1); /* Merges forward */
- test_assert(chHeapNotFragmented(), "heap fragmented #2");
+ test_assert(chHeapStatus(&n) == 1, "heap fragmented #2");
+
+ test_assert(n == sz, "heap size changed");
+ }
+ else {
+ test_print("--- Size : ");
+ test_printn(sz);
+ test_println(" bytes, fragmented, test skipped");
}
}
|