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 Dec 18, 2023
1 parent b58488e commit 44e1a70
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 44e1a70

Please sign in to comment.