Skip to content

Commit

Permalink
Fix placeholder app shutdown to actually do a clean stack shutdown. (p…
Browse files Browse the repository at this point in the history
…roject-chip#24714)

Otherwise we end up crashing on asserts about leaks.

Fixes project-chip#24705
  • Loading branch information
bzbarsky-apple authored and David Lechner committed Mar 22, 2023
1 parent 93d9518 commit 24a6b09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/placeholder/linux/include/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ class TestCommand : public TestRunner,
void SetCommandExitStatus(CHIP_ERROR status)
{
chip::DeviceLayer::PlatformMgr().StopEventLoopTask();
exit(CHIP_NO_ERROR == status ? EXIT_SUCCESS : EXIT_FAILURE);
mExitCode = (CHIP_NO_ERROR == status ? EXIT_SUCCESS : EXIT_FAILURE);
}

int GetCommandExitCode() { return mExitCode; }

template <typename T>
size_t AddArgument(const char * name, chip::Optional<T> * value)
{
Expand Down Expand Up @@ -176,6 +178,8 @@ class TestCommand : public TestRunner,
chip::app::ConcreteAttributePath mAttributePath;
chip::Optional<chip::NodeId> mCommissionerNodeId;
chip::Optional<chip::EndpointId> mEndpointId;
int mExitCode = EXIT_SUCCESS;

void SetIdentity(const char * name){};

/////////// DelayCommands Interface /////////
Expand Down
6 changes: 6 additions & 0 deletions examples/placeholder/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ int main(int argc, char * argv[])
}

ChipLinuxAppMainLoop();

if (test != nullptr)
{
return test->GetCommandExitCode();
}

return 0;
}

0 comments on commit 24a6b09

Please sign in to comment.