From 49b48ad5df227685d150d5abb833784a018432ee Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Wed, 11 Sep 2024 10:38:08 -0700 Subject: [PATCH 1/4] Moving these to async, as the completions already work when needed (#35537) * Moving these to async, as the completions already work when needed * Restyled by clang-format * Adding injection for events/attributes * Missing brace * Restyled by clang-format --------- Co-authored-by: Restyled.io --- .../Framework/CHIP/MTRDefines_Internal.h | 2 +- .../Framework/CHIP/MTRDeviceController_XPC.mm | 6 ++-- .../Framework/CHIP/MTRDevice_Concrete.mm | 34 +++++++++++++------ src/darwin/Framework/CHIP/MTRDevice_XPC.mm | 3 +- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDefines_Internal.h b/src/darwin/Framework/CHIP/MTRDefines_Internal.h index 94a1cbb3da61f4..983226704301e3 100644 --- a/src/darwin/Framework/CHIP/MTRDefines_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDefines_Internal.h @@ -91,7 +91,7 @@ typedef struct {} variable_hidden_by_mtr_hide; { \ NSXPCConnection * xpcConnection = XPC_CONNECTION; \ \ - [[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \ + [[xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \ MTR_LOG_ERROR("Error: %@", error); \ }] PREFIX ADDITIONAL_ARGUMENTS]; \ } diff --git a/src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm b/src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm index 7ca9fde2099e03..29860fd41f1039 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm @@ -181,7 +181,7 @@ - (BOOL)_setupXPCConnection MTR_LOG("%@ Activating new XPC connection", self); [self.xpcConnection activate]; - [[self.xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { + [[self.xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { MTR_LOG_ERROR("Checkin error: %@", error); }] deviceController:self.uniqueIdentifier checkInWithContext:[NSDictionary dictionary]]; @@ -193,7 +193,7 @@ - (BOOL)_setupXPCConnection MTR_LOG("%@ => Registering nodeID: %@", self, nodeID); mtr_weakify(self); - [[self.xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { + [[self.xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { mtr_strongify(self); MTR_LOG_ERROR("%@ Registration error for device nodeID: %@ : %@", self, nodeID, error); }] deviceController:self.uniqueIdentifier registerNodeID:nodeID]; @@ -288,7 +288,7 @@ - (MTRDevice *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(N MTR_LOG("%s: returning XPC device for node id %@", __PRETTY_FUNCTION__, nodeID); mtr_weakify(self); - [[self.xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { + [[self.xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { mtr_strongify(self); MTR_LOG_ERROR("%@ Registration error for device nodeID: %@ : %@", self, nodeID, error); }] deviceController:self.uniqueIdentifier registerNodeID:nodeID]; diff --git a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm index 9beacdfd046bbc..6342a46bcd8432 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm +++ b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm @@ -1852,24 +1852,38 @@ - (void)_handleAttributeReport:(NSArray *> *)attrib [self _reportAttributes:[self _getAttributesToReportWithReportedValues:attributeReport fromSubscription:isFromSubscription]]; } -#ifdef DEBUG -- (void)unitTestInjectEventReport:(NSArray *> *)eventReport +// BEGIN DRAGON: This is used by the XPC Server to inject reports into local cache and broadcast them +- (void)_injectAttributeReport:(NSArray *> *)attributeReport fromSubscription:(BOOL)isFromSubscription { + [_deviceController asyncDispatchToMatterQueue:^{ + [self _handleReportBegin]; + dispatch_async(self.queue, ^{ + [self _handleAttributeReport:attributeReport fromSubscription:isFromSubscription]; + [self _handleReportEnd]; + }); + } errorHandler:nil]; +} + +- (void)_injectEventReport:(NSArray *> *)eventReport +{ + // [_deviceController asyncDispatchToMatterQueue:^{ // TODO: This wasn't used previously, not sure why, so keeping it here for thought, but preserving existing behavior dispatch_async(self.queue, ^{ [self _handleEventReport:eventReport]; }); + // } errorHandler: nil]; +} + +// END DRAGON: This is used by the XPC Server to inject attribute reports + +#ifdef DEBUG +- (void)unitTestInjectEventReport:(NSArray *> *)eventReport +{ + [self _injectEventReport:eventReport]; } - (void)unitTestInjectAttributeReport:(NSArray *> *)attributeReport fromSubscription:(BOOL)isFromSubscription { - [_deviceController asyncDispatchToMatterQueue:^{ - [self _handleReportBegin]; - dispatch_async(self.queue, ^{ - [self _handleAttributeReport:attributeReport fromSubscription:isFromSubscription]; - [self _handleReportEnd]; - }); - } - errorHandler:nil]; + [self _injectAttributeReport:attributeReport fromSubscription:isFromSubscription]; } #endif diff --git a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm index 46f143e4bc189e..2f7fb260ebde48 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm +++ b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm @@ -244,8 +244,7 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID { NSXPCConnection * xpcConnection = [(MTRDeviceController_XPC *) [self deviceController] xpcConnection]; - // TODO: use asynchronous XPC and register a block with controller to call for this transaction - [[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { + [[xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { MTR_LOG_ERROR("Error: %@", error); }] deviceController:[[self deviceController] uniqueIdentifier] nodeID:[self nodeID] From 021f4311fb910905ccc38c9fcd54896704f0c49f Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 11 Sep 2024 14:04:10 -0400 Subject: [PATCH 2/4] Update python builds to latest CI image (ubuntu 24.04 build) (#35534) * Switch python builds to latest CI image * Switch logic for pip updates and wheel installation: do not hardcode paths * More fixes for new python, where pip cannot just be used --- .github/workflows/build.yaml | 14 ++++++++------ scripts/build_python.sh | 4 ++-- scripts/build_python_device.sh | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index be259e232e5022..83ecc7e00a2192 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -283,7 +283,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build:54 + image: ghcr.io/project-chip/chip-build:74 volumes: - "/:/runner-root-volume" - "/tmp/log_output:/tmp/test_logs" @@ -316,9 +316,10 @@ jobs: run: | scripts/run_in_build_env.sh 'virtualenv pyenv' source pyenv/bin/activate - pip3 install ./out/controller/python/chip_core-0.0-cp37-abi3-linux_x86_64.whl - pip3 install ./out/controller/python/chip_clusters-0.0-py3-none-any.whl - pip3 install ./out/controller/python/chip_repl-0.0-py3-none-any.whl + python -m ensurepip --upgrade + python -m pip install ./out/controller/python/chip_core-0.0-cp37-abi3-linux_x86_64.whl + python -m pip install ./out/controller/python/chip_clusters-0.0-py3-none-any.whl + python -m pip install ./out/controller/python/chip_repl-0.0-py3-none-any.whl - name: Run Python tests shell: bash @@ -334,7 +335,8 @@ jobs: scripts/run_in_build_env.sh 'scripts/examples/gn_build_example.sh examples/chip-tool out/' scripts/run_in_build_env.sh 'virtualenv pyenv' source pyenv/bin/activate - pip3 install -r scripts/setup/requirements.setuppayload.txt + python -m ensurepip --upgrade + python -m pip install -r scripts/setup/requirements.setuppayload.txt python3 src/setup_payload/tests/run_python_setup_payload_test.py out/chip-tool build_linux_python_lighting_device: @@ -344,7 +346,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build:54 + image: ghcr.io/project-chip/chip-build:74 volumes: - "/:/runner-root-volume" - "/tmp/log_output:/tmp/test_logs" diff --git a/scripts/build_python.sh b/scripts/build_python.sh index 9bb919605e229c..eaf1ad9c0e3050 100755 --- a/scripts/build_python.sh +++ b/scripts/build_python.sh @@ -217,8 +217,8 @@ if [ -n "$install_virtual_env" ]; then fi source "$ENVIRONMENT_ROOT"/bin/activate - "$ENVIRONMENT_ROOT"/bin/python -m pip install --upgrade pip - "$ENVIRONMENT_ROOT"/bin/pip install --upgrade "${WHEEL[@]}" + "$ENVIRONMENT_ROOT"/bin/python -m ensurepip --upgrade + "$ENVIRONMENT_ROOT"/bin/python -m pip install --upgrade "${WHEEL[@]}" if [ "$install_pytest_requirements" = "yes" ]; then YAMLTESTS_GN_LABEL="//scripts:matter_yamltests_distribution._build_wheel" diff --git a/scripts/build_python_device.sh b/scripts/build_python_device.sh index 9b21d28954c409..17824403184c12 100755 --- a/scripts/build_python_device.sh +++ b/scripts/build_python_device.sh @@ -104,8 +104,8 @@ virtualenv --clear "$ENVIRONMENT_ROOT" WHEEL=("$OUTPUT_ROOT"/controller/python/chip_core*.whl) source "$ENVIRONMENT_ROOT"/bin/activate -"$ENVIRONMENT_ROOT"/bin/python -m pip install --upgrade pip -"$ENVIRONMENT_ROOT"/bin/pip install --upgrade --force-reinstall --no-cache-dir "${WHEEL[@]}" +"$ENVIRONMENT_ROOT"/bin/python -m ensurepip --upgrade +"$ENVIRONMENT_ROOT"/bin/python -m pip install --upgrade --force-reinstall --no-cache-dir "${WHEEL[@]}" echo "" echo_green "Compilation completed and WHL package installed in: " From f46de96fb945c0feb4b3f7046914b7b36d1a6d63 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 11 Sep 2024 14:10:26 -0400 Subject: [PATCH 3/4] Switch infineon builds to latest CI image (#35535) * Switch infineon builds to latest CI image * Set up an environment for modus toolbox because image does not have it --- .github/workflows/examples-infineon.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 290e67273f9bd3..0fcfac2ce7890e 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -37,7 +37,10 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-infineon:54 + image: ghcr.io/project-chip/chip-build-infineon:74 + env: + # TODO: this should probably be part of the dockerfile itself + CY_TOOLS_PATHS: /opt/Tools/ModusToolbox/tools_3.2 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: From e64ab7181ad48e245b4e09feef38df841e61f2c1 Mon Sep 17 00:00:00 2001 From: Vatsal Ghelani <152916324+vatsalghelani-csa@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:58:32 -0400 Subject: [PATCH 4/4] Fix same test run multiple times avoiding duplication (#35539) --- .github/workflows/tests.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3a9bca19317216..2c68b91222bf80 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -522,19 +522,17 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/controller/python/test/test_scripts/mobile-device-test.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/execute_python_tests.py --env-file /tmp/test_env.yaml --search-directory src/python_testing' scripts/run_in_python_env.sh out/venv './scripts/tests/TestTimeSyncTrustedTimeSourceRunner.py --all-clusters out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test-data-model-check-check-failure-die/chip-all-clusters-app' - scripts/run_in_python_env.sh out/venv './src/python_testing/test_testing/test_TC_ICDM_2_1.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestIdChecks.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestSpecParsingDeviceType.py' - scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestSpecParsingSupport.py' - scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestConformanceTest.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestConformanceSupport.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestConformanceTest.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestChoiceConformanceSupport.py' + scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestMatterTestingSupport.py' + scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestSpecParsingSupport.py' + scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_TC_ICDM_2_1.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_IDM_10_4.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_TC_SC_7_1.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/TestDecorators.py' - scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestMatterTestingSupport.py' - scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestSpecParsingSupport.py' - name: Uploading core files