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

Add instructions and scripts on how to generate a coverage report #8889

Open
JaySon-Huang opened this issue Apr 1, 2024 · 0 comments
Open
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@JaySon-Huang
Copy link
Contributor

JaySon-Huang commented Apr 1, 2024

Enhancement

https://github.com/pingcap/tiflash/blob/739d1685ab787b0f926afe8d43e15fffc2aa2926/README.md#generate-llvm-coverage-report

Reference: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html

A possible scripts

set -x

## Reference: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html

PROF_DIR="/DATA/disk1/jaysonhuang/tiflash/cmake-build-debug-cov"
# Build the testing binary
cd ${PROF_DIR} && cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DTEST_LLVM_COVERAGE=ON && ninja -j 32 gtests_dbms && cd -

# Run the testing binary and generate prof raw data
#LLVM_PROFILE_FILE="${PROF_DIR}/gtest_dbms.profraw" ${PROF_DIR}/dbms/gtests_dbms --gtest_filter='*DeltaMergeStore*:*DMFile*:*Segment*' 2>&1 | tee ${PROF_DIR}/coverage_test.output.log
LLVM_PROFILE_FILE="${PROF_DIR}/gtest_dbms.profraw" ${PROF_DIR}/dbms/gtests_dbms 2>&1 | tee ${PROF_DIR}/coverage_test.output.log


# Collect the prof raw data and generate cov report
llvm-profdata merge -sparse ${PROF_DIR}/*.profraw -o ${PROF_DIR}/merged.profdata

TEST_BIN_PATH="${PROF_DIR}"
TEST_BINS="${TEST_BIN_PATH}/dbms/gtests_dbms"
                    
export LD_LIBRARY_PATH=.
llvm-cov export \
    ${TEST_BINS} \
    --format=lcov \
    --instr-profile ${PROF_DIR}/merged.profdata \
    --ignore-filename-regex "/usr/include/.*" \
    --ignore-filename-regex "/usr/local/.*" \
    --ignore-filename-regex "/usr/lib/.*" \
    --ignore-filename-regex ".*/contrib/.*" \
    --ignore-filename-regex ".*/dbms/src/Debug/.*" \
    --ignore-filename-regex ".*/dbms/src/Client/.*" \
    > ${PROF_DIR}/lcov.info

mkdir -p "${PROF_DIR}/report"
genhtml "${PROF_DIR}/lcov.info" -o "${PROF_DIR}/report/" --ignore-errors source


@JaySon-Huang JaySon-Huang added the type/enhancement The issue or PR belongs to an enhancement. label Apr 1, 2024
ti-chi-bot bot pushed a commit that referenced this issue Apr 10, 2024
Lloyd-Pottiger pushed a commit to Lloyd-Pottiger/tiflash that referenced this issue Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant