Skip to content
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

Improve matter gcoverage accuracy by excluding unit test files #22834

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,12 @@ 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(['lcov', '--initial', '--capture', '--directory', os.path.join(self.output_dir, 'obj'), '--exclude', os.path.join(self.chip_dir, 'third_party/*'), '--exclude', '/usr/include/*',
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")

def PostBuildCommand(self):
if self.app == HostApp.TESTS and self.use_coverage:
self._Execute(['lcov', '--capture', '--directory', os.path.join(self.output_dir, 'obj'), '--exclude', os.path.join(self.chip_dir, 'third_party/*'), '--exclude', '/usr/include/*',
self._Execute(['lcov', '--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_test.info')], title="Update coverage")
self._Execute(['lcov', '--add-tracefile', os.path.join(self.coverage_dir, 'lcov_base.info'),
'--add-tracefile', os.path.join(self.coverage_dir, 'lcov_test.info'),
Expand Down
35 changes: 33 additions & 2 deletions scripts/build_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,39 @@ 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"
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved
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"

mkdir -p "$COVERAGE_ROOT"
lcov --initial --capture --directory "$OUTPUT_ROOT/obj/src" --exclude="$CHIP_ROOT/third_party/*" --exclude=/usr/include/* --output-file "$COVERAGE_ROOT/lcov_base.info"
lcov --capture --directory "$OUTPUT_ROOT/obj/src" --exclude="$CHIP_ROOT/third_party/*" --exclude=/usr/include/* --output-file "$COVERAGE_ROOT/lcov_test.info"
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"
lcov --capture --directory "$OUTPUT_ROOT/obj/src" --exclude="$PWD"/zzz_generated/* --exclude="$PWD"/third_party/* --exclude=/usr/include/* --output-file "$COVERAGE_ROOT/lcov_test.info"
lcov --add-tracefile "$COVERAGE_ROOT/lcov_base.info" --add-tracefile "$COVERAGE_ROOT/lcov_test.info" --output-file "$COVERAGE_ROOT/lcov_final.info"
genhtml "$COVERAGE_ROOT/lcov_final.info" --output-directory "$COVERAGE_ROOT/html"