[Improvement](test) compute be full coverage (#23618)

This commit is contained in:
chunping
2023-08-30 10:21:32 +08:00
committed by GitHub
parent f786689044
commit 2a31a1e29b
2 changed files with 28 additions and 0 deletions

19
env.sh
View File

@ -144,6 +144,25 @@ elif [[ "${DORIS_TOOLCHAIN}" == "clang" ]]; then
if [[ -f "${DORIS_CLANG_HOME}/bin/llvm-symbolizer" ]]; then
export ASAN_SYMBOLIZER_PATH="${DORIS_CLANG_HOME}/bin/llvm-symbolizer"
fi
covs=()
while IFS='' read -r line; do covs+=("${line}"); done < <(find "${DORIS_CLANG_HOME}" -name "llvm-cov*")
if [[ ${#covs[@]} -ge 1 ]]; then
LLVM_COV="${covs[0]}"
else
LLVM_COV="$(command -v llvm-cov)"
fi
export LLVM_COV
profdatas=()
while IFS='' read -r line; do profdatas+=("${line}"); done < <(find "${DORIS_CLANG_HOME}" -name "llvm-profdata*")
if [[ ${#profdatas[@]} -ge 1 ]]; then
LLVM_PROFDATA="${profdatas[0]}"
else
LLVM_PROFDATA="$(command -v llvm-profdata)"
fi
export LLVM_PROFDATA
if [[ -z "${ENABLE_PCH}" ]]; then
ENABLE_PCH='ON'
fi

View File

@ -381,11 +381,20 @@ export JAVA_OPTS="-Xmx1024m -DlogPath=${DORIS_HOME}/log/jni.log -Xloggc:${DORIS_
# find all executable test files
test="${DORIS_TEST_BINARY_DIR}/doris_be_test"
profraw=${DORIS_TEST_BINARY_DIR}/doris_be_test.profraw
profdata=${DORIS_TEST_BINARY_DIR}/doris_be_test.profdata
file_name="${test##*/}"
if [[ -f "${test}" ]]; then
if [[ "_${DENABLE_CLANG_COVERAGE}" == "_ON" ]]; then
LLVM_PROFILE_FILE="${profraw}" "${test}" --gtest_output="xml:${GTEST_OUTPUT_DIR}/${file_name}.xml" --gtest_print_time=true "${FILTER}"
if [[ -d "${DORIS_TEST_BINARY_DIR}"/report ]]; then
rm -rf "${DORIS_TEST_BINARY_DIR}"/report
fi
"${LLVM_PROFDATA} merge -o ${profdata} ${profraw}"
"${LLVM_COV} show -output-dir=${DORIS_TEST_BINARY_DIR}/report -format=html \
-ignore-filename-regex='(.*gensrc/.*)|(.*_test\.cpp$)|(.*be/test.*)|(.*apache-orc/.*)|(.*clucene/.*)' \
-instr-profile=${profdata} \
-object=${test}"
else
"${test}" --gtest_output="xml:${GTEST_OUTPUT_DIR}/${file_name}.xml" --gtest_print_time=true "${FILTER}"
fi