From a070b0de9f9e9cbca150eea4eda74757ca588bed Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Wed, 23 Sep 2020 17:50:52 +0200 Subject: [HICN-645] Control plane (WIP) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4be6a40b690b62f22f57de6d8c10b01a1be42a6d Signed-off-by: Jordan Augé Signed-off-by: Enrico Loparco (eloparco) Signed-off-by: Mauro Sardara --- hicn-light/src/hicn/base/test/test-pool.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'hicn-light/src/hicn/base/test/test-pool.cc') diff --git a/hicn-light/src/hicn/base/test/test-pool.cc b/hicn-light/src/hicn/base/test/test-pool.cc index 1146ef2b7..f87ff65dd 100644 --- a/hicn-light/src/hicn/base/test/test-pool.cc +++ b/hicn-light/src/hicn/base/test/test-pool.cc @@ -56,7 +56,7 @@ TEST_F(PoolTest, PoolAllocation) /* Check that free indices and bitmaps are correctly initialize */ off_t * fi = pool_get_free_indices(pool); EXPECT_EQ(vector_len(fi), pool_size); - EXPECT_EQ(fi[0], pool_size - 1); + EXPECT_EQ(fi[0], (long) (pool_size - 1)); EXPECT_EQ(fi[pool_size - 1], 0); /* The allocated size of the underlying vector should be the next power of two */ @@ -89,12 +89,12 @@ TEST_F(PoolTest, PoolAllocation) rc = pool_get(pool, elt); EXPECT_GE(rc, 0); - EXPECT_EQ(vector_len(fi), 1); + EXPECT_EQ(vector_len(fi), 1UL); EXPECT_TRUE(bitmap_is_unset(fb, pool_size - 2)); rc = pool_get(pool, elt); EXPECT_GE(rc, 0); - EXPECT_EQ(vector_len(fi), 0); + EXPECT_EQ(vector_len(fi), 0UL); EXPECT_TRUE(bitmap_is_unset(fb, pool_size - 1)); /* @@ -155,6 +155,21 @@ TEST_F(PoolTest, PoolPut) pool_free(pool); } +// TODO: this test fails, there is a problem when N = n*64 +// (i.e. when a bitmap reallocation occurs) +TEST_F(PoolTest, PoolGetForceBitmapRealloc) +{ + const int N = 64; + int *elts[N]; + int *elt = NULL; + pool_init(pool, N, 0); + + for (int i = 0; i < N; i++) + pool_get(pool, elts[i]); + pool_get(pool, elt); + + pool_free(pool); +} int main(int argc, char **argv) { -- cgit 1.2.3-korg