Skip to content

Commit

Permalink
Fix TestPlatformMgr crash (project-chip#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 project-chip#30640
  • Loading branch information
tcarmelveilleux authored and thivya-amazon committed Dec 18, 2023
1 parent dfe2387 commit eda4480
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 eda4480

Please sign in to comment.