From 0c7100003e332de4d820c321b03b5815d03403d3 Mon Sep 17 00:00:00 2001
From: Yufeng Wang <yufengwang@google.com>
Date: Wed, 5 Feb 2025 22:08:37 -0800
Subject: [PATCH 1/3] Emable python tests during coverage

---
 .github/workflows/build.yaml | 8 --------
 scripts/build_coverage.sh    | 7 ++++++-
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index bcccb51a49f8c9..918686aec561c8 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -81,14 +81,6 @@ jobs:
               run: scripts/run_in_build_env.sh "ninja -C ./out"
             - name: Run Tests
               run: scripts/tests/gn_tests.sh
-            # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
-            # TODO https://github.com/project-chip/connectedhomeip/issues/1512
-            # - name: Run Code Coverage
-            #   if: ${{ contains('main', env.BUILD_TYPE) }}
-            #   run: scripts/tools/codecoverage.sh
-            # - name: Upload Code Coverage
-            #   if: ${{ contains('main', env.BUILD_TYPE) }}
-            #   run: bash <(curl -s https://codecov.io/bash)
             - name: Set up Build Without Detail Logging
               run: scripts/build/gn_gen.sh --args="chip_detail_logging=false"
             - name: Run Build Without Detail Logging
diff --git a/scripts/build_coverage.sh b/scripts/build_coverage.sh
index c9d942e8454e4e..571e9ccb06b5bc 100755
--- a/scripts/build_coverage.sh
+++ b/scripts/build_coverage.sh
@@ -172,8 +172,13 @@ if [ "$skip_gn" == false ]; then
     # 3) Run Python tests if requested
     #
     if [ "$ENABLE_PYTHON" == true ]; then
+        echo "Building python and applications ..."
+        scripts/run_in_build_env.sh \
+            "./scripts/tests/local.py build"
+
         echo "Running Python tests ..."
-        # TODO: run python tests.
+        scripts/run_in_build_env.sh \
+            "./scripts/tests/local.py python-tests"
     fi
 
     # ----------------------------------------------------------------------------

From 927040b79b7e2d776e43c7d1e4b08d959dd0f971 Mon Sep 17 00:00:00 2001
From: Yufeng Wang <yufengwang@google.com>
Date: Fri, 7 Feb 2025 11:31:51 -0800
Subject: [PATCH 2/3] Enable integration test during coverage statistic

---
 .github/workflows/build.yaml |  2 +-
 scripts/build_coverage.sh    | 17 ++++++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 918686aec561c8..af6912075ff92c 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -500,4 +500,4 @@ jobs:
                 platform: linux
 
             - name: Run Build Coverage
-              run: ./scripts/build_coverage.sh
+              run: ./scripts/build_coverage.sh --yaml
diff --git a/scripts/build_coverage.sh b/scripts/build_coverage.sh
index 571e9ccb06b5bc..984cc5b8c9daf2 100755
--- a/scripts/build_coverage.sh
+++ b/scripts/build_coverage.sh
@@ -161,24 +161,27 @@ if [ "$skip_gn" == false ]; then
 
         scripts/run_in_build_env.sh \
             "./scripts/tests/run_test_suite.py \
+             --runner chip_tool_python \
+             --exclude-tags MANUAL \
+             --exclude-tags FLAKY \
+             --exclude-tags IN_DEVELOPMENT \
+             --exclude-tags EXTRA_SLOW \
+             --exclude-tags SLOW \
+             --exclude-tags PURPOSEFUL_FAILURE \
              --chip-tool \"$OUTPUT_ROOT/chip-tool\" \
              run \
              --iterations 1 \
              --test-timeout-seconds 120 \
-             --all-clusters-app \"$OUTPUT_ROOT/chip-all-clusters-app\""
+             --all-clusters-app \"$OUTPUT_ROOT/chip-all-clusters-app\" \
+            "
     fi
 
     #
     # 3) Run Python tests if requested
     #
     if [ "$ENABLE_PYTHON" == true ]; then
-        echo "Building python and applications ..."
-        scripts/run_in_build_env.sh \
-            "./scripts/tests/local.py build"
-
         echo "Running Python tests ..."
-        scripts/run_in_build_env.sh \
-            "./scripts/tests/local.py python-tests"
+        # TODO: run python tests.
     fi
 
     # ----------------------------------------------------------------------------

From 54740bce794b2d89ffabfc91c658980b8fceccb9 Mon Sep 17 00:00:00 2001
From: Yufeng Wang <yufengwang@google.com>
Date: Fri, 7 Feb 2025 12:37:05 -0800
Subject: [PATCH 3/3] Update build_linux_gcc_coverage

---
 .github/workflows/build.yaml | 12 +++++++-----
 scripts/build_coverage.sh    |  1 +
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index af6912075ff92c..24ef4842fbe76a 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -480,16 +480,16 @@ jobs:
     build_linux_gcc_coverage:
         name: Build on Linux (coverage)
 
-        runs-on: ubuntu-latest
+        env:
+            TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt"
+
         if: github.actor != 'restyled-io[bot]'
+        runs-on: ubuntu-latest
 
         container:
             image: ghcr.io/project-chip/chip-build:104
-            volumes:
-                - "/:/runner-root-volume"
-                - "/tmp/log_output:/tmp/test_logs"
             options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0
-                net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"
+                net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0"
 
         steps:
             - name: Checkout
@@ -498,6 +498,8 @@ jobs:
               uses: ./.github/actions/checkout-submodules-and-bootstrap
               with:
                 platform: linux
+                bootstrap-log-name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }}                
 
             - name: Run Build Coverage
               run: ./scripts/build_coverage.sh --yaml
+
diff --git a/scripts/build_coverage.sh b/scripts/build_coverage.sh
index 984cc5b8c9daf2..2cf3f13ee131ad 100755
--- a/scripts/build_coverage.sh
+++ b/scripts/build_coverage.sh
@@ -169,6 +169,7 @@ if [ "$skip_gn" == false ]; then
              --exclude-tags SLOW \
              --exclude-tags PURPOSEFUL_FAILURE \
              --chip-tool \"$OUTPUT_ROOT/chip-tool\" \
+             --target TestUserLabelCluster \
              run \
              --iterations 1 \
              --test-timeout-seconds 120 \