mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-19 04:29:06 +08:00
More transport test fixes, 4 to go
This commit is contained in:
parent
706198fa38
commit
34b32ce0c0
@ -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; i<configure_array_size; i++)
|
||||
{
|
||||
std::cout << "config.ID [" << i << "]= " << configure_array.getByIndex(i)->id << std::endl;
|
||||
std::cout << "config.MK [" << i << "]= " << configure_array.getByIndex(i)->mask << std::endl;
|
||||
std::cout << "config.ID [" << i << "]= " << configure_array_2.getByIndex(i)->id << std::endl;
|
||||
std::cout << "config.MK [" << i << "]= " << configure_array_2.getByIndex(i)->mask << std::endl;
|
||||
}
|
||||
|
||||
ASSERT_EQ(configure_array_2.getByIndex(0)->id, 6272);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(0)->mask, 32640);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(0)->id, 256000);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(0)->mask, 16771968);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(1)->id, 262144);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(1)->mask, 16776320);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(2)->id, 256000);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(2)->mask, 16771968);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(2)->id, 6272);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(2)->mask, 32640);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(3)->id, 262144);
|
||||
ASSERT_EQ(configure_array_2.getByIndex(3)->mask, 16771968);
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ TEST(TransferBufferManager, Basic)
|
||||
using uavcan::TransferBufferManagerKey;
|
||||
using uavcan::ITransferBuffer;
|
||||
|
||||
static const int POOL_BLOCKS = 8;
|
||||
static const int POOL_BLOCKS = 100;
|
||||
uavcan::PoolAllocator<uavcan::MemPoolBlockSize * POOL_BLOCKS, uavcan::MemPoolBlockSize> pool;
|
||||
|
||||
typedef TransferBufferManager<MGR_MAX_BUFFER_SIZE> TransferBufferManagerType;
|
||||
@ -256,26 +256,19 @@ TEST(TransferBufferManager, Basic)
|
||||
|
||||
ASSERT_TRUE((tbb = mgr->create(keys[1])));
|
||||
ASSERT_EQ(MGR_MAX_BUFFER_SIZE, fillTestData(MGR_TEST_DATA[1], tbb));
|
||||
ASSERT_EQ(0, mgr->getNumBuffers());
|
||||
ASSERT_EQ(0, pool.getNumUsedBlocks());
|
||||
ASSERT_EQ(2, mgr->getNumBuffers());
|
||||
ASSERT_LT(2, pool.getNumUsedBlocks());
|
||||
|
||||
ASSERT_TRUE((tbb = mgr->create(keys[2])));
|
||||
ASSERT_EQ(1, pool.getNumUsedBlocks()); // Empty dynamic buffer occupies one block
|
||||
ASSERT_EQ(MGR_MAX_BUFFER_SIZE, fillTestData(MGR_TEST_DATA[2], tbb));
|
||||
ASSERT_EQ(1, mgr->getNumBuffers());
|
||||
ASSERT_LT(1, pool.getNumUsedBlocks());
|
||||
ASSERT_EQ(3, mgr->getNumBuffers());
|
||||
|
||||
std::cout << "TransferBufferManager - Basic: Pool usage: " << pool.getNumUsedBlocks() << std::endl;
|
||||
|
||||
ASSERT_TRUE((tbb = mgr->create(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])));
|
||||
|
||||
@ -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<uavcan::MemPoolBlockSize * NUM_POOL_BLOCKS, uavcan::MemPoolBlockSize> 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<uavcan::MemPoolBlockSize * NUM_POOL_BLOCKS, uavcan::MemPoolBlockSize> 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<uavcan::MemPoolBlockSize * NUM_POOL_BLOCKS, uavcan::MemPoolBlockSize> 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<uavcan::MemPoolBlockSize * NUM_POOL_BLOCKS, uavcan::MemPoolBlockSize> 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<uavcan::MemPoolBlockSize * NUM_POOL_BLOCKS, uavcan::MemPoolBlockSize> poolmgr;
|
||||
uavcan::TransferPerfCounter perf;
|
||||
TestListener<0> subscriber(perf, type, poolmgr);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user