diff --git a/examples/placeholder/linux/include/TestCommand.h b/examples/placeholder/linux/include/TestCommand.h index d544fb92541009..b9204f2d6702b9 100644 --- a/examples/placeholder/linux/include/TestCommand.h +++ b/examples/placeholder/linux/include/TestCommand.h @@ -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 size_t AddArgument(const char * name, chip::Optional * value) { @@ -176,6 +178,8 @@ class TestCommand : public TestRunner, chip::app::ConcreteAttributePath mAttributePath; chip::Optional mCommissionerNodeId; chip::Optional mEndpointId; + int mExitCode = EXIT_SUCCESS; + void SetIdentity(const char * name){}; /////////// DelayCommands Interface ///////// diff --git a/examples/placeholder/linux/main.cpp b/examples/placeholder/linux/main.cpp index eb43b7ece228f7..610e7b65dc1ae3 100644 --- a/examples/placeholder/linux/main.cpp +++ b/examples/placeholder/linux/main.cpp @@ -41,5 +41,11 @@ int main(int argc, char * argv[]) } ChipLinuxAppMainLoop(); + + if (test != nullptr) + { + return test->GetCommandExitCode(); + } + return 0; }