diff mbox

[dpdk-dev,v3,13/14] test_memzone:fix finding the second smallest segment

Message ID 1416792142-23132-14-git-send-email-chaozhu@linux.vnet.ibm.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Chao Zhu Nov. 24, 2014, 1:22 a.m. UTC
Curent implementation in test_memzone.c has bugs in finding the
second smallest memory segment. It's the last smallest memory segment,
but it's not the second smallest memory segment. This bug may cause test
failure in some cases. This patch fixes this bug.

Signed-off-by: Chao Zhu <chaozhu@linux.vnet.ibm.com>
---
 app/test/test_memzone.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 8668103..f3da2c1 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -794,7 +794,7 @@  test_memzone_reserve_memory_in_smallest_segment(void)
 			/* set new smallest */
 			min_ms = ms;
 		}
-		else if (prev_min_ms == NULL) {
+		else if ((prev_min_ms == NULL) || (prev_min_ms->len > ms->len)) {
 			prev_min_ms = ms;
 		}
 	}
@@ -874,7 +874,7 @@  test_memzone_reserve_memory_with_smallest_offset(void)
 			/* set new smallest */
 			min_ms = ms;
 		}
-		else if (prev_min_ms == NULL) {
+		else if ((prev_min_ms == NULL) || (prev_min_ms->len > ms->len)){
 			prev_min_ms = ms;
 		}
 	}