Skip to content

Commit

Permalink
Fix TestPlatformMgr crash (#31052)
Browse files Browse the repository at this point in the history
- TestPlatformMgr did not set a CommissionableDataProvider.
- Recent code changes make that test hit codepaths that try
  to setup BLE advertisement on Linux platform when default-built.
- This PR adds a CommissionableDataProvider instance for the whole
  test with default test values. Tests now pass.

Fixes #30640
  • Loading branch information
tcarmelveilleux authored and pull[bot] committed Mar 22, 2024
1 parent 8969198 commit 23eea46
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/platform/tests/TestPlatformMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <nlunit-test.h>

#include <platform/CHIPDeviceLayer.h>
#include <platform/TestOnlyCommissionableDataProvider.h>

using namespace chip;
using namespace chip::Logging;
Expand Down Expand Up @@ -277,6 +278,12 @@ int TestPlatformMgr_Setup(void * inContext)
CHIP_ERROR error = chip::Platform::MemoryInit();
if (error != CHIP_NO_ERROR)
return FAILURE;

// Setup a fake commissionable data provider since required by internals of several
// Device/SystemLayer components.
static chip::DeviceLayer::TestOnlyCommissionableDataProvider commissionable_data_provider;
chip::DeviceLayer::SetCommissionableDataProvider(&commissionable_data_provider);

return SUCCESS;
}

Expand Down

0 comments on commit 23eea46

Please sign in to comment.