Loading CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ add_library(pwmpi src/dma/cb.h src/bcm/base.h src/dma/ti.h src/mem/bmap.h src/dm add_executable(pwmpi-demo src/main.cpp src/misc.h) add_executable(pwmpi-test test/utmain.cpp test/test_allocation_table.cpp) add_executable(pwmpi-test test/utmain.cpp test/test_allocation_table.cpp test/test_resident_allocator.cpp) target_link_libraries(pwmpi-demo pwmpi) target_link_libraries(pwmpi-test pwmpi) Loading test/test_allocation_table.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ #include <catch2/catch.hpp> #include <mem/allocation_table.h> #include <array> #include <misc.h> namespace { inline mem::chunk mkchunk(std::uintptr_t ofs, std::size_t sz) { Loading test/test_resident_allocator.cpp 0 → 100644 +34 −0 Original line number Diff line number Diff line // // Created by Pietro Saccardi on 04/09/2019. // #include <catch2/catch.hpp> #include <mem/resident_allocator.h> TEST_CASE("Allocate simple", "[resident_allocator]") { mem::resident_memory_resource pmr; static constexpr std::size_t sz = 100; void * const addr = pmr.allocate(sz); REQUIRE(pmr.pool_size() >= sz); if (pmr.pool_size() > sz) { REQUIRE(pmr.num_fragments() == 1); REQUIRE(pmr.largest_fragment_size() == pmr.pool_size() - sz); } else { REQUIRE(pmr.num_fragments() == 0); REQUIRE(pmr.largest_fragment_size() == 0); } REQUIRE(pmr.used_memory() == sz); pmr.deallocate(addr, sz); REQUIRE(pmr.num_fragments() == 1); REQUIRE(pmr.largest_fragment_size() == pmr.pool_size()); REQUIRE(pmr.pool_size() >= sz); REQUIRE(pmr.available_memory() == pmr.pool_size()); REQUIRE(pmr.used_memory() == 0); const auto saved_spc = pmr.try_reduce_pool_size(); REQUIRE(saved_spc >= sz); REQUIRE(pmr.num_fragments() == 0); REQUIRE(pmr.pool_size() == 0); REQUIRE(pmr.largest_fragment_size() == 0); REQUIRE(pmr.available_memory() == 0); } No newline at end of file Loading
CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ add_library(pwmpi src/dma/cb.h src/bcm/base.h src/dma/ti.h src/mem/bmap.h src/dm add_executable(pwmpi-demo src/main.cpp src/misc.h) add_executable(pwmpi-test test/utmain.cpp test/test_allocation_table.cpp) add_executable(pwmpi-test test/utmain.cpp test/test_allocation_table.cpp test/test_resident_allocator.cpp) target_link_libraries(pwmpi-demo pwmpi) target_link_libraries(pwmpi-test pwmpi) Loading
test/test_allocation_table.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ #include <catch2/catch.hpp> #include <mem/allocation_table.h> #include <array> #include <misc.h> namespace { inline mem::chunk mkchunk(std::uintptr_t ofs, std::size_t sz) { Loading
test/test_resident_allocator.cpp 0 → 100644 +34 −0 Original line number Diff line number Diff line // // Created by Pietro Saccardi on 04/09/2019. // #include <catch2/catch.hpp> #include <mem/resident_allocator.h> TEST_CASE("Allocate simple", "[resident_allocator]") { mem::resident_memory_resource pmr; static constexpr std::size_t sz = 100; void * const addr = pmr.allocate(sz); REQUIRE(pmr.pool_size() >= sz); if (pmr.pool_size() > sz) { REQUIRE(pmr.num_fragments() == 1); REQUIRE(pmr.largest_fragment_size() == pmr.pool_size() - sz); } else { REQUIRE(pmr.num_fragments() == 0); REQUIRE(pmr.largest_fragment_size() == 0); } REQUIRE(pmr.used_memory() == sz); pmr.deallocate(addr, sz); REQUIRE(pmr.num_fragments() == 1); REQUIRE(pmr.largest_fragment_size() == pmr.pool_size()); REQUIRE(pmr.pool_size() >= sz); REQUIRE(pmr.available_memory() == pmr.pool_size()); REQUIRE(pmr.used_memory() == 0); const auto saved_spc = pmr.try_reduce_pool_size(); REQUIRE(saved_spc >= sz); REQUIRE(pmr.num_fragments() == 0); REQUIRE(pmr.pool_size() == 0); REQUIRE(pmr.largest_fragment_size() == 0); REQUIRE(pmr.available_memory() == 0); } No newline at end of file