From 4bbf94568b7b452dc580b5740b4f719d858e4871 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Fri, 23 Sep 2022 12:24:37 -0700 Subject: [PATCH] Address review comment --- scripts/build/builders/host.py | 2 ++ scripts/build_coverage.sh | 32 ++------------------------------ 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index 5e0161bb2adb91..a599b0f6e6c3cf 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -365,6 +365,8 @@ def generate(self): def PreBuildCommand(self): if self.app == HostApp.TESTS and self.use_coverage: self._Execute(['ninja', '-C', self.output_dir, 'default'], title="Build-only") + self._Execute(['find', os.path.join(self.output_dir, 'obj/src/'), '-depth', + '-name', 'tests', '-exec', 'rm -rf {} \;'], title="Cleanup unit tests") self._Execute(['lcov', '--initial', '--capture', '--directory', os.path.join(self.output_dir, 'obj'), '--exclude', os.path.join(self.chip_dir, 'zzz_generated/*'), '--exclude', os.path.join(self.chip_dir, 'third_party/*'), '--exclude', '/usr/include/*', '--output-file', os.path.join(self.coverage_dir, 'lcov_base.info')], title="Initial coverage baseline") diff --git a/scripts/build_coverage.sh b/scripts/build_coverage.sh index 67961cc43e119b..91f5e7f4f0e2a0 100755 --- a/scripts/build_coverage.sh +++ b/scripts/build_coverage.sh @@ -92,36 +92,8 @@ if [ "$skip_gn" == false ]; then ninja -C "$OUTPUT_ROOT" check fi -echo "PWD:$PWD" -echo "CHIP_ROOT:$CHIP_ROOT" -echo "OUTPUT_ROOT:$OUTPUT_ROOT" - -rm -rf "$OUTPUT_ROOT/obj/src/access/tests" -rm -rf "$OUTPUT_ROOT/obj/src/app/tests" -rm -rf "$OUTPUT_ROOT/obj/src/ble/tests" -rm -rf "$OUTPUT_ROOT/obj/src/controller/tests" -rm -rf "$OUTPUT_ROOT/obj/src/credentials/tests" -rm -rf "$OUTPUT_ROOT/obj/src/crypto/tests" -rm -rf "$OUTPUT_ROOT/obj/src/inet/tests" -rm -rf "$OUTPUT_ROOT/obj/src/lib/asn1/tests" -rm -rf "$OUTPUT_ROOT/obj/src/lib/core/tests" -rm -rf "$OUTPUT_ROOT/obj/src/lib/dnssd/minimal_mdns/tests" -rm -rf "$OUTPUT_ROOT/obj/src/lib/dnssd/minimal_mdns/core/tests" -rm -rf "$OUTPUT_ROOT/obj/src/lib/dnssd/minimal_mdns/records/tests" -rm -rf "$OUTPUT_ROOT/obj/src/lib/dnssd/minimal_mdns/responders/tests" -rm -rf "$OUTPUT_ROOT/obj/src/lib/dnssd/tests" -rm -rf "$OUTPUT_ROOT/obj/src/lib/shell/tests" -rm -rf "$OUTPUT_ROOT/obj/src/lib/support/tests" -rm -rf "$OUTPUT_ROOT/obj/src/messaging/tests" -rm -rf "$OUTPUT_ROOT/obj/src/platform/tests" -rm -rf "$OUTPUT_ROOT/obj/src/protocols/bdx/tests" -rm -rf "$OUTPUT_ROOT/obj/src/protocols/secure_channel/tests" -rm -rf "$OUTPUT_ROOT/obj/src/protocols/user_directed_commissioning/tests" -rm -rf "$OUTPUT_ROOT/obj/src/setup_payload/tests" -rm -rf "$OUTPUT_ROOT/obj/src/system/tests" -rm -rf "$OUTPUT_ROOT/obj/src/transport/tests" -rm -rf "$OUTPUT_ROOT/obj/src/transport/raw/tests" -rm -rf "$OUTPUT_ROOT/obj/src/transport/retransmit/tests" +# Remove unit test itself from coverage statistics +find "$OUTPUT_ROOT/obj/src/" -depth -name 'tests' -exec rm -rf {} \; mkdir -p "$COVERAGE_ROOT" lcov --initial --capture --directory "$OUTPUT_ROOT/obj/src" --exclude="$PWD"/zzz_generated/* --exclude="$PWD"/third_party/* --exclude=/usr/include/* --output-file "$COVERAGE_ROOT/lcov_base.info"