From 236182029c7a9642e1ff07c29cf231d53f89fd52 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 17 Jul 2024 19:10:18 +0100 Subject: [PATCH] [Python] Fix build without host unit test config (#34368) Allow to build the Python controller without host unit test config enabled. --- src/controller/python/chip/clusters/command.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/controller/python/chip/clusters/command.cpp b/src/controller/python/chip/clusters/command.cpp index d65766b7989d4d..037c848f96fae0 100644 --- a/src/controller/python/chip/clusters/command.cpp +++ b/src/controller/python/chip/clusters/command.cpp @@ -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) { @@ -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()); @@ -273,6 +277,7 @@ PyChipError SendBatchCommandsInternal(void * appContext, DeviceProxy * device, u Optional timedRequestTimeout = timedRequestTimeoutMs != 0 ? Optional(timedRequestTimeoutMs) : Optional::Missing(); CommandSender::FinishCommandParameters finishCommandParams(timedRequestTimeout); +#if CONFIG_BUILD_FOR_HOST_UNIT_TEST if (testOnlyCommandRefsOverride != nullptr) { finishCommandParams.commandRef.SetValue(testOnlyCommandRefsOverride[i]); @@ -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)); } @@ -300,12 +306,14 @@ PyChipError SendBatchCommandsInternal(void * appContext, DeviceProxy * device, u Optional interactionTimeout = interactionTimeoutMs != 0 ? MakeOptional(System::Clock::Milliseconds32(interactionTimeoutMs)) : Optional::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)); }