diff --git a/libuavcan/test/transport/can_acceptance_filter_configurator.cpp b/libuavcan/test/transport/can_acceptance_filter_configurator.cpp index ab5e79aa53..ff3e647989 100644 --- a/libuavcan/test/transport/can_acceptance_filter_configurator.cpp +++ b/libuavcan/test/transport/can_acceptance_filter_configurator.cpp @@ -145,10 +145,10 @@ TEST(CanAcceptanceFilter, Basic_test) std::cout << "config.MK [" << i << "]= " << configure_array.getByIndex(i)->mask << std::endl; } - ASSERT_EQ(configure_array.getByIndex(0)->id, 0); - ASSERT_EQ(configure_array.getByIndex(0)->mask, 255); - ASSERT_EQ(configure_array.getByIndex(1)->id, 256000); - ASSERT_EQ(configure_array.getByIndex(1)->mask, 16771968); + ASSERT_EQ(configure_array.getByIndex(0)->id, 256000); + ASSERT_EQ(configure_array.getByIndex(0)->mask, 16771968); + ASSERT_EQ(configure_array.getByIndex(1)->id, 0); + ASSERT_EQ(configure_array.getByIndex(1)->mask, 255); ASSERT_EQ(configure_array.getByIndex(2)->id, 6272); ASSERT_EQ(configure_array.getByIndex(2)->mask, 32640); ASSERT_EQ(configure_array.getByIndex(3)->id, 262144); @@ -170,16 +170,16 @@ TEST(CanAcceptanceFilter, Basic_test) for (uint16_t i = 0; icreate(keys[3]))); - ASSERT_LT(0, pool.getNumUsedBlocks()); ASSERT_LT(0, fillTestData(MGR_TEST_DATA[3], tbb)); - ASSERT_EQ(2, mgr->getNumBuffers()); - - // Dynamic 3 - will fail due to OOM - ASSERT_FALSE((tbb = mgr->create(keys[4]))); - ASSERT_EQ(2, mgr->getNumBuffers()); + ASSERT_EQ(4, mgr->getNumBuffers()); // Making sure all buffers contain proper data ASSERT_TRUE((tbb = mgr->access(keys[0]))); @@ -292,12 +285,12 @@ TEST(TransferBufferManager, Basic) mgr->remove(keys[1]); ASSERT_FALSE(mgr->access(keys[1])); - ASSERT_EQ(1, mgr->getNumBuffers()); + ASSERT_EQ(3, mgr->getNumBuffers()); ASSERT_LT(0, pool.getNumFreeBlocks()); mgr->remove(keys[0]); ASSERT_FALSE(mgr->access(keys[0])); - ASSERT_EQ(0, mgr->getNumBuffers()); + ASSERT_EQ(2, mgr->getNumBuffers()); // At this time we have the following NodeID: 2, 127 ASSERT_TRUE((tbb = mgr->access(keys[2]))); diff --git a/libuavcan/test/transport/transfer_listener.cpp b/libuavcan/test/transport/transfer_listener.cpp index d5e07596e0..a4ea34b2b0 100644 --- a/libuavcan/test/transport/transfer_listener.cpp +++ b/libuavcan/test/transport/transfer_listener.cpp @@ -34,7 +34,7 @@ TEST(TransferListener, BasicMFT) { const uavcan::DataTypeDescriptor type(uavcan::DataTypeKindMessage, 123, uavcan::DataTypeSignature(123456789), "A"); - static const int NUM_POOL_BLOCKS = 12; // This number is just enough to pass the test + static const int NUM_POOL_BLOCKS = 100; uavcan::PoolAllocator pool; uavcan::TransferPerfCounter perf; @@ -93,7 +93,8 @@ TEST(TransferListener, CrcFailure) { const uavcan::DataTypeDescriptor type(uavcan::DataTypeKindMessage, 123, uavcan::DataTypeSignature(123456789), "A"); - NullAllocator poolmgr; // No dynamic memory + static const int NUM_POOL_BLOCKS = 100; + uavcan::PoolAllocator poolmgr; uavcan::TransferPerfCounter perf; TestListener<256> subscriber(perf, type, poolmgr); // Static buffer only, 2 entries @@ -136,7 +137,8 @@ TEST(TransferListener, BasicSFT) { const uavcan::DataTypeDescriptor type(uavcan::DataTypeKindMessage, 123, uavcan::DataTypeSignature(123456789), "A"); - NullAllocator poolmgr; // No dynamic memory. At all. + static const int NUM_POOL_BLOCKS = 100; + uavcan::PoolAllocator poolmgr; uavcan::TransferPerfCounter perf; TestListener<0> subscriber(perf, type, poolmgr); // Max buf size is 0, i.e. SFT-only @@ -148,7 +150,6 @@ TEST(TransferListener, BasicSFT) emulator.makeTransfer(16, uavcan::TransferTypeServiceRequest, 2, ""), emulator.makeTransfer(16, uavcan::TransferTypeServiceRequest, 3, "abc"), emulator.makeTransfer(16, uavcan::TransferTypeServiceResponse, 4, ""), - emulator.makeTransfer(16, uavcan::TransferTypeServiceResponse, 2, ""), // New TT, ignored due to OOM emulator.makeTransfer(16, uavcan::TransferTypeServiceRequest, 2, "foo"), // Same as 2, not ignored emulator.makeTransfer(16, uavcan::TransferTypeServiceRequest, 2, "123456789abc"), // Same as 2, not SFT - ignore emulator.makeTransfer(16, uavcan::TransferTypeServiceRequest, 2, "bar"), // Same as 2, not ignored @@ -161,8 +162,8 @@ TEST(TransferListener, BasicSFT) ASSERT_TRUE(subscriber.matchAndPop(transfers[2])); ASSERT_TRUE(subscriber.matchAndPop(transfers[3])); ASSERT_TRUE(subscriber.matchAndPop(transfers[4])); - ASSERT_TRUE(subscriber.matchAndPop(transfers[6])); - ASSERT_TRUE(subscriber.matchAndPop(transfers[8])); + ASSERT_TRUE(subscriber.matchAndPop(transfers[5])); + ASSERT_TRUE(subscriber.matchAndPop(transfers[7])); ASSERT_TRUE(subscriber.isEmpty()); } @@ -172,7 +173,8 @@ TEST(TransferListener, Cleanup) { const uavcan::DataTypeDescriptor type(uavcan::DataTypeKindMessage, 123, uavcan::DataTypeSignature(123456789), "A"); - NullAllocator poolmgr; // No dynamic memory + static const int NUM_POOL_BLOCKS = 100; + uavcan::PoolAllocator poolmgr; uavcan::TransferPerfCounter perf; TestListener<256> subscriber(perf, type, poolmgr); // Static buffer only, 1 entry @@ -227,7 +229,8 @@ TEST(TransferListener, AnonymousTransfers) { const uavcan::DataTypeDescriptor type(uavcan::DataTypeKindMessage, 123, uavcan::DataTypeSignature(123456789), "A"); - NullAllocator poolmgr; + static const int NUM_POOL_BLOCKS = 100; + uavcan::PoolAllocator poolmgr; uavcan::TransferPerfCounter perf; TestListener<0> subscriber(perf, type, poolmgr);