Skip to content

Commit

Permalink
Scripts to generate unit test coverage reports (#708)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Foster <[email protected]>
  • Loading branch information
ffoulkes authored Nov 4, 2024
1 parent bd7f495 commit cdd01f3
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 0 deletions.
48 changes: 48 additions & 0 deletions scripts/dpdk/report-krnlmon-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
#
# Copyright 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# Reports unit test code coverage for KRNLMON on DPDK.
#
# You must build the tests with coverage enabled before
# running this script. For example:
#
# cmake -B build -C dpdk.cmake -DTEST_COVERAGE=ON
# cmake --build build -j5 --target krnlmon-unit-tests
#

set -e

# Folder under which to search for .gcda files.
INPUT_DIR=build/krnlmon/krnlmon/

# Folder in which the report will be generated.
OUTPUT_DIR=build/Coverage/krnlmon/dpdk

# Label identifying the tests to report on.
TEST_LABEL=krnlmon

# Select tests with the specified label, run the tests,
# and compute coverage of the source code.
(cd build; ctest -L ${TEST_LABEL} -T test -T coverage)

# Make sure the output directory exists.
mkdir -p ${OUTPUT_DIR}

# Empty it for good measure.
rm -fr ${OUTPUT_DIR:?}/*

# Capture the coverage data, excluding files in directories
# that don't interest us.
lcov --capture \
--directory ${INPUT_DIR} \
--output-file ${OUTPUT_DIR}/coverage.info \
--exclude '/opt/deps/*' \
--exclude '/usr/include/*'

# Generate html coverage report.
genhtml ${OUTPUT_DIR}/coverage.info \
--output-directory ${OUTPUT_DIR}

echo "Coverage report is in ${OUTPUT_DIR}."
48 changes: 48 additions & 0 deletions scripts/dpdk/report-ovsp4rt-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
#
# Copyright 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# Reports unit test code coverage for OVSP4RT on DPDK.
#
# You must build the tests with coverage enabled before
# running this script. For example:
#
# cmake -B build -C dpdk.cmake -DTEST_COVERAGE=ON
# cmake --build build -j5 --target ovsp4rt-unit-tests
#

set -e

# Folder under which to search for .gcda files.
INPUT_DIR=build/ovs-p4rt/sidecar/

# Folder in which the report will be generated.
OUTPUT_DIR=build/Coverage/ovsp4rt/dpdk

# Label identifying the tests to report on.
TEST_LABEL=ovsp4rt

# Select tests with the specified label, run the tests,
# and compute coverage of the source code.
(cd build; ctest -L ${TEST_LABEL} -T test -T coverage)

# Make sure the output directory exists.
mkdir -p ${OUTPUT_DIR}

# Empty it for good measure.
rm -fr ${OUTPUT_DIR:?}/*

# Capture the coverage data, excluding files in directories
# that don't interest us.
lcov --capture \
--directory ${INPUT_DIR} \
--output-file ${OUTPUT_DIR}/coverage.info \
--exclude '/opt/deps/*' \
--exclude '/usr/include/*'

# Generate html coverage report.
genhtml ${OUTPUT_DIR}/coverage.info \
--output-directory ${OUTPUT_DIR}

echo "Coverage report is in ${OUTPUT_DIR}."
48 changes: 48 additions & 0 deletions scripts/es2k/report-krnlmon-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
#
# Copyright 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# Reports unit test code coverage for KRNLMON on ES2K.
#
# You must build the tests with coverage enabled before
# running this script. For example:
#
# cmake --preset es2k -DTEST_COVERAGE=ON
# cmake --build build -j5 --target krnlmon-unit-tests
#

set -e

# Folder under which to search for .gcda files.
INPUT_DIR=build/krnlmon/krnlmon/

# Folder in which the report will be generated.
OUTPUT_DIR=build/Coverage/krnlmon/es2k

# Label identifying the tests to report on.
TEST_LABEL=krnlmon

# Select tests with the specified label, run the tests,
# and compute coverage of the source code.
(cd build; ctest -L ${TEST_LABEL} -T test -T coverage)

# Make sure the output directory exists.
mkdir -p ${OUTPUT_DIR}

# Empty it for good measure.
rm -fr ${OUTPUT_DIR:?}/*

# Capture the coverage data, excluding files in directories
# that don't interest us.
lcov --capture \
--directory ${INPUT_DIR} \
--output-file ${OUTPUT_DIR}/coverage.info \
--exclude '/opt/deps/*' \
--exclude '/usr/include/*'

# Generate html coverage report.
genhtml ${OUTPUT_DIR}/coverage.info \
--output-directory ${OUTPUT_DIR}

echo "Coverage report is in ${OUTPUT_DIR}."
48 changes: 48 additions & 0 deletions scripts/es2k/report-ovsp4rt-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
#
# Copyright 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# Reports unit test code coverage for OVSP4RT on ES2K.
#
# You must build the tests with coverage enabled before
# running this script. For example:
#
# cmake --preset es2k -DTEST_COVERAGE=ON
# cmake --build build -j5 --target ovsp4rt-unit-tests
#

set -e

# Folder under which to search for .gcda files.
INPUT_DIR=build/ovs-p4rt/sidecar/

# Folder in which the report will be generated.
OUTPUT_DIR=build/Coverage/ovsp4rt/es2k

# Label identifying the tests to report on.
TEST_LABEL=ovsp4rt

# Select tests with the specified label, run the tests,
# and compute coverage of the source code.
(cd build; ctest -L ${TEST_LABEL} -T test -T coverage)

# Make sure the output directory exists.
mkdir -p ${OUTPUT_DIR}

# Empty it for good measure.
rm -fr ${OUTPUT_DIR:?}/*

# Capture the coverage data, excluding files in directories
# that don't interest us.
lcov --capture \
--directory ${INPUT_DIR} \
--output-file ${OUTPUT_DIR}/coverage.info \
--exclude '/opt/deps/*' \
--exclude '/usr/include/*'

# Generate html coverage report.
genhtml ${OUTPUT_DIR}/coverage.info \
--output-directory ${OUTPUT_DIR}

echo "Coverage report is in ${OUTPUT_DIR}."

0 comments on commit cdd01f3

Please sign in to comment.