From 25951775d7f6eee5304c26f16d8748783849b161 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 4 Apr 2023 15:00:57 -0400 Subject: [PATCH] Make all-clusters be able to fuzz (#25968) * Fix typo: fuzzer should enable fuzzer, not tsan * Add fixes * Restyle --------- Co-authored-by: Andrei Litvin --- examples/all-clusters-app/linux/fuzzing-main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/all-clusters-app/linux/fuzzing-main.cpp b/examples/all-clusters-app/linux/fuzzing-main.cpp index b1736826ef335a..4fe21865727371 100644 --- a/examples/all-clusters-app/linux/fuzzing-main.cpp +++ b/examples/all-clusters-app/linux/fuzzing-main.cpp @@ -18,9 +18,17 @@ #include "AppMain.h" #include +#include + using namespace chip; using namespace chip::DeviceLayer; +namespace { + +LinuxCommissionableDataProvider gCommissionableDataProvider; + +} + void CleanShutdown() { Server::GetInstance().Shutdown(); @@ -40,6 +48,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t * aData, size_t aSize) VerifyOrDie(Platform::MemoryInit() == CHIP_NO_ERROR); VerifyOrDie(PlatformMgr().InitChipStack() == CHIP_NO_ERROR); + VerifyOrDie(chip::examples::InitCommissionableDataProvider(gCommissionableDataProvider, + LinuxDeviceOptions::GetInstance()) == CHIP_NO_ERROR); + SetCommissionableDataProvider(&gCommissionableDataProvider); + // ChipLinuxAppMainLoop blocks, and we don't want that here. static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit();