Skip to content

[Python] Fix build without host unit test config #34368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading