Add instructions and scripts on how to generate a coverage report
Open
Nobody has claimed this yet.
type/enhancement
- Dominant language
- C++
- Stars
- 1k
- Forks
- 423
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 24
Description
Enhancement
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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