Skip to content

Commit

Permalink
[Python] Fix build without host unit test config (#34368)
Browse files Browse the repository at this point in the history
Allow to build the Python controller without host unit test config
enabled.
  • Loading branch information
agners authored and pull[bot] committed Aug 12, 2024
1 parent e75e248 commit 2361820
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/controller/python/chip/clusters/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,13 @@ PyChipError SendBatchCommandsInternal(void * appContext, DeviceProxy * device, u
CHIP_ERROR err = CHIP_NO_ERROR;

bool testOnlySuppressTimedRequestMessage = false;
uint16_t * testOnlyCommandRefsOverride = nullptr;
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
uint16_t * testOnlyCommandRefsOverride = nullptr;
#endif

VerifyOrReturnError(device->GetSecureSession().HasValue(), ToPyChipError(CHIP_ERROR_MISSING_SECURE_SESSION));

#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
// Test only override validation checks and setup
if (testOnlyOverrides != nullptr)
{
Expand All @@ -228,6 +231,7 @@ PyChipError SendBatchCommandsInternal(void * appContext, DeviceProxy * device, u
config.SetRemoteMaxPathsPerInvoke(testOnlyOverrides->overrideRemoteMaxPathsPerInvoke);
}
else
#endif
{
auto remoteSessionParameters = device->GetSecureSession().Value()->GetRemoteSessionParameters();
config.SetRemoteMaxPathsPerInvoke(remoteSessionParameters.GetMaxPathsPerInvoke());
Expand Down Expand Up @@ -273,6 +277,7 @@ PyChipError SendBatchCommandsInternal(void * appContext, DeviceProxy * device, u
Optional<uint16_t> timedRequestTimeout =
timedRequestTimeoutMs != 0 ? Optional<uint16_t>(timedRequestTimeoutMs) : Optional<uint16_t>::Missing();
CommandSender::FinishCommandParameters finishCommandParams(timedRequestTimeout);
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
if (testOnlyCommandRefsOverride != nullptr)
{
finishCommandParams.commandRef.SetValue(testOnlyCommandRefsOverride[i]);
Expand All @@ -291,6 +296,7 @@ PyChipError SendBatchCommandsInternal(void * appContext, DeviceProxy * device, u
callback->AddCommandRefToIndexLookup(finishCommandParams.commandRef.Value(), i);
}
else
#endif
{
SuccessOrExit(err = callback->AddCommandRefToIndexLookup(finishCommandParams.commandRef.Value(), i));
}
Expand All @@ -300,12 +306,14 @@ PyChipError SendBatchCommandsInternal(void * appContext, DeviceProxy * device, u
Optional<System::Clock::Timeout> interactionTimeout = interactionTimeoutMs != 0
? MakeOptional(System::Clock::Milliseconds32(interactionTimeoutMs))
: Optional<System::Clock::Timeout>::Missing();
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
if (testOnlySuppressTimedRequestMessage)
{
SuccessOrExit(err = sender->TestOnlyCommandSenderTimedRequestFlagWithNoTimedInvoke(device->GetSecureSession().Value(),
interactionTimeout));
}
else
#endif
{
SuccessOrExit(err = sender->SendCommandRequest(device->GetSecureSession().Value(), interactionTimeout));
}
Expand Down

0 comments on commit 2361820

Please sign in to comment.