aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/base/test/test-pool.cc
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2020-09-23 17:50:52 +0200
committerMauro Sardara <msardara@cisco.com>2021-03-19 14:15:14 +0100
commita070b0de9f9e9cbca150eea4eda74757ca588bed (patch)
tree9f2a11fa1afcd51b0b14f4b26bebf4deb8289a2f /hicn-light/src/hicn/base/test/test-pool.cc
parent32dccec98e4c7d7e4ce902e19ba8d1b29b823758 (diff)
[HICN-645] Control plane (WIP)
Change-Id: I4be6a40b690b62f22f57de6d8c10b01a1be42a6d Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com> Signed-off-by: Enrico Loparco (eloparco) <eloparco@cisco.com> Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/base/test/test-pool.cc')
-rw-r--r--hicn-light/src/hicn/base/test/test-pool.cc21
1 files changed, 18 insertions, 3 deletions
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)
{