mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[unit-test] remove extra \n at end of error message (#4367)
This commit removes the extra `\n` at the end of error message strings used in `VerifyOrQuit()` or `SuccessOrQuit()` macros in different unit test modules. This help make the style (usage of macros) consistent across all unit tests.
This commit is contained in:
committed by
Jonathan Hui
parent
720e9130da
commit
ab27fcd9e6
@@ -54,7 +54,7 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co
|
||||
|
||||
for (uint8_t index = 0; index < aAddressListLength; index++)
|
||||
{
|
||||
VerifyOrQuit(aChild.HasIp6Address(*sInstance, aAddressList[index]), "HasIp6Address() failed\n");
|
||||
VerifyOrQuit(aChild.HasIp6Address(*sInstance, aAddressList[index]), "HasIp6Address() failed");
|
||||
}
|
||||
|
||||
memset(addressObserved, 0, sizeof(addressObserved));
|
||||
@@ -81,18 +81,18 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co
|
||||
}
|
||||
}
|
||||
|
||||
VerifyOrQuit(addressIsInList, "Child::GetNextIp6Address() returned an address not in the expected list\n");
|
||||
VerifyOrQuit(addressIsInList, "Child::GetNextIp6Address() returned an address not in the expected list");
|
||||
}
|
||||
|
||||
for (uint8_t index = 0; index < aAddressListLength; index++)
|
||||
{
|
||||
VerifyOrQuit(addressObserved[index], "Child::GetNextIp6Address() missed an entry from the expected list\n");
|
||||
VerifyOrQuit(addressObserved[index], "Child::GetNextIp6Address() missed an entry from the expected list");
|
||||
|
||||
if (sInstance->Get<Mle::MleRouter>().IsMeshLocalAddress(aAddressList[index]))
|
||||
{
|
||||
SuccessOrQuit(aChild.GetMeshLocalIp6Address(*sInstance, address),
|
||||
"Child::GetMeshLocalIp6Address() failed\n");
|
||||
VerifyOrQuit(address == aAddressList[index], "GetMeshLocalIp6Address() did not return expected address\n");
|
||||
VerifyOrQuit(address == aAddressList[index], "GetMeshLocalIp6Address() did not return expected address");
|
||||
hasMeshLocal = true;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co
|
||||
if (!hasMeshLocal)
|
||||
{
|
||||
VerifyOrQuit(aChild.GetMeshLocalIp6Address(*sInstance, address) == OT_ERROR_NOT_FOUND,
|
||||
"Child::GetMeshLocalIp6Address() returned an address not in the exptect list\n");
|
||||
"Child::GetMeshLocalIp6Address() returned an address not in the expected list");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,11 +51,11 @@ void TestAllocateSingle(void)
|
||||
|
||||
{
|
||||
void *p = heap.CAlloc(1, 0);
|
||||
VerifyOrQuit(p == NULL && totalSize == heap.GetFreeSize(), "TestAllocateSingle allocate 1 x 0 byte failed!\n");
|
||||
VerifyOrQuit(p == NULL && totalSize == heap.GetFreeSize(), "TestAllocateSingle allocate 1 x 0 byte failed!");
|
||||
heap.Free(p);
|
||||
|
||||
p = heap.CAlloc(0, 1);
|
||||
VerifyOrQuit(p == NULL && totalSize == heap.GetFreeSize(), "TestAllocateSingle allocate 0 x 1 byte failed!\n");
|
||||
VerifyOrQuit(p == NULL && totalSize == heap.GetFreeSize(), "TestAllocateSingle allocate 0 x 1 byte failed!");
|
||||
heap.Free(p);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ void TestAllocateSingle(void)
|
||||
{
|
||||
Log("%s allocating %zu bytes...", __func__, size);
|
||||
void *p = heap.CAlloc(1, size);
|
||||
VerifyOrQuit(p != NULL && !heap.IsClean() && heap.GetFreeSize() + size <= totalSize, "allocating failed!\n");
|
||||
VerifyOrQuit(p != NULL && !heap.IsClean() && heap.GetFreeSize() + size <= totalSize, "allocating failed!");
|
||||
memset(p, 0xff, size);
|
||||
heap.Free(p);
|
||||
VerifyOrQuit(heap.IsClean() && heap.GetFreeSize() == totalSize, "freeing failed!\n");
|
||||
@@ -106,7 +106,7 @@ void TestAllocateRandomly(size_t aSizeLimit, unsigned int aSeed)
|
||||
break;
|
||||
}
|
||||
|
||||
VerifyOrQuit(last->mNext->mNext == NULL, "TestAllocateRandomly memory not initialized to zero!\n");
|
||||
VerifyOrQuit(last->mNext->mNext == NULL, "TestAllocateRandomly memory not initialized to zero!");
|
||||
last = last->mNext;
|
||||
last->mSize = size;
|
||||
++nnodes;
|
||||
@@ -150,7 +150,7 @@ void TestAllocateRandomly(size_t aSizeLimit, unsigned int aSeed)
|
||||
}
|
||||
|
||||
VerifyOrQuit(heap.IsClean() && heap.GetFreeSize() == totalSize,
|
||||
"TestAllocateRandomly heap not clean after freeing all!\n");
|
||||
"TestAllocateRandomly heap not clean after freeing all!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,7 +73,7 @@ void TestHmacSha256(void)
|
||||
hmac.Update(reinterpret_cast<const uint8_t *>(tests[i].data), static_cast<uint16_t>(strlen(tests[i].data)));
|
||||
hmac.Finish(hash);
|
||||
|
||||
VerifyOrQuit(memcmp(hash, tests[i].hash, sizeof(tests[i].hash)) == 0, "HMAC-SHA-256 failed\n");
|
||||
VerifyOrQuit(memcmp(hash, tests[i].hash, sizeof(tests[i].hash)) == 0, "HMAC-SHA-256 failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ static void checkAddressFromString(Ip6AddressStringTestVector *aTestVector)
|
||||
|
||||
error = address.FromString(aTestVector->mString);
|
||||
|
||||
VerifyOrQuit(error == aTestVector->mError, "Ip6::Address::FromString returned unexpected error code\n");
|
||||
VerifyOrQuit(error == aTestVector->mError, "Ip6::Address::FromString returned unexpected error code");
|
||||
|
||||
if (error == OT_ERROR_NONE)
|
||||
{
|
||||
VerifyOrQuit(0 == memcmp(address.mFields.m8, aTestVector->mAddr, OT_IP6_ADDRESS_SIZE),
|
||||
"Ip6::Address::FromString parsing failed\n");
|
||||
"Ip6::Address::FromString parsing failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ void TestIphcVector::GetUncompressedStream(Message &aMessage)
|
||||
"6lo: Message::Append failed");
|
||||
}
|
||||
|
||||
SuccessOrQuit(aMessage.Append(mPayload.mData, mPayload.mLength), "6lo: Message::Append failed5");
|
||||
SuccessOrQuit(aMessage.Append(mPayload.mData, mPayload.mLength), "6lo: Message::Append failed");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,87 +70,87 @@ void TestMacAddress(void)
|
||||
// Mac::ExtAddress
|
||||
|
||||
extAddr.GenerateRandom();
|
||||
VerifyOrQuit(extAddr.IsLocal(), "Random Extended Address should have its Local bit set\n");
|
||||
VerifyOrQuit(!extAddr.IsGroup(), "Random Extended Address should not have its Group bit set\n");
|
||||
VerifyOrQuit(extAddr.IsLocal(), "Random Extended Address should have its Local bit set");
|
||||
VerifyOrQuit(!extAddr.IsGroup(), "Random Extended Address should not have its Group bit set");
|
||||
|
||||
extAddr.CopyTo(buffer);
|
||||
VerifyOrQuit(memcmp(extAddr.m8, buffer, OT_EXT_ADDRESS_SIZE) == 0, "ExtAddress::CopyTo() failed\n");
|
||||
VerifyOrQuit(memcmp(extAddr.m8, buffer, OT_EXT_ADDRESS_SIZE) == 0, "ExtAddress::CopyTo() failed");
|
||||
|
||||
extAddr.CopyTo(buffer, Mac::ExtAddress::kReverseByteOrder);
|
||||
VerifyOrQuit(CompareReversed(extAddr.m8, buffer, OT_EXT_ADDRESS_SIZE), "ExtAddress::CopyTo() failed\n");
|
||||
VerifyOrQuit(CompareReversed(extAddr.m8, buffer, OT_EXT_ADDRESS_SIZE), "ExtAddress::CopyTo() failed");
|
||||
|
||||
extAddr.Set(kExtAddr);
|
||||
VerifyOrQuit(memcmp(extAddr.m8, kExtAddr, OT_EXT_ADDRESS_SIZE) == 0, "ExtAddress::Set() failed\n");
|
||||
VerifyOrQuit(memcmp(extAddr.m8, kExtAddr, OT_EXT_ADDRESS_SIZE) == 0, "ExtAddress::Set() failed");
|
||||
|
||||
extAddr.Set(kExtAddr, Mac::ExtAddress::kReverseByteOrder);
|
||||
VerifyOrQuit(CompareReversed(extAddr.m8, kExtAddr, OT_EXT_ADDRESS_SIZE), "ExtAddress::Set() failed\n");
|
||||
VerifyOrQuit(CompareReversed(extAddr.m8, kExtAddr, OT_EXT_ADDRESS_SIZE), "ExtAddress::Set() failed");
|
||||
|
||||
extAddr.SetLocal(true);
|
||||
VerifyOrQuit(extAddr.IsLocal(), "ExtAddress::SetLocal() failed\n");
|
||||
VerifyOrQuit(extAddr.IsLocal(), "ExtAddress::SetLocal() failed");
|
||||
extAddr.SetLocal(false);
|
||||
VerifyOrQuit(!extAddr.IsLocal(), "ExtAddress::SetLocal() failed\n");
|
||||
VerifyOrQuit(!extAddr.IsLocal(), "ExtAddress::SetLocal() failed");
|
||||
extAddr.ToggleLocal();
|
||||
VerifyOrQuit(extAddr.IsLocal(), "ExtAddress::SetLocal() failed\n");
|
||||
VerifyOrQuit(extAddr.IsLocal(), "ExtAddress::SetLocal() failed");
|
||||
extAddr.ToggleLocal();
|
||||
VerifyOrQuit(!extAddr.IsLocal(), "ExtAddress::SetLocal() failed\n");
|
||||
VerifyOrQuit(!extAddr.IsLocal(), "ExtAddress::SetLocal() failed");
|
||||
|
||||
extAddr.SetGroup(true);
|
||||
VerifyOrQuit(extAddr.IsGroup(), "ExtAddress::SetGroup() failed\n");
|
||||
VerifyOrQuit(extAddr.IsGroup(), "ExtAddress::SetGroup() failed");
|
||||
extAddr.SetGroup(false);
|
||||
VerifyOrQuit(!extAddr.IsGroup(), "ExtAddress::SetGroup() failed\n");
|
||||
VerifyOrQuit(!extAddr.IsGroup(), "ExtAddress::SetGroup() failed");
|
||||
extAddr.ToggleGroup();
|
||||
VerifyOrQuit(extAddr.IsGroup(), "ExtAddress::SetGroup() failed\n");
|
||||
VerifyOrQuit(extAddr.IsGroup(), "ExtAddress::SetGroup() failed");
|
||||
extAddr.ToggleGroup();
|
||||
VerifyOrQuit(!extAddr.IsGroup(), "ExtAddress::SetGroup() failed\n");
|
||||
VerifyOrQuit(!extAddr.IsGroup(), "ExtAddress::SetGroup() failed");
|
||||
|
||||
// Mac::Address
|
||||
|
||||
VerifyOrQuit(addr.IsNone(), "Address constructor failed\n");
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeNone, "Address::GetType() failed\n");
|
||||
VerifyOrQuit(addr.IsNone(), "Address constructor failed");
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeNone, "Address::GetType() failed");
|
||||
|
||||
addr.SetShort(kShortAddr);
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeShort, "Address::GetType() failed\n");
|
||||
VerifyOrQuit(addr.IsShort(), "Address::SetShort() failed\n");
|
||||
VerifyOrQuit(!addr.IsExtended(), "Address::SetShort() failed\n");
|
||||
VerifyOrQuit(addr.GetShort() == kShortAddr, "Address::GetShort() failed\n");
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeShort, "Address::GetType() failed");
|
||||
VerifyOrQuit(addr.IsShort(), "Address::SetShort() failed");
|
||||
VerifyOrQuit(!addr.IsExtended(), "Address::SetShort() failed");
|
||||
VerifyOrQuit(addr.GetShort() == kShortAddr, "Address::GetShort() failed");
|
||||
|
||||
addr.SetExtended(extAddr);
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeExtended, "Address::GetType() failed\n");
|
||||
VerifyOrQuit(!addr.IsShort(), "Address::SetExtended() failed\n");
|
||||
VerifyOrQuit(addr.IsExtended(), "Address::SetExtended() failed\n");
|
||||
VerifyOrQuit(addr.GetExtended() == extAddr, "Address::GetExtended() failed\n");
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeExtended, "Address::GetType() failed");
|
||||
VerifyOrQuit(!addr.IsShort(), "Address::SetExtended() failed");
|
||||
VerifyOrQuit(addr.IsExtended(), "Address::SetExtended() failed");
|
||||
VerifyOrQuit(addr.GetExtended() == extAddr, "Address::GetExtended() failed");
|
||||
|
||||
addr.SetExtended(extAddr.m8, Mac::ExtAddress::kReverseByteOrder);
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeExtended, "Address::GetType() failed\n");
|
||||
VerifyOrQuit(!addr.IsShort(), "Address::SetExtended() failed\n");
|
||||
VerifyOrQuit(addr.IsExtended(), "Address::SetExtended() failed\n");
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeExtended, "Address::GetType() failed");
|
||||
VerifyOrQuit(!addr.IsShort(), "Address::SetExtended() failed");
|
||||
VerifyOrQuit(addr.IsExtended(), "Address::SetExtended() failed");
|
||||
VerifyOrQuit(CompareReversed(addr.GetExtended().m8, extAddr.m8, OT_EXT_ADDRESS_SIZE),
|
||||
"Address::SetExtended() reverse byte order failed");
|
||||
|
||||
addr.SetNone();
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeNone, "Address::GetType() failed\n");
|
||||
VerifyOrQuit(addr.IsNone(), "Address:SetNone() failed\n");
|
||||
VerifyOrQuit(!addr.IsShort(), "Address::SetNone() failed\n");
|
||||
VerifyOrQuit(!addr.IsExtended(), "Address::SetNone() failed\n");
|
||||
VerifyOrQuit(addr.GetType() == Mac::Address::kTypeNone, "Address::GetType() failed");
|
||||
VerifyOrQuit(addr.IsNone(), "Address:SetNone() failed");
|
||||
VerifyOrQuit(!addr.IsShort(), "Address::SetNone() failed");
|
||||
VerifyOrQuit(!addr.IsExtended(), "Address::SetNone() failed");
|
||||
|
||||
VerifyOrQuit(!addr.IsBroadcast(), "Address:IsBroadcast() failed\n");
|
||||
VerifyOrQuit(!addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed\n");
|
||||
VerifyOrQuit(!addr.IsBroadcast(), "Address:IsBroadcast() failed");
|
||||
VerifyOrQuit(!addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed");
|
||||
|
||||
addr.SetExtended(extAddr);
|
||||
VerifyOrQuit(!addr.IsBroadcast(), "Address:IsBroadcast() failed\n");
|
||||
VerifyOrQuit(!addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed\n");
|
||||
VerifyOrQuit(!addr.IsBroadcast(), "Address:IsBroadcast() failed");
|
||||
VerifyOrQuit(!addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed");
|
||||
|
||||
addr.SetShort(kShortAddr);
|
||||
VerifyOrQuit(!addr.IsBroadcast(), "Address:IsBroadcast() failed\n");
|
||||
VerifyOrQuit(!addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed\n");
|
||||
VerifyOrQuit(!addr.IsBroadcast(), "Address:IsBroadcast() failed");
|
||||
VerifyOrQuit(!addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed");
|
||||
|
||||
addr.SetShort(Mac::kShortAddrBroadcast);
|
||||
VerifyOrQuit(addr.IsBroadcast(), "Address:IsBroadcast() failed\n");
|
||||
VerifyOrQuit(!addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed\n");
|
||||
VerifyOrQuit(addr.IsBroadcast(), "Address:IsBroadcast() failed");
|
||||
VerifyOrQuit(!addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed");
|
||||
|
||||
addr.SetShort(Mac::kShortAddrInvalid);
|
||||
VerifyOrQuit(!addr.IsBroadcast(), "Address:IsBroadcast() failed\n");
|
||||
VerifyOrQuit(addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed\n");
|
||||
VerifyOrQuit(!addr.IsBroadcast(), "Address:IsBroadcast() failed");
|
||||
VerifyOrQuit(addr.IsShortAddrInvalid(), "Address:IsShortAddrInvalid() failed");
|
||||
|
||||
testFreeInstance(instance);
|
||||
}
|
||||
@@ -159,11 +159,11 @@ void CompareNetworkName(const Mac::NetworkName &aNetworkName, const char *aNameS
|
||||
{
|
||||
uint8_t len = static_cast<uint8_t>(strlen(aNameString));
|
||||
|
||||
VerifyOrQuit(strcmp(aNetworkName.GetAsCString(), aNameString) == 0, "NetworkName does not match expected value\n");
|
||||
VerifyOrQuit(strcmp(aNetworkName.GetAsCString(), aNameString) == 0, "NetworkName does not match expected value");
|
||||
|
||||
VerifyOrQuit(aNetworkName.GetAsData().GetLength() == len, "NetworkName:GetAsData().GetLength() is incorrect\n");
|
||||
VerifyOrQuit(aNetworkName.GetAsData().GetLength() == len, "NetworkName:GetAsData().GetLength() is incorrect");
|
||||
VerifyOrQuit(memcmp(aNetworkName.GetAsData().GetBuffer(), aNameString, len) == 0,
|
||||
"NetworkName:GetAsData().GetBuffer() is incorrect\n");
|
||||
"NetworkName:GetAsData().GetBuffer() is incorrect");
|
||||
}
|
||||
|
||||
void TestMacNetworkName(void)
|
||||
@@ -180,7 +180,7 @@ void TestMacNetworkName(void)
|
||||
|
||||
CompareNetworkName(networkName, kEmptyName);
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kName1, sizeof(kName1))), "NetworkName::Set() failed\n");
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kName1, sizeof(kName1))), "NetworkName::Set() failed");
|
||||
CompareNetworkName(networkName, kName1);
|
||||
|
||||
VerifyOrQuit(networkName.Set(Mac::NetworkName::Data(kName1, sizeof(kName1))) == OT_ERROR_ALREADY,
|
||||
@@ -190,45 +190,45 @@ void TestMacNetworkName(void)
|
||||
VerifyOrQuit(networkName.Set(Mac::NetworkName::Data(kName1, sizeof(kName1) - 1)) == OT_ERROR_ALREADY,
|
||||
"NetworkName::Set() accepted same name without returning OT_ERROR_ALREADY");
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kName2, sizeof(kName2))), "NetworkName::Set() failed\n");
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kName2, sizeof(kName2))), "NetworkName::Set() failed");
|
||||
CompareNetworkName(networkName, kName2);
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kEmptyName, 0)), "NetworkName::Set() failed\n");
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kEmptyName, 0)), "NetworkName::Set() failed");
|
||||
CompareNetworkName(networkName, kEmptyName);
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kLongName, sizeof(kLongName))), "NetworkName::Set() failed\n");
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kLongName, sizeof(kLongName))), "NetworkName::Set() failed");
|
||||
CompareNetworkName(networkName, kLongName);
|
||||
|
||||
VerifyOrQuit(networkName.Set(Mac::NetworkName::Data(kLongName, sizeof(kLongName) - 1)) == OT_ERROR_ALREADY,
|
||||
"NetworkName::Set() accepted same name without returning OT_ERROR_ALREADY");
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(NULL, 0)), "NetworkName::Set() failed\n");
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(NULL, 0)), "NetworkName::Set() failed");
|
||||
CompareNetworkName(networkName, kEmptyName);
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kName1, sizeof(kName1))), "NetworkName::Set() failed\n");
|
||||
SuccessOrQuit(networkName.Set(Mac::NetworkName::Data(kName1, sizeof(kName1))), "NetworkName::Set() failed");
|
||||
|
||||
VerifyOrQuit(networkName.Set(Mac::NetworkName::Data(kTooLongName, sizeof(kTooLongName))) == OT_ERROR_INVALID_ARGS,
|
||||
"NetworkName::Set() accepted an invalid (too long) name\n");
|
||||
"NetworkName::Set() accepted an invalid (too long) name");
|
||||
|
||||
CompareNetworkName(networkName, kName1);
|
||||
|
||||
memset(buffer, 'a', sizeof(buffer));
|
||||
len = networkName.GetAsData().CopyTo(buffer, 1);
|
||||
VerifyOrQuit(len == 1, "NetworkName::Data::CopyTo() failed\n");
|
||||
VerifyOrQuit(buffer[0] == kName1[0], "NetworkName::Data::CopyTo() failed\n");
|
||||
VerifyOrQuit(buffer[1] == 'a', "NetworkName::Data::CopyTo() failed\n");
|
||||
VerifyOrQuit(len == 1, "NetworkName::Data::CopyTo() failed");
|
||||
VerifyOrQuit(buffer[0] == kName1[0], "NetworkName::Data::CopyTo() failed");
|
||||
VerifyOrQuit(buffer[1] == 'a', "NetworkName::Data::CopyTo() failed");
|
||||
|
||||
memset(buffer, 'a', sizeof(buffer));
|
||||
len = networkName.GetAsData().CopyTo(buffer, sizeof(kName1) - 1);
|
||||
VerifyOrQuit(len == sizeof(kName1) - 1, "NetworkName::Data::CopyTo() failed\n");
|
||||
VerifyOrQuit(memcmp(buffer, kName1, sizeof(kName1) - 1) == 0, "NetworkName::Data::CopyTo() failed\n");
|
||||
VerifyOrQuit(buffer[sizeof(kName1)] == 'a', "NetworkName::Data::CopyTo() failed\n");
|
||||
VerifyOrQuit(len == sizeof(kName1) - 1, "NetworkName::Data::CopyTo() failed");
|
||||
VerifyOrQuit(memcmp(buffer, kName1, sizeof(kName1) - 1) == 0, "NetworkName::Data::CopyTo() failed");
|
||||
VerifyOrQuit(buffer[sizeof(kName1)] == 'a', "NetworkName::Data::CopyTo() failed");
|
||||
|
||||
memset(buffer, 'a', sizeof(buffer));
|
||||
len = networkName.GetAsData().CopyTo(buffer, sizeof(buffer));
|
||||
VerifyOrQuit(len == sizeof(kName1) - 1, "NetworkName::Data::CopyTo() failed\n");
|
||||
VerifyOrQuit(memcmp(buffer, kName1, sizeof(kName1) - 1) == 0, "NetworkName::Data::CopyTo() failed\n");
|
||||
VerifyOrQuit(buffer[sizeof(kName1)] == 0, "NetworkName::Data::CopyTo() failed\n");
|
||||
VerifyOrQuit(len == sizeof(kName1) - 1, "NetworkName::Data::CopyTo() failed");
|
||||
VerifyOrQuit(memcmp(buffer, kName1, sizeof(kName1) - 1) == 0, "NetworkName::Data::CopyTo() failed");
|
||||
VerifyOrQuit(buffer[sizeof(kName1)] == 0, "NetworkName::Data::CopyTo() failed");
|
||||
}
|
||||
|
||||
void TestMacHeader(void)
|
||||
@@ -279,7 +279,7 @@ void TestMacHeader(void)
|
||||
|
||||
frame.InitMacHeader(tests[i].fcf, tests[i].secCtl);
|
||||
printf("%d\n", frame.GetHeaderLength());
|
||||
VerifyOrQuit(frame.GetHeaderLength() == tests[i].headerLength, "MacHeader test failed\n");
|
||||
VerifyOrQuit(frame.GetHeaderLength() == tests[i].headerLength, "MacHeader test failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,11 +295,11 @@ void VerifyChannelMaskContent(const Mac::ChannelMask &aMask, uint8_t *aChannels,
|
||||
if (channel == aChannels[index])
|
||||
{
|
||||
index++;
|
||||
VerifyOrQuit(aMask.ContainsChannel(channel), "ChannelMask.ContainsChannel() failed\n");
|
||||
VerifyOrQuit(aMask.ContainsChannel(channel), "ChannelMask.ContainsChannel() failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
VerifyOrQuit(!aMask.ContainsChannel(channel), "ChannelMask.ContainsChannel() failed\n");
|
||||
VerifyOrQuit(!aMask.ContainsChannel(channel), "ChannelMask.ContainsChannel() failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -309,21 +309,21 @@ void VerifyChannelMaskContent(const Mac::ChannelMask &aMask, uint8_t *aChannels,
|
||||
|
||||
while (aMask.GetNextChannel(channel) == OT_ERROR_NONE)
|
||||
{
|
||||
VerifyOrQuit(channel == aChannels[index++], "ChannelMask.GetNextChannel() failed\n");
|
||||
VerifyOrQuit(channel == aChannels[index++], "ChannelMask.GetNextChannel() failed");
|
||||
}
|
||||
|
||||
VerifyOrQuit(index == aLength, "ChannelMask.GetNextChannel() failed\n");
|
||||
VerifyOrQuit(index == aLength, "ChannelMask.GetNextChannel() failed");
|
||||
|
||||
if (aLength == 1)
|
||||
{
|
||||
VerifyOrQuit(aMask.IsSingleChannel(), "ChannelMask.IsSingleChannel() failed\n");
|
||||
VerifyOrQuit(aMask.IsSingleChannel(), "ChannelMask.IsSingleChannel() failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
VerifyOrQuit(!aMask.IsSingleChannel(), "ChannelMask.IsSingleChannel() failed\n");
|
||||
VerifyOrQuit(!aMask.IsSingleChannel(), "ChannelMask.IsSingleChannel() failed");
|
||||
}
|
||||
|
||||
VerifyOrQuit(aLength == aMask.GetNumberOfChannels(), "ChannelMask.GetNumberOfChannels() failed\n");
|
||||
VerifyOrQuit(aLength == aMask.GetNumberOfChannels(), "ChannelMask.GetNumberOfChannels() failed");
|
||||
}
|
||||
|
||||
void TestMacChannelMask(void)
|
||||
@@ -339,16 +339,16 @@ void TestMacChannelMask(void)
|
||||
|
||||
printf("Testing Mac::ChannelMask\n");
|
||||
|
||||
VerifyOrQuit(mask1.IsEmpty(), "ChannelMask.IsEmpty failed\n");
|
||||
VerifyOrQuit(mask1.IsEmpty(), "ChannelMask.IsEmpty failed");
|
||||
printf("empty = %s\n", mask1.ToString().AsCString());
|
||||
|
||||
VerifyOrQuit(!mask2.IsEmpty(), "ChannelMask.IsEmpty failed\n");
|
||||
VerifyOrQuit(mask2.GetMask() == Radio::kSupportedChannels, "ChannelMask.GetMask() failed\n");
|
||||
VerifyOrQuit(!mask2.IsEmpty(), "ChannelMask.IsEmpty failed");
|
||||
VerifyOrQuit(mask2.GetMask() == Radio::kSupportedChannels, "ChannelMask.GetMask() failed");
|
||||
printf("all_channels = %s\n", mask2.ToString().AsCString());
|
||||
|
||||
mask1.SetMask(Radio::kSupportedChannels);
|
||||
VerifyOrQuit(!mask1.IsEmpty(), "ChannelMask.IsEmpty failed\n");
|
||||
VerifyOrQuit(mask1.GetMask() == Radio::kSupportedChannels, "ChannelMask.GetMask() failed\n");
|
||||
VerifyOrQuit(!mask1.IsEmpty(), "ChannelMask.IsEmpty failed");
|
||||
VerifyOrQuit(mask1.GetMask() == Radio::kSupportedChannels, "ChannelMask.GetMask() failed");
|
||||
|
||||
VerifyChannelMaskContent(mask1, all_channels, sizeof(all_channels));
|
||||
|
||||
@@ -360,7 +360,7 @@ void TestMacChannelMask(void)
|
||||
}
|
||||
|
||||
mask1.Clear();
|
||||
VerifyOrQuit(mask1.IsEmpty(), "ChannelMask.IsEmpty failed\n");
|
||||
VerifyOrQuit(mask1.IsEmpty(), "ChannelMask.IsEmpty failed");
|
||||
VerifyChannelMaskContent(mask1, NULL, 0);
|
||||
|
||||
for (uint16_t index = 0; index < sizeof(channels1); index++)
|
||||
@@ -370,7 +370,7 @@ void TestMacChannelMask(void)
|
||||
|
||||
printf("channels1 = %s\n", mask1.ToString().AsCString());
|
||||
|
||||
VerifyOrQuit(!mask1.IsEmpty(), "ChannelMask.IsEmpty failed\n");
|
||||
VerifyOrQuit(!mask1.IsEmpty(), "ChannelMask.IsEmpty failed");
|
||||
VerifyChannelMaskContent(mask1, channels1, sizeof(channels1));
|
||||
|
||||
mask2.Clear();
|
||||
@@ -382,7 +382,7 @@ void TestMacChannelMask(void)
|
||||
|
||||
printf("channels2 = %s\n", mask2.ToString().AsCString());
|
||||
|
||||
VerifyOrQuit(!mask2.IsEmpty(), "ChannelMask.IsEmpty failed\n");
|
||||
VerifyOrQuit(!mask2.IsEmpty(), "ChannelMask.IsEmpty failed");
|
||||
VerifyChannelMaskContent(mask2, channels2, sizeof(channels2));
|
||||
|
||||
mask1.Intersect(mask2);
|
||||
@@ -396,14 +396,14 @@ void TestMacChannelMask(void)
|
||||
|
||||
mask1.Clear();
|
||||
mask2.Clear();
|
||||
VerifyOrQuit(mask1 == mask2, "ChannelMask.operator== failed\n");
|
||||
VerifyOrQuit(mask1 == mask2, "ChannelMask.operator== failed");
|
||||
|
||||
mask1.SetMask(Radio::kSupportedChannels);
|
||||
mask2.SetMask(Radio::kSupportedChannels);
|
||||
VerifyOrQuit(mask1 == mask2, "ChannelMask.operator== failed\n");
|
||||
VerifyOrQuit(mask1 == mask2, "ChannelMask.operator== failed");
|
||||
|
||||
mask1.Clear();
|
||||
VerifyOrQuit(mask1 != mask2, "ChannelMask.operator== failed\n");
|
||||
VerifyOrQuit(mask1 != mask2, "ChannelMask.operator== failed");
|
||||
}
|
||||
|
||||
} // namespace ot
|
||||
|
||||
@@ -52,12 +52,12 @@ void TestMessage(void)
|
||||
writeBuffer[i] = static_cast<uint8_t>(random());
|
||||
}
|
||||
|
||||
VerifyOrQuit((message = messagePool->New(ot::Message::kTypeIp6, 0)) != NULL, "Message::New failed\n");
|
||||
SuccessOrQuit(message->SetLength(sizeof(writeBuffer)), "Message::SetLength failed\n");
|
||||
VerifyOrQuit(message->Write(0, sizeof(writeBuffer), writeBuffer) == sizeof(writeBuffer), "Message::Write failed\n");
|
||||
VerifyOrQuit(message->Read(0, sizeof(readBuffer), readBuffer) == sizeof(readBuffer), "Message::Read failed\n");
|
||||
VerifyOrQuit(memcmp(writeBuffer, readBuffer, sizeof(writeBuffer)) == 0, "Message compare failed\n");
|
||||
VerifyOrQuit(message->GetLength() == 1024, "Message::GetLength failed\n");
|
||||
VerifyOrQuit((message = messagePool->New(ot::Message::kTypeIp6, 0)) != NULL, "Message::New failed");
|
||||
SuccessOrQuit(message->SetLength(sizeof(writeBuffer)), "Message::SetLength failed");
|
||||
VerifyOrQuit(message->Write(0, sizeof(writeBuffer), writeBuffer) == sizeof(writeBuffer), "Message::Write failed");
|
||||
VerifyOrQuit(message->Read(0, sizeof(readBuffer), readBuffer) == sizeof(readBuffer), "Message::Read failed");
|
||||
VerifyOrQuit(memcmp(writeBuffer, readBuffer, sizeof(writeBuffer)) == 0, "Message compare failed");
|
||||
VerifyOrQuit(message->GetLength() == 1024, "Message::GetLength failed");
|
||||
message->Free();
|
||||
|
||||
testFreeInstance(instance);
|
||||
|
||||
@@ -56,21 +56,21 @@ void VerifyMessageQueueContent(ot::MessageQueue &aMessageQueue, int aExpectedLen
|
||||
if (aExpectedLength == 0)
|
||||
{
|
||||
message = aMessageQueue.GetHead();
|
||||
VerifyOrQuit(message == NULL, "MessageQueue is not empty when expected len is zero.\n");
|
||||
VerifyOrQuit(message == NULL, "MessageQueue is not empty when expected len is zero.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (message = aMessageQueue.GetHead(); message != NULL; message = message->GetNext())
|
||||
{
|
||||
VerifyOrQuit(aExpectedLength != 0, "MessageQueue contains more entries than expected\n");
|
||||
VerifyOrQuit(aExpectedLength != 0, "MessageQueue contains more entries than expected");
|
||||
|
||||
msgArg = va_arg(args, ot::Message *);
|
||||
VerifyOrQuit(msgArg == message, "MessageQueue content does not match what is expected.\n");
|
||||
VerifyOrQuit(msgArg == message, "MessageQueue content does not match what is expected.");
|
||||
|
||||
aExpectedLength--;
|
||||
}
|
||||
|
||||
VerifyOrQuit(aExpectedLength == 0, "MessageQueue contains less entries than expected\n");
|
||||
VerifyOrQuit(aExpectedLength == 0, "MessageQueue contains less entries than expected");
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
@@ -91,102 +91,102 @@ void TestMessageQueue(void)
|
||||
for (int i = 0; i < kNumTestMessages; i++)
|
||||
{
|
||||
msg[i] = sMessagePool->New(ot::Message::kTypeIp6, 0);
|
||||
VerifyOrQuit(msg[i] != NULL, "Message::New failed\n");
|
||||
VerifyOrQuit(msg[i] != NULL, "Message::New failed");
|
||||
}
|
||||
|
||||
VerifyMessageQueueContent(messageQueue, 0);
|
||||
|
||||
// Enqueue 1 message and remove it
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[0]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[0]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 1, msg[0]);
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[0]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[0]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 0);
|
||||
|
||||
// Enqueue 1 message at head and remove it
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[0], ot::MessageQueue::kQueuePositionHead),
|
||||
"MessageQueue::Enqueue() failed.\n");
|
||||
"MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 1, msg[0]);
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[0]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[0]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 0);
|
||||
|
||||
// Enqueue 5 messages
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[0]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[0]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 1, msg[0]);
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[1]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[1]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 2, msg[0], msg[1]);
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[2]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[2]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 3, msg[0], msg[1], msg[2]);
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[3]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[3]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 4, msg[0], msg[1], msg[2], msg[3]);
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[4]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[4]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 5, msg[0], msg[1], msg[2], msg[3], msg[4]);
|
||||
|
||||
// Check the GetInfo()
|
||||
messageQueue.GetInfo(msgCount, bufferCount);
|
||||
VerifyOrQuit(msgCount == 5, "MessageQueue::GetInfo() failed.\n");
|
||||
VerifyOrQuit(msgCount == 5, "MessageQueue::GetInfo() failed.");
|
||||
|
||||
// Remove from head
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[0]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[0]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 4, msg[1], msg[2], msg[3], msg[4]);
|
||||
|
||||
// Remove a message in middle
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[3]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[3]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 3, msg[1], msg[2], msg[4]);
|
||||
|
||||
// Remove from tail
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[4]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[4]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 2, msg[1], msg[2]);
|
||||
|
||||
// Add after remove
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[0]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[0]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 3, msg[1], msg[2], msg[0]);
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[3]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[3]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 4, msg[1], msg[2], msg[0], msg[3]);
|
||||
|
||||
// Remove from middle
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[2]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[2]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 3, msg[1], msg[0], msg[3]);
|
||||
|
||||
// Add to head
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[2], ot::MessageQueue::kQueuePositionHead),
|
||||
"MessageQueue::Enqueue() failed.\n");
|
||||
"MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 4, msg[2], msg[1], msg[0], msg[3]);
|
||||
|
||||
// Remove from head
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[2]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[2]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 3, msg[1], msg[0], msg[3]);
|
||||
|
||||
// Remove from head
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[1]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[1]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 2, msg[0], msg[3]);
|
||||
|
||||
// Add to head
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[1], ot::MessageQueue::kQueuePositionHead),
|
||||
"MessageQueue::Enqueue() failed.\n");
|
||||
"MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 3, msg[1], msg[0], msg[3]);
|
||||
|
||||
// Add to tail
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[2], ot::MessageQueue::kQueuePositionTail),
|
||||
"MessageQueue::Enqueue() failed.\n");
|
||||
"MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 4, msg[1], msg[0], msg[3], msg[2]);
|
||||
|
||||
// Remove all messages.
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[3]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[3]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 3, msg[1], msg[0], msg[2]);
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[1]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[1]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 2, msg[0], msg[2]);
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[2]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[2]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 1, msg[0]);
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[0]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msg[0]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 0);
|
||||
|
||||
// Check the failure cases: Enqueue an already queued message or dequeue a message not in the queue.
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[0]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msg[0]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMessageQueueContent(messageQueue, 1, msg[0]);
|
||||
error = messageQueue.Enqueue(*msg[0]);
|
||||
VerifyOrQuit(error == OT_ERROR_ALREADY, "Enqueuing an already queued message did not fail as expected.\n");
|
||||
VerifyOrQuit(error == OT_ERROR_ALREADY, "Enqueuing an already queued message did not fail as expected.");
|
||||
error = messageQueue.Dequeue(*msg[1]);
|
||||
VerifyOrQuit(error == OT_ERROR_NOT_FOUND, "Dequeuing a message not in the queue did not fail as expected.\n");
|
||||
VerifyOrQuit(error == OT_ERROR_NOT_FOUND, "Dequeuing a message not in the queue did not fail as expected.");
|
||||
|
||||
testFreeInstance(sInstance);
|
||||
}
|
||||
@@ -203,21 +203,21 @@ void VerifyMessageQueueContentUsingOtApi(otMessageQueue *aQueue, int aExpectedLe
|
||||
if (aExpectedLength == 0)
|
||||
{
|
||||
message = otMessageQueueGetHead(aQueue);
|
||||
VerifyOrQuit(message == NULL, "MessageQueue is not empty when expected len is zero.\n");
|
||||
VerifyOrQuit(message == NULL, "MessageQueue is not empty when expected len is zero.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (message = otMessageQueueGetHead(aQueue); message != NULL; message = otMessageQueueGetNext(aQueue, message))
|
||||
{
|
||||
VerifyOrQuit(aExpectedLength != 0, "MessageQueue contains more entries than expected\n");
|
||||
VerifyOrQuit(aExpectedLength != 0, "MessageQueue contains more entries than expected");
|
||||
|
||||
msgArg = va_arg(args, otMessage *);
|
||||
VerifyOrQuit(msgArg == message, "MessageQueue content does not match what is expected.\n");
|
||||
VerifyOrQuit(msgArg == message, "MessageQueue content does not match what is expected.");
|
||||
|
||||
aExpectedLength--;
|
||||
}
|
||||
|
||||
VerifyOrQuit(aExpectedLength == 0, "MessageQueue contains less entries than expected\n");
|
||||
VerifyOrQuit(aExpectedLength == 0, "MessageQueue contains less entries than expected");
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
@@ -237,7 +237,7 @@ void TestMessageQueueOtApis(void)
|
||||
for (int i = 0; i < kNumTestMessages; i++)
|
||||
{
|
||||
msg[i] = otIp6NewMessage(sInstance, NULL);
|
||||
VerifyOrQuit(msg[i] != NULL, "otIp6NewMessage() failed.\n");
|
||||
VerifyOrQuit(msg[i] != NULL, "otIp6NewMessage() failed.");
|
||||
}
|
||||
|
||||
otMessageQueueInit(&queue);
|
||||
@@ -247,48 +247,48 @@ void TestMessageQueueOtApis(void)
|
||||
VerifyMessageQueueContentUsingOtApi(&queue, 0);
|
||||
|
||||
// Add message to the queue and check the content
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue, msg[0]), "Failed to enqueue a message to otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue, msg[0]), "Failed to enqueue a message to otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue, 1, msg[0]);
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue, msg[1]), "Failed to enqueue a message to otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue, msg[1]), "Failed to enqueue a message to otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue, 2, msg[0], msg[1]);
|
||||
SuccessOrQuit(otMessageQueueEnqueueAtHead(&queue, msg[2]), "Failed to enqueue a message to otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueEnqueueAtHead(&queue, msg[2]), "Failed to enqueue a message to otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue, 3, msg[2], msg[0], msg[1]);
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue, msg[3]), "Failed to enqueue a message to otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue, msg[3]), "Failed to enqueue a message to otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue, 4, msg[2], msg[0], msg[1], msg[3]);
|
||||
|
||||
// Remove elements and check the content
|
||||
SuccessOrQuit(otMessageQueueDequeue(&queue, msg[1]), "Failed to dequeue a message from otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueDequeue(&queue, msg[1]), "Failed to dequeue a message from otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue, 3, msg[2], msg[0], msg[3]);
|
||||
SuccessOrQuit(otMessageQueueDequeue(&queue, msg[0]), "Failed to dequeue a message from otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueDequeue(&queue, msg[0]), "Failed to dequeue a message from otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue, 2, msg[2], msg[3]);
|
||||
SuccessOrQuit(otMessageQueueDequeue(&queue, msg[3]), "Failed to dequeue a message from otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueDequeue(&queue, msg[3]), "Failed to dequeue a message from otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue, 1, msg[2]);
|
||||
|
||||
// Check the expected failure cases for the enqueue and dequeue:
|
||||
error = otMessageQueueEnqueue(&queue, msg[2]);
|
||||
VerifyOrQuit(error == OT_ERROR_ALREADY, "Enqueuing an already queued message did not fail as expected.\n");
|
||||
VerifyOrQuit(error == OT_ERROR_ALREADY, "Enqueuing an already queued message did not fail as expected.");
|
||||
error = otMessageQueueDequeue(&queue, msg[0]);
|
||||
VerifyOrQuit(error == OT_ERROR_NOT_FOUND, "Dequeuing a message not in the queue did not fail as expected.\n");
|
||||
VerifyOrQuit(error == OT_ERROR_NOT_FOUND, "Dequeuing a message not in the queue did not fail as expected.");
|
||||
|
||||
// Check the failure cases for otMessageQueueGetNext()
|
||||
message = otMessageQueueGetNext(&queue, NULL);
|
||||
VerifyOrQuit(message == NULL, "otMessageQueueGetNext(queue, NULL) did not return NULL.\n");
|
||||
VerifyOrQuit(message == NULL, "otMessageQueueGetNext(queue, NULL) did not return NULL.");
|
||||
message = otMessageQueueGetNext(&queue, msg[1]);
|
||||
VerifyOrQuit(message == NULL, "otMessageQueueGetNext() did not return NULL for a message not in the queue.\n");
|
||||
VerifyOrQuit(message == NULL, "otMessageQueueGetNext() did not return NULL for a message not in the queue.");
|
||||
|
||||
// Check the failure case when attempting to do otMessageQueueGetNext() but passing in a wrong queue pointer.
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue2, msg[0]), "Failed to enqueue a message to otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue2, msg[0]), "Failed to enqueue a message to otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue2, 1, msg[0]);
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue2, msg[1]), "Failed to enqueue a message to otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueEnqueue(&queue2, msg[1]), "Failed to enqueue a message to otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue2, 2, msg[0], msg[1]);
|
||||
|
||||
message = otMessageQueueGetNext(&queue2, msg[0]);
|
||||
VerifyOrQuit(message == msg[1], "otMessageQueueGetNext() failed\n");
|
||||
VerifyOrQuit(message == msg[1], "otMessageQueueGetNext() failed");
|
||||
message = otMessageQueueGetNext(&queue, msg[0]);
|
||||
VerifyOrQuit(message == NULL, "otMessageQueueGetNext() did not return NULL for message not in the queue.\n");
|
||||
VerifyOrQuit(message == NULL, "otMessageQueueGetNext() did not return NULL for message not in the queue.");
|
||||
|
||||
// Remove all element and make sure queue is empty
|
||||
SuccessOrQuit(otMessageQueueDequeue(&queue, msg[2]), "Failed to dequeue a message from otMessageQueue.\n");
|
||||
SuccessOrQuit(otMessageQueueDequeue(&queue, msg[2]), "Failed to dequeue a message from otMessageQueue.");
|
||||
VerifyMessageQueueContentUsingOtApi(&queue, 0);
|
||||
|
||||
testFreeInstance(sInstance);
|
||||
|
||||
@@ -112,7 +112,7 @@ void TestNetworkDataIterator(void)
|
||||
|
||||
for (uint8_t i = 0; i < OT_ARRAY_LENGTH(routes); i++)
|
||||
{
|
||||
SuccessOrQuit(netData.GetNextExternalRoute(iter, config), "GetNextExternalRoute() failed\n");
|
||||
SuccessOrQuit(netData.GetNextExternalRoute(iter, config), "GetNextExternalRoute() failed");
|
||||
PrintExternalRouteConfig(config);
|
||||
VerifyOrQuit(CompareExternalRouteConfig(config, routes[i]) == true,
|
||||
"external route config does not match expectation");
|
||||
@@ -162,7 +162,7 @@ void TestNetworkDataIterator(void)
|
||||
|
||||
for (uint8_t i = 0; i < OT_ARRAY_LENGTH(routes); i++)
|
||||
{
|
||||
SuccessOrQuit(netData.GetNextExternalRoute(iter, config), "GetNextExternalRoute() failed\n");
|
||||
SuccessOrQuit(netData.GetNextExternalRoute(iter, config), "GetNextExternalRoute() failed");
|
||||
PrintExternalRouteConfig(config);
|
||||
VerifyOrQuit(CompareExternalRouteConfig(config, routes[i]) == true,
|
||||
"external route config does not match expectation");
|
||||
|
||||
@@ -51,30 +51,30 @@ void VerifyPriorityQueueContent(ot::PriorityQueue &aPriorityQueue, int aExpected
|
||||
|
||||
// Check the `GetInfo`
|
||||
aPriorityQueue.GetInfo(msgCount, bufCount);
|
||||
VerifyOrQuit(msgCount == aExpectedLength, "GetInfo() result does not match expected len.\n");
|
||||
VerifyOrQuit(msgCount == aExpectedLength, "GetInfo() result does not match expected len.");
|
||||
|
||||
va_start(args, aExpectedLength);
|
||||
|
||||
if (aExpectedLength == 0)
|
||||
{
|
||||
message = aPriorityQueue.GetHead();
|
||||
VerifyOrQuit(message == NULL, "PriorityQueue is not empty when expected len is zero.\n");
|
||||
VerifyOrQuit(message == NULL, "PriorityQueue is not empty when expected len is zero.");
|
||||
|
||||
VerifyOrQuit(aPriorityQueue.GetHeadForPriority(ot::Message::kPriorityLow) == NULL,
|
||||
"GetHeadForPriority() non-NULL when empty\n");
|
||||
"GetHeadForPriority() non-NULL when empty");
|
||||
VerifyOrQuit(aPriorityQueue.GetHeadForPriority(ot::Message::kPriorityNormal) == NULL,
|
||||
"GetHeadForPriority() non-NULL when empty\n");
|
||||
"GetHeadForPriority() non-NULL when empty");
|
||||
VerifyOrQuit(aPriorityQueue.GetHeadForPriority(ot::Message::kPriorityHigh) == NULL,
|
||||
"GetHeadForPriority() non-NULL when empty\n");
|
||||
"GetHeadForPriority() non-NULL when empty");
|
||||
VerifyOrQuit(aPriorityQueue.GetHeadForPriority(ot::Message::kPriorityNet) == NULL,
|
||||
"GetHeadForPriority() non-NULL when empty\n");
|
||||
"GetHeadForPriority() non-NULL when empty");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Go through all messages in the queue and verify they match the passed-in messages
|
||||
for (message = aPriorityQueue.GetHead(); message != NULL; message = message->GetNext())
|
||||
{
|
||||
VerifyOrQuit(aExpectedLength != 0, "PriorityQueue contains more entries than expected.\n");
|
||||
VerifyOrQuit(aExpectedLength != 0, "PriorityQueue contains more entries than expected.");
|
||||
|
||||
msgArg = va_arg(args, ot::Message *);
|
||||
|
||||
@@ -85,27 +85,27 @@ void VerifyPriorityQueueContent(ot::PriorityQueue &aPriorityQueue, int aExpected
|
||||
// Check the `GetHeadForPriority` is NULL if there are no expected message for this priority level.
|
||||
VerifyOrQuit(
|
||||
aPriorityQueue.GetHeadForPriority(static_cast<uint8_t>(curPriority)) == NULL,
|
||||
"PriorityQueue::GetHeadForPriority is non-NULL when no expected msg for this priority.\n");
|
||||
"PriorityQueue::GetHeadForPriority is non-NULL when no expected msg for this priority.");
|
||||
}
|
||||
|
||||
// Check the `GetHeadForPriority`.
|
||||
VerifyOrQuit(aPriorityQueue.GetHeadForPriority(static_cast<uint8_t>(curPriority)) == msgArg,
|
||||
"PriorityQueue::GetHeadForPriority failed.\n");
|
||||
"PriorityQueue::GetHeadForPriority failed.");
|
||||
}
|
||||
|
||||
// Check the queued message to match the one from argument list
|
||||
VerifyOrQuit(msgArg == message, "PriorityQueue content does not match what is expected.\n");
|
||||
VerifyOrQuit(msgArg == message, "PriorityQueue content does not match what is expected.");
|
||||
|
||||
aExpectedLength--;
|
||||
}
|
||||
|
||||
VerifyOrQuit(aExpectedLength == 0, "PriorityQueue contains less entries than expected.\n");
|
||||
VerifyOrQuit(aExpectedLength == 0, "PriorityQueue contains less entries than expected.");
|
||||
|
||||
// Check the `GetHeadForPriority` is NULL if there are no expected message for any remaining priority level.
|
||||
for (curPriority--; curPriority >= 0; curPriority--)
|
||||
{
|
||||
VerifyOrQuit(aPriorityQueue.GetHeadForPriority(static_cast<uint8_t>(curPriority)) == NULL,
|
||||
"PriorityQueue::GetHeadForPriority is non-NULL when no expected msg for this priority.\n");
|
||||
"PriorityQueue::GetHeadForPriority is non-NULL when no expected msg for this priority.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,21 +124,21 @@ void VerifyMsgQueueContent(ot::MessageQueue &aMessageQueue, int aExpectedLength,
|
||||
if (aExpectedLength == 0)
|
||||
{
|
||||
message = aMessageQueue.GetHead();
|
||||
VerifyOrQuit(message == NULL, "MessageQueue is not empty when expected len is zero.\n");
|
||||
VerifyOrQuit(message == NULL, "MessageQueue is not empty when expected len is zero.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (message = aMessageQueue.GetHead(); message != NULL; message = message->GetNext())
|
||||
{
|
||||
VerifyOrQuit(aExpectedLength != 0, "MessageQueue contains more entries than expected\n");
|
||||
VerifyOrQuit(aExpectedLength != 0, "MessageQueue contains more entries than expected");
|
||||
|
||||
msgArg = va_arg(args, ot::Message *);
|
||||
VerifyOrQuit(msgArg == message, "MessageQueue content does not match what is expected.\n");
|
||||
VerifyOrQuit(msgArg == message, "MessageQueue content does not match what is expected.");
|
||||
|
||||
aExpectedLength--;
|
||||
}
|
||||
|
||||
VerifyOrQuit(aExpectedLength == 0, "MessageQueue contains less entries than expected\n");
|
||||
VerifyOrQuit(aExpectedLength == 0, "MessageQueue contains less entries than expected");
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
@@ -156,7 +156,7 @@ void TestPriorityQueue(void)
|
||||
ot::Message * msgLow[kNumTestMessages];
|
||||
|
||||
instance = testInitInstance();
|
||||
VerifyOrQuit(instance != NULL, "Null OpenThread instance\n");
|
||||
VerifyOrQuit(instance != NULL, "Null OpenThread instance");
|
||||
|
||||
messagePool = &instance->Get<ot::MessagePool>();
|
||||
|
||||
@@ -164,159 +164,159 @@ void TestPriorityQueue(void)
|
||||
for (int i = 0; i < kNumNewPriorityTestMessages; i++)
|
||||
{
|
||||
msgNet[i] = messagePool->New(ot::Message::kTypeIp6, 0, ot::Message::kPriorityNet);
|
||||
VerifyOrQuit(msgNet[i] != NULL, "Message::New failed\n");
|
||||
VerifyOrQuit(msgNet[i] != NULL, "Message::New failed");
|
||||
msgHigh[i] = messagePool->New(ot::Message::kTypeIp6, 0, ot::Message::kPriorityHigh);
|
||||
VerifyOrQuit(msgHigh[i] != NULL, "Message::New failed\n");
|
||||
VerifyOrQuit(msgHigh[i] != NULL, "Message::New failed");
|
||||
msgNor[i] = messagePool->New(ot::Message::kTypeIp6, 0, ot::Message::kPriorityNormal);
|
||||
VerifyOrQuit(msgNor[i] != NULL, "Message::New failed\n");
|
||||
VerifyOrQuit(msgNor[i] != NULL, "Message::New failed");
|
||||
msgLow[i] = messagePool->New(ot::Message::kTypeIp6, 0, ot::Message::kPriorityLow);
|
||||
VerifyOrQuit(msgLow[i] != NULL, "Message::New failed\n");
|
||||
VerifyOrQuit(msgLow[i] != NULL, "Message::New failed");
|
||||
}
|
||||
|
||||
// Check the failure case for `New()` for invalid argument.
|
||||
VerifyOrQuit(messagePool->New(ot::Message::kTypeIp6, 0, ot::Message::kNumPriorities) == NULL,
|
||||
"Message::New() with out of range value did not fail as expected.\n");
|
||||
"Message::New() with out of range value did not fail as expected.");
|
||||
|
||||
// Use the function "SetPriority()" to allocate messages with different priorities
|
||||
for (int i = kNumNewPriorityTestMessages; i < kNumTestMessages; i++)
|
||||
{
|
||||
msgNet[i] = messagePool->New(ot::Message::kTypeIp6, 0);
|
||||
VerifyOrQuit(msgNet[i] != NULL, "Message::New failed\n");
|
||||
SuccessOrQuit(msgNet[i]->SetPriority(ot::Message::kPriorityNet), "Message:SetPriority failed\n");
|
||||
VerifyOrQuit(msgNet[i] != NULL, "Message::New failed");
|
||||
SuccessOrQuit(msgNet[i]->SetPriority(ot::Message::kPriorityNet), "Message:SetPriority failed");
|
||||
msgHigh[i] = messagePool->New(ot::Message::kTypeIp6, 0);
|
||||
VerifyOrQuit(msgHigh[i] != NULL, "Message::New failed\n");
|
||||
SuccessOrQuit(msgHigh[i]->SetPriority(ot::Message::kPriorityHigh), "Message:SetPriority failed\n");
|
||||
VerifyOrQuit(msgHigh[i] != NULL, "Message::New failed");
|
||||
SuccessOrQuit(msgHigh[i]->SetPriority(ot::Message::kPriorityHigh), "Message:SetPriority failed");
|
||||
msgNor[i] = messagePool->New(ot::Message::kTypeIp6, 0);
|
||||
VerifyOrQuit(msgNor[i] != NULL, "Message::New failed\n");
|
||||
SuccessOrQuit(msgNor[i]->SetPriority(ot::Message::kPriorityNormal), "Message:SetPriority failed\n");
|
||||
VerifyOrQuit(msgNor[i] != NULL, "Message::New failed");
|
||||
SuccessOrQuit(msgNor[i]->SetPriority(ot::Message::kPriorityNormal), "Message:SetPriority failed");
|
||||
msgLow[i] = messagePool->New(ot::Message::kTypeIp6, 0);
|
||||
VerifyOrQuit(msgLow[i] != NULL, "Message::New failed\n");
|
||||
SuccessOrQuit(msgLow[i]->SetPriority(ot::Message::kPriorityLow), "Message:SetPriority failed\n");
|
||||
VerifyOrQuit(msgLow[i] != NULL, "Message::New failed");
|
||||
SuccessOrQuit(msgLow[i]->SetPriority(ot::Message::kPriorityLow), "Message:SetPriority failed");
|
||||
}
|
||||
|
||||
// Check the failure case for `SetPriority()` for invalid argument.
|
||||
VerifyOrQuit(msgNet[2]->SetPriority(ot::Message::kNumPriorities) == OT_ERROR_INVALID_ARGS,
|
||||
"Message::SetPriority() with out of range value did not fail as expected.\n");
|
||||
"Message::SetPriority() with out of range value did not fail as expected.");
|
||||
|
||||
// Check the `GetPriority()`
|
||||
for (int i = 0; i < kNumTestMessages; i++)
|
||||
{
|
||||
VerifyOrQuit(msgLow[i]->GetPriority() == ot::Message::kPriorityLow, "Message::GetPriority failed.\n");
|
||||
VerifyOrQuit(msgNor[i]->GetPriority() == ot::Message::kPriorityNormal, "Message::GetPriority failed.\n");
|
||||
VerifyOrQuit(msgHigh[i]->GetPriority() == ot::Message::kPriorityHigh, "Message::GetPriority failed.\n");
|
||||
VerifyOrQuit(msgNet[i]->GetPriority() == ot::Message::kPriorityNet, "Message::GetPriority failed.\n");
|
||||
VerifyOrQuit(msgLow[i]->GetPriority() == ot::Message::kPriorityLow, "Message::GetPriority failed.");
|
||||
VerifyOrQuit(msgNor[i]->GetPriority() == ot::Message::kPriorityNormal, "Message::GetPriority failed.");
|
||||
VerifyOrQuit(msgHigh[i]->GetPriority() == ot::Message::kPriorityHigh, "Message::GetPriority failed.");
|
||||
VerifyOrQuit(msgNet[i]->GetPriority() == ot::Message::kPriorityNet, "Message::GetPriority failed.");
|
||||
}
|
||||
|
||||
// Verify case of an empty queue.
|
||||
VerifyPriorityQueueContent(queue, 0);
|
||||
|
||||
// Add msgs in different orders and check the content of queue.
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[0]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[0]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 1, msgHigh[0]);
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[1]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[1]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 2, msgHigh[0], msgHigh[1]);
|
||||
SuccessOrQuit(queue.Enqueue(*msgNet[0]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgNet[0]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgNet[0], msgHigh[0], msgHigh[1]);
|
||||
SuccessOrQuit(queue.Enqueue(*msgNet[1]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgNet[1]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 4, msgNet[0], msgNet[1], msgHigh[0], msgHigh[1]);
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[2]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[2]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 5, msgNet[0], msgNet[1], msgHigh[0], msgHigh[1], msgHigh[2]);
|
||||
SuccessOrQuit(queue.Enqueue(*msgLow[0]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgLow[0]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 6, msgNet[0], msgNet[1], msgHigh[0], msgHigh[1], msgHigh[2], msgLow[0]);
|
||||
SuccessOrQuit(queue.Enqueue(*msgNor[0]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgNor[0]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 7, msgNet[0], msgNet[1], msgHigh[0], msgHigh[1], msgHigh[2], msgNor[0],
|
||||
msgLow[0]);
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[3]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[3]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 8, msgNet[0], msgNet[1], msgHigh[0], msgHigh[1], msgHigh[2], msgHigh[3],
|
||||
msgNor[0], msgLow[0]);
|
||||
|
||||
// Remove messages in different order and check the content of queue in each step.
|
||||
SuccessOrQuit(queue.Dequeue(*msgNet[0]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgNet[0]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 7, msgNet[1], msgHigh[0], msgHigh[1], msgHigh[2], msgHigh[3], msgNor[0],
|
||||
msgLow[0]);
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[2]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[2]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 6, msgNet[1], msgHigh[0], msgHigh[1], msgHigh[3], msgNor[0], msgLow[0]);
|
||||
SuccessOrQuit(queue.Dequeue(*msgNor[0]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgNor[0]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 5, msgNet[1], msgHigh[0], msgHigh[1], msgHigh[3], msgLow[0]);
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[1]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[1]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 4, msgNet[1], msgHigh[0], msgHigh[3], msgLow[0]);
|
||||
SuccessOrQuit(queue.Dequeue(*msgLow[0]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgLow[0]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgNet[1], msgHigh[0], msgHigh[3]);
|
||||
SuccessOrQuit(queue.Dequeue(*msgNet[1]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgNet[1]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 2, msgHigh[0], msgHigh[3]);
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[0]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[0]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 1, msgHigh[3]);
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[3]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[3]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 0);
|
||||
|
||||
// Check the failure cases: Enqueuing an already queued message, or dequeuing a message not queued.
|
||||
SuccessOrQuit(queue.Enqueue(*msgNet[0]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgNet[0]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 1, msgNet[0]);
|
||||
VerifyOrQuit(queue.Enqueue(*msgNet[0]) == OT_ERROR_ALREADY,
|
||||
"Enqueuing an already queued message did not fail as expected.\n");
|
||||
"Enqueuing an already queued message did not fail as expected.");
|
||||
VerifyOrQuit(queue.Dequeue(*msgHigh[0]) == OT_ERROR_NOT_FOUND,
|
||||
"Dequeuing a message not queued, did not fail as expected.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgNet[0]), "PriorityQueue::Dequeue() failed.\n");
|
||||
"Dequeuing a message not queued, did not fail as expected.");
|
||||
SuccessOrQuit(queue.Dequeue(*msgNet[0]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 0);
|
||||
|
||||
// Change the priority of an already queued message and check the order change in the queue.
|
||||
SuccessOrQuit(queue.Enqueue(*msgNor[0]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgNor[0]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 1, msgNor[0]);
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[0]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgHigh[0]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 2, msgHigh[0], msgNor[0]);
|
||||
SuccessOrQuit(queue.Enqueue(*msgLow[0]), "PriorityQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(queue.Enqueue(*msgLow[0]), "PriorityQueue::Enqueue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgHigh[0], msgNor[0], msgLow[0]);
|
||||
|
||||
SuccessOrQuit(msgNor[0]->SetPriority(ot::Message::kPriorityNet),
|
||||
"SetPriority failed for an already queued message.\n");
|
||||
"SetPriority failed for an already queued message.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgNor[0], msgHigh[0], msgLow[0]);
|
||||
SuccessOrQuit(msgLow[0]->SetPriority(ot::Message::kPriorityLow),
|
||||
"SetPriority failed for an already queued message.\n");
|
||||
"SetPriority failed for an already queued message.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgNor[0], msgHigh[0], msgLow[0]);
|
||||
SuccessOrQuit(msgLow[0]->SetPriority(ot::Message::kPriorityNormal),
|
||||
"SetPriority failed for an already queued message.\n");
|
||||
"SetPriority failed for an already queued message.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgNor[0], msgHigh[0], msgLow[0]);
|
||||
SuccessOrQuit(msgLow[0]->SetPriority(ot::Message::kPriorityHigh),
|
||||
"SetPriority failed for an already queued message.\n");
|
||||
"SetPriority failed for an already queued message.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgNor[0], msgHigh[0], msgLow[0]);
|
||||
SuccessOrQuit(msgLow[0]->SetPriority(ot::Message::kPriorityNet),
|
||||
"SetPriority failed for an already queued message.\n");
|
||||
"SetPriority failed for an already queued message.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgNor[0], msgLow[0], msgHigh[0]);
|
||||
SuccessOrQuit(msgNor[0]->SetPriority(ot::Message::kPriorityNormal),
|
||||
"SetPriority failed for an already queued message.\n");
|
||||
"SetPriority failed for an already queued message.");
|
||||
SuccessOrQuit(msgLow[0]->SetPriority(ot::Message::kPriorityLow),
|
||||
"SetPriority failed for an already queued message.\n");
|
||||
"SetPriority failed for an already queued message.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgHigh[0], msgNor[0], msgLow[0]);
|
||||
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msgNor[1]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msgHigh[1]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msgNet[1]), "MessageQueue::Enqueue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msgNor[1]), "MessageQueue::Enqueue() failed.");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msgHigh[1]), "MessageQueue::Enqueue() failed.");
|
||||
SuccessOrQuit(messageQueue.Enqueue(*msgNet[1]), "MessageQueue::Enqueue() failed.");
|
||||
VerifyMsgQueueContent(messageQueue, 3, msgNor[1], msgHigh[1], msgNet[1]);
|
||||
|
||||
// Change priority of message and check for not in messageQueue.
|
||||
SuccessOrQuit(msgNor[1]->SetPriority(ot::Message::kPriorityNet),
|
||||
"SetPriority failed for an already queued message.\n");
|
||||
"SetPriority failed for an already queued message.");
|
||||
VerifyMsgQueueContent(messageQueue, 3, msgNor[1], msgHigh[1], msgNet[1]);
|
||||
|
||||
SuccessOrQuit(msgLow[0]->SetPriority(ot::Message::kPriorityHigh),
|
||||
"SetPriority failed for an already queued message.\n");
|
||||
"SetPriority failed for an already queued message.");
|
||||
VerifyPriorityQueueContent(queue, 3, msgHigh[0], msgLow[0], msgNor[0]);
|
||||
VerifyMsgQueueContent(messageQueue, 3, msgNor[1], msgHigh[1], msgNet[1]);
|
||||
|
||||
// Remove messages from the two queues
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[0]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgHigh[0]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 2, msgLow[0], msgNor[0]);
|
||||
VerifyMsgQueueContent(messageQueue, 3, msgNor[1], msgHigh[1], msgNet[1]);
|
||||
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msgNet[1]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msgNet[1]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 2, msgLow[0], msgNor[0]);
|
||||
VerifyMsgQueueContent(messageQueue, 2, msgNor[1], msgHigh[1]);
|
||||
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msgHigh[1]), "MessageQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(messageQueue.Dequeue(*msgHigh[1]), "MessageQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 2, msgLow[0], msgNor[0]);
|
||||
VerifyMsgQueueContent(messageQueue, 1, msgNor[1]);
|
||||
|
||||
SuccessOrQuit(queue.Dequeue(*msgLow[0]), "PriorityQueue::Dequeue() failed.\n");
|
||||
SuccessOrQuit(queue.Dequeue(*msgLow[0]), "PriorityQueue::Dequeue() failed.");
|
||||
VerifyPriorityQueueContent(queue, 1, msgNor[0]);
|
||||
VerifyMsgQueueContent(messageQueue, 1, msgNor[1]);
|
||||
|
||||
|
||||
+185
-185
@@ -128,22 +128,22 @@ int TestOneTimer(void)
|
||||
sNow = kTimeT0;
|
||||
timer.Start(kTimerInterval);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == 1000 && sPlatDt == 10, "TestOneTimer: Start params Failed.\n");
|
||||
VerifyOrQuit(timer.IsRunning(), "TestOneTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestOneTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sPlatT0 == 1000 && sPlatDt == 10, "TestOneTimer: Start params Failed.");
|
||||
VerifyOrQuit(timer.IsRunning(), "TestOneTimer: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestOneTimer: Platform Timer State Failed.");
|
||||
|
||||
sNow += kTimerInterval;
|
||||
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestOneTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestOneTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer.IsRunning() == false, "TestOneTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == false, "TestOneTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestOneTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestOneTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer.IsRunning() == false, "TestOneTimer: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == false, "TestOneTimer: Platform Timer State Failed.");
|
||||
|
||||
// Test one Timer that spans the 32-bit wrap.
|
||||
|
||||
@@ -152,22 +152,22 @@ int TestOneTimer(void)
|
||||
sNow = 0 - (kTimerInterval - 2);
|
||||
timer.Start(kTimerInterval);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == 0 - (kTimerInterval - 2) && sPlatDt == 10, "TestOneTimer: Start params Failed.\n");
|
||||
VerifyOrQuit(timer.IsRunning(), "TestOneTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestOneTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sPlatT0 == 0 - (kTimerInterval - 2) && sPlatDt == 10, "TestOneTimer: Start params Failed.");
|
||||
VerifyOrQuit(timer.IsRunning(), "TestOneTimer: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestOneTimer: Platform Timer State Failed.");
|
||||
|
||||
sNow += kTimerInterval;
|
||||
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestOneTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestOneTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer.IsRunning() == false, "TestOneTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == false, "TestOneTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestOneTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestOneTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer.IsRunning() == false, "TestOneTimer: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == false, "TestOneTimer: Platform Timer State Failed.");
|
||||
|
||||
// Test one Timer that is late by several msec
|
||||
|
||||
@@ -176,22 +176,22 @@ int TestOneTimer(void)
|
||||
sNow = kTimeT0;
|
||||
timer.Start(kTimerInterval);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == 1000 && sPlatDt == 10, "TestOneTimer: Start params Failed.\n");
|
||||
VerifyOrQuit(timer.IsRunning(), "TestOneTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestOneTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sPlatT0 == 1000 && sPlatDt == 10, "TestOneTimer: Start params Failed.");
|
||||
VerifyOrQuit(timer.IsRunning(), "TestOneTimer: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestOneTimer: Platform Timer State Failed.");
|
||||
|
||||
sNow += kTimerInterval + 5;
|
||||
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestOneTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestOneTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer.IsRunning() == false, "TestOneTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == false, "TestOneTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestOneTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestOneTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer.IsRunning() == false, "TestOneTimer: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == false, "TestOneTimer: Platform Timer State Failed.");
|
||||
|
||||
// Test one Timer that is early by several msec
|
||||
|
||||
@@ -200,32 +200,32 @@ int TestOneTimer(void)
|
||||
sNow = kTimeT0;
|
||||
timer.Start(kTimerInterval);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == 1000 && sPlatDt == 10, "TestOneTimer: Start params Failed.\n");
|
||||
VerifyOrQuit(timer.IsRunning(), "TestOneTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestOneTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestOneTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sPlatT0 == 1000 && sPlatDt == 10, "TestOneTimer: Start params Failed.");
|
||||
VerifyOrQuit(timer.IsRunning(), "TestOneTimer: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestOneTimer: Platform Timer State Failed.");
|
||||
|
||||
sNow += kTimerInterval - 2;
|
||||
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestOneTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer.IsRunning() == true, "TestOneTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == true, "TestOneTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestOneTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestOneTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestOneTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer.IsRunning() == true, "TestOneTimer: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == true, "TestOneTimer: Platform Timer State Failed.");
|
||||
|
||||
sNow += kTimerInterval;
|
||||
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestOneTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestOneTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestOneTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer.IsRunning() == false, "TestOneTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == false, "TestOneTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestOneTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestOneTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestOneTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer.IsRunning() == false, "TestOneTimer: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == false, "TestOneTimer: Platform Timer State Failed.");
|
||||
|
||||
printf(" --> PASSED\n");
|
||||
|
||||
@@ -255,47 +255,47 @@ int TestTwoTimers(void)
|
||||
sNow = kTimeT0;
|
||||
timer1.Start(kTimerInterval);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0 && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning(), "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0 && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.");
|
||||
VerifyOrQuit(timer1.IsRunning(), "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
sNow += kTimerInterval;
|
||||
|
||||
timer2.Start(kTimerInterval);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0 && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning() == true, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0 && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.");
|
||||
VerifyOrQuit(timer1.IsRunning() == true, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTwoTimers: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer1.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == sNow && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == true, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTwoTimers: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer1.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.");
|
||||
VerifyOrQuit(sPlatT0 == sNow && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == true, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
sNow += kTimerInterval;
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTwoTimers: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 2, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer2.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == false, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTwoTimers: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 2, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer2.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == false, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
// Test when second timer starts at the fire time of first timer (before otPlatAlarmMilliFired()) and its fire time
|
||||
// is before the first timer. Ensure that the second timer handler is invoked before the first one.
|
||||
@@ -307,41 +307,41 @@ int TestTwoTimers(void)
|
||||
sNow = kTimeT0;
|
||||
timer1.Start(kTimerInterval);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0 && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning(), "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0 && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.");
|
||||
VerifyOrQuit(timer1.IsRunning(), "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
sNow += kTimerInterval;
|
||||
|
||||
timer2.StartAt(ot::TimeMilli(kTimeT0), kTimerInterval - 2); // Timer 2 is even before timer 1
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning() == true, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer1.IsRunning() == true, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer2.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == sNow && sPlatDt == 0, "TestTwoTimers: Start params Failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning() == true, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == true, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer2.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.");
|
||||
VerifyOrQuit(sPlatT0 == sNow && sPlatDt == 0, "TestTwoTimers: Start params Failed.");
|
||||
VerifyOrQuit(timer1.IsRunning() == true, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == true, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 2, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer1.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == false, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 2, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer1.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == false, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
// Timer 1 fire callback is late by some ticks/ms, and second timer is scheduled (before call to
|
||||
// otPlatAlarmMilliFired) with a maximum interval. This is to test (corner-case) scenario where the fire time of two
|
||||
@@ -354,47 +354,47 @@ int TestTwoTimers(void)
|
||||
sNow = kTimeT0;
|
||||
timer1.Start(kTimerInterval);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0 && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning(), "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0 && sPlatDt == kTimerInterval, "TestTwoTimers: Start params Failed.");
|
||||
VerifyOrQuit(timer1.IsRunning(), "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
sNow += kTimerInterval + 5;
|
||||
|
||||
timer2.Start(ot::Timer::kMaxDelay);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning() == true, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 1, "TestTwoTimers: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer1.IsRunning() == true, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTwoTimers: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer1.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == sNow, "TestTwoTimers: Start params Failed.\n");
|
||||
VerifyOrQuit(sPlatDt == ot::Timer::kMaxDelay, "TestTwoTimers: Start params Failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == true, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTwoTimers: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 1, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer1.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.");
|
||||
VerifyOrQuit(sPlatT0 == sNow, "TestTwoTimers: Start params Failed.");
|
||||
VerifyOrQuit(sPlatDt == ot::Timer::kMaxDelay, "TestTwoTimers: Start params Failed.");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == true, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == true, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
sNow += ot::Timer::kMaxDelay;
|
||||
otPlatAlarmMilliFired(instance);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTwoTimers: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestTwoTimers: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 2, "TestTwoTimers: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(timer2.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.\n");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == false, "TestTwoTimers: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTwoTimers: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 1, "TestTwoTimers: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 2, "TestTwoTimers: Handler CallCount Failed.");
|
||||
VerifyOrQuit(timer2.GetFiredCounter() == 1, "TestTwoTimers: Fire Counter failed.");
|
||||
VerifyOrQuit(timer1.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(timer2.IsRunning() == false, "TestTwoTimers: Timer running Failed.");
|
||||
VerifyOrQuit(sTimerOn == false, "TestTwoTimers: Platform Timer State Failed.");
|
||||
|
||||
printf(" --> PASSED\n");
|
||||
|
||||
@@ -488,16 +488,16 @@ static void TenTimers(uint32_t aTimeShift)
|
||||
|
||||
// given the order in which timers are started, the TimerScheduler should call otPlatAlarmMilliStartAt 2 times.
|
||||
// one for timer[0] and one for timer[5] which will supercede timer[0].
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTenTimer: Start CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTenTimer: Stop CallCount Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTenTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0[5] + aTimeShift, "TestTenTimer: Start params Failed.\n");
|
||||
VerifyOrQuit(sPlatDt == kTimerInterval[5], "TestTenTimer: Start params Failed.\n");
|
||||
VerifyOrQuit(sTimerOn, "TestTenTimer: Platform Timer State Failed.\n");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTenTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTenTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTenTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sPlatT0 == kTimeT0[5] + aTimeShift, "TestTenTimer: Start params Failed.");
|
||||
VerifyOrQuit(sPlatDt == kTimerInterval[5], "TestTenTimer: Start params Failed.");
|
||||
VerifyOrQuit(sTimerOn, "TestTenTimer: Platform Timer State Failed.");
|
||||
|
||||
for (i = 0; i < kNumTimers; i++)
|
||||
{
|
||||
VerifyOrQuit(timers[i]->IsRunning(), "TestTenTimer: Timer running Failed.\n");
|
||||
VerifyOrQuit(timers[i]->IsRunning(), "TestTenTimer: Timer running Failed.");
|
||||
}
|
||||
|
||||
// Issue the triggers and test the State after each trigger.
|
||||
@@ -518,23 +518,23 @@ static void TenTimers(uint32_t aTimeShift)
|
||||
} while (sPlatDt == 0);
|
||||
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == kTimerStartCountAfterTrigger[trigger],
|
||||
"TestTenTimer: Start CallCount Failed.\n");
|
||||
"TestTenTimer: Start CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == kTimerStopCountAfterTrigger[trigger],
|
||||
"TestTenTimer: Stop CallCount Failed.\n");
|
||||
"TestTenTimer: Stop CallCount Failed.");
|
||||
VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == kTimerHandlerCountAfterTrigger[trigger],
|
||||
"TestTenTimer: Handler CallCount Failed.\n");
|
||||
VerifyOrQuit(sTimerOn == kSchedulerStateAfterTrigger[trigger], "TestTenTimer: Platform Timer State Failed.\n");
|
||||
"TestTenTimer: Handler CallCount Failed.");
|
||||
VerifyOrQuit(sTimerOn == kSchedulerStateAfterTrigger[trigger], "TestTenTimer: Platform Timer State Failed.");
|
||||
|
||||
for (i = 0; i < kNumTimers; i++)
|
||||
{
|
||||
VerifyOrQuit(timers[i]->IsRunning() == kTimerStateAfterTrigger[trigger][i],
|
||||
"TestTenTimer: Timer running Failed.\n");
|
||||
"TestTenTimer: Timer running Failed.");
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < kNumTimers; i++)
|
||||
{
|
||||
VerifyOrQuit(timers[i]->GetFiredCounter() == 1, "TestTenTimer: Timer fired counter Failed.\n");
|
||||
VerifyOrQuit(timers[i]->GetFiredCounter() == 1, "TestTenTimer: Timer fired counter Failed.");
|
||||
}
|
||||
|
||||
printf("--> PASSED\n");
|
||||
@@ -582,66 +582,66 @@ int TestTimerTime(void)
|
||||
printf("TestTimerTime() start=%-10x duration=%-10x ", start, duration);
|
||||
|
||||
t1.SetValue(start);
|
||||
VerifyOrQuit(t1.GetValue() == start, "Time::SetValue() failed.\n");
|
||||
VerifyOrQuit(t1.GetValue() == start, "Time::SetValue() failed.");
|
||||
|
||||
t2 = t1;
|
||||
VerifyOrQuit(t1.GetValue() == start, "Time assignment failed.\n");
|
||||
VerifyOrQuit(t1.GetValue() == start, "Time assignment failed.");
|
||||
|
||||
VerifyOrQuit(t1 == t2, "Time == failed.\n");
|
||||
VerifyOrQuit(!(t1 != t2), "Time != failed.\n");
|
||||
VerifyOrQuit(!(t1 < t2), "Time < failed.\n");
|
||||
VerifyOrQuit((t1 <= t2), "Time <= failed.\n");
|
||||
VerifyOrQuit(!(t1 > t2), "Time > failed.\n");
|
||||
VerifyOrQuit((t1 >= t2), "Time >= failed.\n");
|
||||
VerifyOrQuit(t2 - t1 == 0, "Time difference failed\n");
|
||||
VerifyOrQuit(t1 == t2, "Time == failed.");
|
||||
VerifyOrQuit(!(t1 != t2), "Time != failed.");
|
||||
VerifyOrQuit(!(t1 < t2), "Time < failed.");
|
||||
VerifyOrQuit((t1 <= t2), "Time <= failed.");
|
||||
VerifyOrQuit(!(t1 > t2), "Time > failed.");
|
||||
VerifyOrQuit((t1 >= t2), "Time >= failed.");
|
||||
VerifyOrQuit(t2 - t1 == 0, "Time difference failed");
|
||||
|
||||
t2 = t1 + duration;
|
||||
VerifyOrQuit(!(t1 == t2), "Time == failed.\n");
|
||||
VerifyOrQuit((t1 != t2), "Time != failed.\n");
|
||||
VerifyOrQuit((t1 < t2), "Time < failed.\n");
|
||||
VerifyOrQuit((t1 <= t2), "Time <= failed.\n");
|
||||
VerifyOrQuit(!(t1 > t2), "Time > failed.\n");
|
||||
VerifyOrQuit(!(t1 >= t2), "Time >= failed.\n");
|
||||
VerifyOrQuit(t2 - t1 == duration, "Time difference failed\n");
|
||||
VerifyOrQuit(!(t1 == t2), "Time == failed.");
|
||||
VerifyOrQuit((t1 != t2), "Time != failed.");
|
||||
VerifyOrQuit((t1 < t2), "Time < failed.");
|
||||
VerifyOrQuit((t1 <= t2), "Time <= failed.");
|
||||
VerifyOrQuit(!(t1 > t2), "Time > failed.");
|
||||
VerifyOrQuit(!(t1 >= t2), "Time >= failed.");
|
||||
VerifyOrQuit(t2 - t1 == duration, "Time difference failed");
|
||||
|
||||
t2 = t1;
|
||||
t2 += duration;
|
||||
VerifyOrQuit(!(t1 == t2), "Time == failed.\n");
|
||||
VerifyOrQuit((t1 != t2), "Time != failed.\n");
|
||||
VerifyOrQuit((t1 < t2), "Time < failed.\n");
|
||||
VerifyOrQuit((t1 <= t2), "Time <= failed.\n");
|
||||
VerifyOrQuit(!(t1 > t2), "Time > failed.\n");
|
||||
VerifyOrQuit(!(t1 >= t2), "Time >= failed.\n");
|
||||
VerifyOrQuit(t2 - t1 == duration, "Time difference failed\n");
|
||||
VerifyOrQuit(!(t1 == t2), "Time == failed.");
|
||||
VerifyOrQuit((t1 != t2), "Time != failed.");
|
||||
VerifyOrQuit((t1 < t2), "Time < failed.");
|
||||
VerifyOrQuit((t1 <= t2), "Time <= failed.");
|
||||
VerifyOrQuit(!(t1 > t2), "Time > failed.");
|
||||
VerifyOrQuit(!(t1 >= t2), "Time >= failed.");
|
||||
VerifyOrQuit(t2 - t1 == duration, "Time difference failed");
|
||||
|
||||
t2 = t1 - duration;
|
||||
VerifyOrQuit(!(t1 == t2), "Time == failed.\n");
|
||||
VerifyOrQuit((t1 != t2), "Time != failed.\n");
|
||||
VerifyOrQuit(!(t1 < t2), "Time < failed.\n");
|
||||
VerifyOrQuit(!(t1 <= t2), "Time <= failed.\n");
|
||||
VerifyOrQuit((t1 > t2), "Time > failed.\n");
|
||||
VerifyOrQuit((t1 >= t2), "Time >= failed.\n");
|
||||
VerifyOrQuit(t1 - t2 == duration, "Time difference failed\n");
|
||||
VerifyOrQuit(!(t1 == t2), "Time == failed.");
|
||||
VerifyOrQuit((t1 != t2), "Time != failed.");
|
||||
VerifyOrQuit(!(t1 < t2), "Time < failed.");
|
||||
VerifyOrQuit(!(t1 <= t2), "Time <= failed.");
|
||||
VerifyOrQuit((t1 > t2), "Time > failed.");
|
||||
VerifyOrQuit((t1 >= t2), "Time >= failed.");
|
||||
VerifyOrQuit(t1 - t2 == duration, "Time difference failed");
|
||||
|
||||
t2 = t1;
|
||||
t2 -= duration;
|
||||
VerifyOrQuit(!(t1 == t2), "Time == failed.\n");
|
||||
VerifyOrQuit((t1 != t2), "Time != failed.\n");
|
||||
VerifyOrQuit(!(t1 < t2), "Time < failed.\n");
|
||||
VerifyOrQuit(!(t1 <= t2), "Time <= failed.\n");
|
||||
VerifyOrQuit((t1 > t2), "Time > failed.\n");
|
||||
VerifyOrQuit((t1 >= t2), "Time >= failed.\n");
|
||||
VerifyOrQuit(t1 - t2 == duration, "Time difference failed\n");
|
||||
VerifyOrQuit(!(t1 == t2), "Time == failed.");
|
||||
VerifyOrQuit((t1 != t2), "Time != failed.");
|
||||
VerifyOrQuit(!(t1 < t2), "Time < failed.");
|
||||
VerifyOrQuit(!(t1 <= t2), "Time <= failed.");
|
||||
VerifyOrQuit((t1 > t2), "Time > failed.");
|
||||
VerifyOrQuit((t1 >= t2), "Time >= failed.");
|
||||
VerifyOrQuit(t1 - t2 == duration, "Time difference failed");
|
||||
|
||||
t2 = t1.GetDistantFuture();
|
||||
VerifyOrQuit((t1 < t2), "GetDistanceFuture() failed\n");
|
||||
VerifyOrQuit((t1 < t2), "GetDistanceFuture() failed");
|
||||
t2 += 1;
|
||||
VerifyOrQuit(!(t1 < t2), "GetDistanceFuture() failed\n");
|
||||
VerifyOrQuit(!(t1 < t2), "GetDistanceFuture() failed");
|
||||
|
||||
t2 = t1.GetDistantPast();
|
||||
VerifyOrQuit((t1 > t2), "GetDistantPast() failed\n");
|
||||
VerifyOrQuit((t1 > t2), "GetDistantPast() failed");
|
||||
t2 -= 1;
|
||||
VerifyOrQuit(!(t1 > t2), "GetDistantPast() failed\n");
|
||||
VerifyOrQuit(!(t1 > t2), "GetDistantPast() failed");
|
||||
|
||||
printf("--> PASSED\n");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ void test_packed1()
|
||||
|
||||
CompileTimeAssert(sizeof(packed_t) == 7, "packed_t should be packed to 7 bytes");
|
||||
|
||||
VerifyOrQuit(sizeof(packed_t) == 7, "Toolchain::OT_TOOL_PACKED failed 1\n");
|
||||
VerifyOrQuit(sizeof(packed_t) == 7, "Toolchain::OT_TOOL_PACKED failed 1");
|
||||
}
|
||||
|
||||
void test_packed2()
|
||||
@@ -67,7 +67,7 @@ void test_packed2()
|
||||
|
||||
CompileTimeAssert(sizeof(packed_t) == 4, "packed_t should be packed to 4 bytes");
|
||||
|
||||
VerifyOrQuit(sizeof(packed_t) == 4, "Toolchain::OT_TOOL_PACKED failed 2\n");
|
||||
VerifyOrQuit(sizeof(packed_t) == 4, "Toolchain::OT_TOOL_PACKED failed 2");
|
||||
}
|
||||
|
||||
void test_packed_union()
|
||||
@@ -90,7 +90,7 @@ void test_packed_union()
|
||||
|
||||
CompileTimeAssert(sizeof(packed_t) == 5, "packed_t should be packed to 5 bytes");
|
||||
|
||||
VerifyOrQuit(sizeof(packed_t) == 5, "Toolchain::OT_TOOL_PACKED failed 3\n");
|
||||
VerifyOrQuit(sizeof(packed_t) == 5, "Toolchain::OT_TOOL_PACKED failed 3");
|
||||
}
|
||||
|
||||
void test_packed_enum()
|
||||
@@ -99,7 +99,7 @@ void test_packed_enum()
|
||||
neighbor.SetState(ot::Neighbor::kStateValid);
|
||||
|
||||
// Make sure that when we read the 3 bit field it is read as unsigned, so it return '4'
|
||||
VerifyOrQuit(neighbor.GetState() == ot::Neighbor::kStateValid, "Toolchain::OT_TOOL_PACKED failed 4\n");
|
||||
VerifyOrQuit(neighbor.GetState() == ot::Neighbor::kStateValid, "Toolchain::OT_TOOL_PACKED failed 4");
|
||||
}
|
||||
|
||||
void test_addr_sizes()
|
||||
@@ -111,7 +111,7 @@ void test_addr_sizes()
|
||||
|
||||
void test_addr_bitfield()
|
||||
{
|
||||
VerifyOrQuit(CreateNetif_c().mScopeOverrideValid == true, "Toolchain::test_addr_size_cpp\n");
|
||||
VerifyOrQuit(CreateNetif_c().mScopeOverrideValid == true, "Toolchain::test_addr_size_cpp");
|
||||
}
|
||||
|
||||
void TestToolchain(void)
|
||||
|
||||
Reference in New Issue
Block a user