Skip to content

Commit

Permalink
Run yaml and unit test for unified coverage (#22892)
Browse files Browse the repository at this point in the history
* Include yaml test into test coverage result

* Address review comments
  • Loading branch information
yufengwangca authored and pull[bot] committed Jan 8, 2024
1 parent b0d1065 commit 1278128
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
13 changes: 13 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
(current_os == "mac" || current_os == "linux") &&
(host_cpu == "x64" || host_cpu == "arm64" || host_cpu == "arm")
enable_pylib = false

# Build the Linux all clusters app example with default group
chip_build_all_clusters_app = false
}

if (enable_fuzz_test_targets) {
Expand Down Expand Up @@ -218,6 +221,16 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
if (build_tv_casting_common_a) {
deps += [ "${chip_root}/examples/tv-casting-app/tv-casting-common:tvCastingCommon" ]
}

if (chip_build_all_clusters_app) {
if (is_libfuzzer) {
deps += [ "${chip_root}/examples/all-clusters-app/linux:chip-all-clusters-app-fuzzing" ]
} else {
deps += [
"${chip_root}/examples/all-clusters-app/linux:chip-all-clusters-app",
]
}
}
}

if (chip_build_tools) {
Expand Down
24 changes: 23 additions & 1 deletion scripts/build_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ CHIP_ROOT=$(_normpath "$(dirname "$0")/..")
OUTPUT_ROOT="$CHIP_ROOT/out/coverage"
COVERAGE_ROOT="$OUTPUT_ROOT/coverage"
skip_gn=false
run_yaml=false

help() {

echo "Usage: $file_name [ options ... ]"

echo "General Options:
-h, --help Display this information.
-f, --full Run both yaml and unit tests for unified coverage.
Input Options:
-o, --output_root Set the build output directory. When set manually, performs only lcov stage
on provided build output. Assumes output_root has been built with 'use_coverage=true'
Expand All @@ -68,6 +70,9 @@ while (($#)); do
help
exit 1
;;
--full | -f)
run_yaml=true
;;
--output_root | -o)
OUTPUT_ROOT=$2
COVERAGE_ROOT="$OUTPUT_ROOT/coverage"
Expand All @@ -88,10 +93,27 @@ source "$CHIP_ROOT/scripts/activate.sh"

# Generates ninja files
if [ "$skip_gn" == false ]; then
gn --root="$CHIP_ROOT" gen "$OUTPUT_ROOT" --args='use_coverage=true'
gn --root="$CHIP_ROOT" gen "$OUTPUT_ROOT" --args='use_coverage=true chip_build_all_clusters_app=true'
ninja -C "$OUTPUT_ROOT"
fi

# Run unit tests
if [ "$skip_gn" == false ]; then
ninja -C "$OUTPUT_ROOT" check
fi

# Run yaml tests
if [ "$run_yaml" == true ]; then
scripts/run_in_build_env.sh \
"./scripts/tests/run_test_suite.py \
--chip-tool ""$OUTPUT_ROOT/chip-tool \
run \
--iterations 1 \
--test-timeout-seconds 120 \
--all-clusters-app ""$OUTPUT_ROOT/chip-all-clusters-app
"
fi

# Remove unit test itself from coverage statistics
find "$OUTPUT_ROOT/obj/src/" -depth -name 'tests' -exec rm -rf {} \;

Expand Down

0 comments on commit 1278128

Please sign in to comment.