diff --git a/tests/gtest/fake_platform.cpp b/tests/gtest/fake_platform.cpp index 9514eeaf78c..54908db4279 100644 --- a/tests/gtest/fake_platform.cpp +++ b/tests/gtest/fake_platform.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -47,7 +48,8 @@ #include #include #include -#include "openthread/error.h" +#include +#include using namespace ot; @@ -90,6 +92,7 @@ FakePlatform::~FakePlatform() sPlatform = nullptr; } +#if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE void FakePlatform::StartMicroAlarm(uint32_t aT0, uint32_t aDt) { uint64_t start = mNow; @@ -102,6 +105,10 @@ void FakePlatform::StartMicroAlarm(uint32_t aT0, uint32_t aDt) mMicroAlarmStart = start; } + +void FakePlatform::StopMicroAlarm() { mMicroAlarmStart = kAlarmStop; } +#endif + void FakePlatform::StartMilliAlarm(uint32_t aT0, uint32_t aDt) { uint64_t start = mNow - (mNow % OT_US_PER_MS); @@ -115,8 +122,6 @@ void FakePlatform::StartMilliAlarm(uint32_t aT0, uint32_t aDt) mMilliAlarmStart = start; } -void FakePlatform::StopMicroAlarm() { mMicroAlarmStart = kAlarmStop; } - void FakePlatform::StopMilliAlarm() { mMilliAlarmStart = kAlarmStop; } void FakePlatform::ProcessAlarm(uint64_t &aTimeout) @@ -124,12 +129,12 @@ void FakePlatform::ProcessAlarm(uint64_t &aTimeout) uint64_t end = mNow + aTimeout; uint64_t *alarm = &end; - +#if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE if (mMicroAlarmStart < *alarm) { alarm = &mMicroAlarmStart; } - +#endif if (mMilliAlarmStart < *alarm) { alarm = &mMilliAlarmStart; @@ -141,12 +146,14 @@ void FakePlatform::ProcessAlarm(uint64_t &aTimeout) mNow = *alarm; } *alarm = kAlarmStop; - +#if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE if (alarm == &mMicroAlarmStart) { otPlatAlarmMicroFired(mInstance); } - else if (alarm == &mMilliAlarmStart) + else +#endif + if (alarm == &mMilliAlarmStart) { otPlatAlarmMilliFired(mInstance); } @@ -244,7 +251,7 @@ otError FakePlatform::SettingsDelete(uint16_t aKey, int aIndex) return OT_ERROR_NOT_FOUND; } - if (aIndex >= setting->second.size()) + if (static_cast(aIndex) >= setting->second.size()) { return OT_ERROR_NOT_FOUND; } @@ -309,12 +316,14 @@ void otPlatAlarmMilliStartAt(otInstance *, uint32_t aT0, uint32_t aDt) } uint32_t otPlatAlarmMilliGetNow(void) { return FakePlatform::CurrentPlatform().GetNow() / OT_US_PER_MS; } -void otPlatAlarmMicroStop(otInstance *) { FakePlatform::CurrentPlatform().StopMicroAlarm(); } +#if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE +void otPlatAlarmMicroStop(otInstance *) { FakePlatform::CurrentPlatform().StopMicroAlarm(); } void otPlatAlarmMicroStartAt(otInstance *, uint32_t aT0, uint32_t aDt) { FakePlatform::CurrentPlatform().StartMicroAlarm(aT0, aDt); } +#endif uint64_t otPlatTimeGet(void) { return FakePlatform::CurrentPlatform().GetNow(); } uint16_t otPlatTimeGetXtalAccuracy(void) { return 0; } @@ -392,6 +401,11 @@ bool otPlatRadioIsCoexEnabled(otInstance *) { return true; } otError otPlatRadioSetCoexEnabled(otInstance *, bool) { return OT_ERROR_NOT_IMPLEMENTED; } +otError otPlatRadioConfigureEnhAckProbing(otInstance *, otLinkMetrics, otShortAddress, const otExtAddress *) +{ + return OT_ERROR_NOT_IMPLEMENTED; +} + void otPlatReset(otInstance *) {} otPlatResetReason otPlatGetResetReason(otInstance *) { return OT_PLAT_RESET_REASON_POWER_ON; } @@ -426,7 +440,7 @@ void otPlatDiagRadioReceived(otInstance *, otRadioFrame *, otError) {} void otPlatDiagAlarmCallback(otInstance *) {} -OT_TOOL_WEAK void otPlatLog(otLogLevel aLevel, otLogRegion aRegion, const char *aFormat, ...) {} +OT_TOOL_WEAK void otPlatLog(otLogLevel, otLogRegion, const char *, ...) {} void *otPlatCAlloc(size_t aNum, size_t aSize) { return calloc(aNum, aSize); } @@ -438,7 +452,7 @@ otError otPlatInfraIfSendIcmp6Nd(uint32_t, const otIp6Address *, const uint8_t * otError otPlatInfraIfDiscoverNat64Prefix(uint32_t) { return OT_ERROR_FAILED; } -void otPlatDsoEnableListening(otInstance *aInstance, bool) {} +void otPlatDsoEnableListening(otInstance *, bool) {} void otPlatDsoConnect(otPlatDsoConnection *, const otSockAddr *) {} @@ -450,7 +464,7 @@ otError otPlatBleEnable(otInstance *) { return OT_ERROR_NONE; } otError otPlatBleDisable(otInstance *) { return OT_ERROR_NONE; } -otError otPlatBleGetAdvertisementBuffer(otInstance *, uint8_t **aAdvertisementBuffer) { return OT_ERROR_NO_BUFS; } +otError otPlatBleGetAdvertisementBuffer(otInstance *, uint8_t **) { return OT_ERROR_NO_BUFS; } otError otPlatBleGapAdvStart(otInstance *, uint16_t) { return OT_ERROR_NONE; } @@ -468,6 +482,10 @@ bool otPlatBleSupportsMultiRadio(otInstance *) { return false; } otError otPlatBleGapAdvSetData(otInstance *, uint8_t *, uint16_t) { return OT_ERROR_NONE; } +void otPlatSettingsInit(otInstance *, const uint16_t *, uint16_t) {} + +void otPlatSettingsDeinit(otInstance *) {} + otError otPlatSettingsGet(otInstance *, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength) { return FakePlatform::CurrentPlatform().SettingsGet(aKey, aIndex, aValue, aValueLength); @@ -506,4 +524,26 @@ void otPlatFlashWrite(otInstance *, uint8_t aSwapIndex, uint32_t aOffset, const FakePlatform::CurrentPlatform().FlashWrite(aSwapIndex, aOffset, aData, aSize); } +void otPlatTrelEnable(otInstance *, uint16_t *) {} +void otPlatTrelDisable(otInstance *) {} +void otPlatTrelRegisterService(otInstance *, uint16_t, const uint8_t *, uint8_t) {} +void otPlatTrelSend(otInstance *, const uint8_t *, uint16_t, const otSockAddr *) {} +const otPlatTrelCounters *otPlatTrelGetCounters(otInstance *) { return nullptr; } +void otPlatTrelResetCounters(otInstance *) {} + +otError otPlatUdpSocket(otUdpSocket *) { return OT_ERROR_NOT_IMPLEMENTED; } +otError otPlatUdpClose(otUdpSocket *) { return OT_ERROR_NOT_IMPLEMENTED; } +otError otPlatUdpBind(otUdpSocket *) { return OT_ERROR_NOT_IMPLEMENTED; } +otError otPlatUdpBindToNetif(otUdpSocket *, otNetifIdentifier) { return OT_ERROR_NOT_IMPLEMENTED; } +otError otPlatUdpConnect(otUdpSocket *) { return OT_ERROR_NOT_IMPLEMENTED; } +otError otPlatUdpSend(otUdpSocket *, otMessage *, const otMessageInfo *) { return OT_ERROR_NOT_IMPLEMENTED; } +otError otPlatUdpJoinMulticastGroup(otUdpSocket *, otNetifIdentifier, const otIp6Address *) +{ + return OT_ERROR_NOT_IMPLEMENTED; +} +otError otPlatUdpLeaveMulticastGroup(otUdpSocket *, otNetifIdentifier, const otIp6Address *) +{ + return OT_ERROR_NOT_IMPLEMENTED; +} + } // extern "C" diff --git a/tests/gtest/fake_platform.hpp b/tests/gtest/fake_platform.hpp index 4423ae82387..b10c7ca1b82 100644 --- a/tests/gtest/fake_platform.hpp +++ b/tests/gtest/fake_platform.hpp @@ -29,7 +29,7 @@ #ifndef OT_GTEST_FAKE_PLATFORM_HPP_ #define OT_GTEST_FAKE_PLATFORM_HPP_ -#include +#include "openthread-core-config.h" #include #include @@ -69,8 +69,10 @@ class FakePlatform virtual void StartMilliAlarm(uint32_t aT0, uint32_t aDt); virtual void StopMilliAlarm(); +#if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE virtual void StartMicroAlarm(uint32_t aT0, uint32_t aDt); virtual void StopMicroAlarm(); +#endif uint8_t GetReceiveChannel(void) const { return mChannel; } virtual otRadioFrame *GetTransmitBuffer() { return &mTransmitFrame; } @@ -107,8 +109,10 @@ class FakePlatform otInstance *mInstance = nullptr; - uint64_t mNow = 0; + uint64_t mNow = 0; +#if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE uint64_t mMicroAlarmStart = kAlarmStop; +#endif uint64_t mMilliAlarmStart = kAlarmStop; otRadioFrame mTransmitFrame;