diff options
Diffstat (limited to 'hicn-light/src/hicn/base/test')
-rw-r--r-- | hicn-light/src/hicn/base/test/CMakeLists.txt | 4 | ||||
-rw-r--r-- | hicn-light/src/hicn/base/test/test-bitmap.cc | 14 | ||||
-rw-r--r-- | hicn-light/src/hicn/base/test/test-pool.cc | 21 | ||||
-rw-r--r-- | hicn-light/src/hicn/base/test/test-vector.cc | 6 |
4 files changed, 30 insertions, 15 deletions
diff --git a/hicn-light/src/hicn/base/test/CMakeLists.txt b/hicn-light/src/hicn/base/test/CMakeLists.txt index 351e7bd34..cdf6ed11b 100644 --- a/hicn-light/src/hicn/base/test/CMakeLists.txt +++ b/hicn-light/src/hicn/base/test/CMakeLists.txt @@ -15,9 +15,9 @@ foreach(test ${TESTS}) build_executable(${test} NO_INSTALL SOURCES ${test}.cc - LINK_LIBRARIES ${LIBHICN_LIGHT_SHARED} ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} + LINK_LIBRARIES ${LIBHICN_LIGHT_SHARED} ${LIBHICNCTRL_SHARED} ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} INCLUDE_DIRS ${HICN_LIGHT_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS} - DEPENDS gtest ${LIBHICN_LIGHT_SHARED} + DEPENDS gtest ${LIBHICNCTRL_SHARED} ${LIBHICN_LIGHT_SHARED} COMPONENT ${HICN_LIGHT} DEFINITIONS "${COMPILER_DEFINITIONS}" ) diff --git a/hicn-light/src/hicn/base/test/test-bitmap.cc b/hicn-light/src/hicn/base/test/test-bitmap.cc index 1a62edba3..d1b335ace 100644 --- a/hicn-light/src/hicn/base/test/test-bitmap.cc +++ b/hicn-light/src/hicn/base/test/test-bitmap.cc @@ -57,32 +57,32 @@ TEST_F(BitmapTest, BitmapAllocation) * Bitmap should have been allocated with a size rounded to the next power * of 2 */ - EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1); + EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1UL); /* By default, no element should be set */ EXPECT_FALSE(bitmap_is_set(bitmap, 0)); EXPECT_TRUE(bitmap_is_unset(bitmap, 0)); - EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1); + EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1UL); EXPECT_FALSE(bitmap_is_set(bitmap, size_not_pow2 - 1)); EXPECT_TRUE(bitmap_is_unset(bitmap, size_not_pow2 - 1)); /* Bitmap should not have been reallocated */ - EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1); + EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1UL); /* After setting a bit after the end, bitmap should have been reallocated */ bitmap_set(bitmap, sizeof(bitmap[0]) * 8 - 1); - EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1); + EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1UL); /* After setting a bit after the end, bitmap should have been reallocated */ rc = bitmap_set(bitmap, sizeof(bitmap[0]) * 8); EXPECT_GE(rc, 0); - EXPECT_EQ(bitmap_get_alloc_size(bitmap), 2); + EXPECT_EQ(bitmap_get_alloc_size(bitmap), 2UL); rc = bitmap_set(bitmap, sizeof(bitmap[0]) * 8 + 1); EXPECT_GE(rc, 0); - EXPECT_EQ(bitmap_get_alloc_size(bitmap), 2); + EXPECT_EQ(bitmap_get_alloc_size(bitmap), 2UL); bitmap_free(bitmap); @@ -90,7 +90,7 @@ TEST_F(BitmapTest, BitmapAllocation) /* Limiting test for allocation size */ bitmap_init(bitmap, size_pow2, 0); - EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1); + EXPECT_EQ(bitmap_get_alloc_size(bitmap), 1UL); bitmap_free(bitmap); } 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) { diff --git a/hicn-light/src/hicn/base/test/test-vector.cc b/hicn-light/src/hicn/base/test/test-vector.cc index 59571b053..aaec7a92c 100644 --- a/hicn-light/src/hicn/base/test/test-vector.cc +++ b/hicn-light/src/hicn/base/test/test-vector.cc @@ -49,15 +49,15 @@ TEST_F(VectorTest, VectorAllocate) vector_init(vector, DEFAULT_SIZE, 0); /* Allocated size should be the next power of two */ - EXPECT_EQ(vector_get_alloc_size(vector), 16); + EXPECT_EQ(vector_get_alloc_size(vector), 16UL); /* Setting elements within the allocated size should not trigger a resize */ vector_ensure_pos(vector, 15); - EXPECT_EQ(vector_get_alloc_size(vector), 16); + EXPECT_EQ(vector_get_alloc_size(vector), 16UL); /* Setting elements after should through */ vector_ensure_pos(vector, 16); - EXPECT_EQ(vector_get_alloc_size(vector), 32); + EXPECT_EQ(vector_get_alloc_size(vector), 32UL); /* Check that free indices and bitmaps are correctly updated */ |