diff options
author | Florin Coras <fcoras@cisco.com> | 2020-12-07 14:33:58 -0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-12-23 02:27:52 +0000 |
commit | 213b1bb3b9652ce2937e3b47573cc54ee3008387 (patch) | |
tree | 0445b51256183db2c8593390a1f95e0234dbffc6 /src/plugins/unittest/svm_fifo_test.c | |
parent | 0da8168423349dfb1852d4708d67014de36748b8 (diff) |
svm: remove fifo segment heap
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I518e096fe13847759806ff62009e73fd8f7451b7
Diffstat (limited to 'src/plugins/unittest/svm_fifo_test.c')
-rw-r--r-- | src/plugins/unittest/svm_fifo_test.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/plugins/unittest/svm_fifo_test.c b/src/plugins/unittest/svm_fifo_test.c index a3f88d35b9c..a223e132d3d 100644 --- a/src/plugins/unittest/svm_fifo_test.c +++ b/src/plugins/unittest/svm_fifo_test.c @@ -2536,6 +2536,14 @@ sfifo_test_fifo_segment_mempig (int verbose) } static int +approx_leq (uword a, uword b, u32 margin) +{ + if (a - margin <= b && b <= a) + return 1; + return 0; +} + +static int sfifo_test_fifo_segment_prealloc (int verbose) { fifo_segment_create_args_t _a, *a = &_a; @@ -2568,8 +2576,10 @@ sfifo_test_fifo_segment_prealloc (int verbose) SFIFO_TEST (rv == 50, "prealloc chunks expected %u is %u", 50, rv); rv = fifo_segment_free_bytes (fs); free_space -= (sizeof (svm_fifo_chunk_t) + 4096) * 50; - SFIFO_TEST (rv == free_space, "free space expected %u is %u", free_space, - rv); + /* Memory alloc alignment accounts for the difference */ + SFIFO_TEST (approx_leq (free_space, rv, 16), "free space expected %u is %u", + free_space, rv); + free_space = rv; rv = fifo_segment_fl_chunk_bytes (fs); SFIFO_TEST (rv == 4096 * 50, "chunk free space expected %u is %u", 4096 * 50, rv); @@ -2580,10 +2590,11 @@ sfifo_test_fifo_segment_prealloc (int verbose) SFIFO_TEST (rv == 50, "prealloc fifo hdrs expected %u is %u", 50, rv); rv = fifo_segment_free_bytes (fs); free_space -= sizeof (svm_fifo_t) * 50; - SFIFO_TEST (rv == free_space, "free space expected %u is %u", free_space, - rv); + /* Memory alloc alignment accounts for the difference */ + SFIFO_TEST (approx_leq (free_space, rv, 16), "free space expected %u is %u", + free_space, rv); + free_space = rv; - fifo_segment_update_free_bytes (fs); rv = fifo_segment_free_bytes (fs); SFIFO_TEST (clib_abs (rv - (int) free_space) < 512, "free space expected %u is %u", free_space, rv); @@ -2606,7 +2617,6 @@ sfifo_test_fifo_segment_prealloc (int verbose) /* * Multiple preallocs that consume the remaining space */ - fifo_segment_update_free_bytes (fs); free_space = fifo_segment_free_bytes (fs); pair_mem = 2 * (4096 + sizeof (*f) + sizeof (svm_fifo_chunk_t)); max_pairs = pairs_req = (free_space / pair_mem) - 1; @@ -2616,7 +2626,6 @@ sfifo_test_fifo_segment_prealloc (int verbose) SFIFO_TEST (rv == max_pairs * 2, "prealloc chunks expected %u is %u", max_pairs * 2, rv); - fifo_segment_update_free_bytes (fs); rv = fifo_segment_free_bytes (fs); SFIFO_TEST (rv < 2 * pair_mem, "free bytes %u less than %u", rv, 2 * pair_mem); |