app/test: fix finding the second smallest memory segment

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>
Acked-by: David Marchand <david.marchand@6wind.com>
This commit is contained in:
Chao Zhu 2014-11-25 17:17:16 -05:00 committed by Thomas Monjalon
parent d05e7115f4
commit 6e8ae24ab8

View File

@ -797,10 +797,9 @@ 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;
}
}
if (min_ms == NULL || prev_min_ms == NULL) {
@ -877,8 +876,8 @@ 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;
}
}