pingcap / pingcap/tiflash

Add instructions and scripts on how to generate a coverage report

Open
#8,889 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/enhancement
Dominant language
C++
Stars
1k
Forks
423
Avg merge
1d 15h
Merged PRs (30d)
24

Description

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


Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the README.md coverage section linked in the issue and the referenced LLVM source-based coverage documentation. Turn the proposed build, test, llvm-profdata, llvm-cov, and genhtml commands into documented instructions and scripts that work for the project; done means a contributor can generate an HTML coverage report.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, shell
Domain
documentation, testing
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.