From cd0ca6727a7274600608dd70eb640d30a83be6c1 Mon Sep 17 00:00:00 2001 From: groot Date: Fri, 17 Sep 2021 18:21:52 +0800 Subject: [PATCH] [skip ci] Update cpp codecov script (#8158) Signed-off-by: yhmo --- scripts/run_cpp_codecov.sh | 79 +++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/scripts/run_cpp_codecov.sh b/scripts/run_cpp_codecov.sh index f7788f401b..65119e8cd9 100755 --- a/scripts/run_cpp_codecov.sh +++ b/scripts/run_cpp_codecov.sh @@ -10,75 +10,66 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done ROOT_DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" -MILVUS_CORE_DIR="${ROOT_DIR}/internal/core" -CORE_INSTALL_PREFIX="${MILVUS_CORE_DIR}/output" -UNITTEST_DIRS=("${CORE_INSTALL_PREFIX}/unittest") -CWRAPPER_UNITTEST="${ROOT_DIR}/internal/storage/cwrapper/output/wrapper_test" +MILVUS_CORE_DIR="${ROOT_DIR}/internal/core/" +MILVUS_CORE_UNITTEST_DIR="${MILVUS_CORE_DIR}/output/unittest/" echo "ROOT_DIR = ${ROOT_DIR}" echo "MILVUS_CORE_DIR = ${MILVUS_CORE_DIR}" -echo "CORE_INSTALL_PREFIX = ${CORE_INSTALL_PREFIX}" -echo "UNITTEST_DIRS = ${UNITTEST_DIRS}" -echo "CWRAPPER_UNITTEST = ${CWRAPPER_UNITTEST}" - -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${CORE_INSTALL_PREFIX}/lib -echo "LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}" +echo "MILVUS_CORE_UNITTEST_DIR = ${MILVUS_CORE_UNITTEST_DIR}" LCOV_CMD="lcov" LCOV_GEN_CMD="genhtml" -FILE_INFO_BASE="base.info" -FILE_INFO_MILVUS="server.info" -FILE_INFO_OUTPUT="output.info" -FILE_INFO_OUTPUT_NEW="output_new.info" -DIR_LCOV_OUTPUT="${ROOT_DIR}/lcov_out" - -DIR_GCNO="${ROOT_DIR}/cmake_build" -DIR_UNITTEST="${CORE_INSTALL_PREFIX}/unittest" +FILE_INFO_BASE="${ROOT_DIR}/lcov_base.info" +FILE_INFO_UT="${ROOT_DIR}/lcov_ut.info" +FILE_INFO_COMBINE="${ROOT_DIR}/lcov_combine.info" +FILE_INFO_OUTPUT="${ROOT_DIR}/lcov_output.info" +DIR_LCOV_OUTPUT="${ROOT_DIR}/lcov_html" +DIR_GCNO="${ROOT_DIR}/cmake_build/" # delete old code coverage info files -rm -f FILE_INFO_BASE -rm -f FILE_INFO_MILVUS -rm -f FILE_INFO_OUTPUT -rm -f FILE_INFO_OUTPUT_NEW -rm -rf lcov_out -rm -f FILE_INFO_BASE FILE_INFO_MILVUS FILE_INFO_OUTPUT FILE_INFO_OUTPUT_NEW +rm -f ${FILE_INFO_BASE} +rm -f ${FILE_INFO_UT} +rm -f ${FILE_INFO_COMBINE} +rm -f ${FILE_INFO_OUTPUT} +rm -rf ${DIR_LCOV_OUTPUT} - -# get baseline -${LCOV_CMD} -c -i -d ${DIR_GCNO} -o "${FILE_INFO_BASE}" +# generate baseline +${LCOV_CMD} -c -i -d ${DIR_GCNO} -o ${FILE_INFO_BASE} if [ $? -ne 0 ]; then echo "gen baseline coverage run failed" exit -1 fi -for test in `ls ${DIR_UNITTEST}`; do - echo $test +# run unittest +for test in `ls ${MILVUS_CORE_UNITTEST_DIR}`; do + echo "${MILVUS_CORE_UNITTEST_DIR}/$test" # run unittest - ${DIR_UNITTEST}/${test} + ${MILVUS_CORE_UNITTEST_DIR}/${test} if [ $? -ne 0 ]; then echo ${args} - echo ${DIR_UNITTEST}/${test} "run failed" + echo ${${MILVUS_CORE_UNITTEST_DIR}/}/${test} "run failed" exit -1 fi done -# gen code coverage -${LCOV_CMD} -d ${DIR_GCNO} -o "${FILE_INFO_MILVUS}" -c -# merge coverage -${LCOV_CMD} -a ${FILE_INFO_BASE} -a ${FILE_INFO_MILVUS} -o "${FILE_INFO_OUTPUT}" +# generate ut file +${LCOV_CMD} -c -d ${DIR_GCNO} -o ${FILE_INFO_UT} -# remove third party from tracefiles -${LCOV_CMD} -r "${FILE_INFO_OUTPUT}" -o "${FILE_INFO_OUTPUT_NEW}" \ +# merge baseline and ut file +${LCOV_CMD} -a ${FILE_INFO_BASE} -a ${FILE_INFO_UT} -o ${FILE_INFO_COMBINE} + +# remove unnecessary info +${LCOV_CMD} -r "${FILE_INFO_COMBINE}" -o "${FILE_INFO_OUTPUT}" \ "/usr/*" \ + "*/src/pb/*" \ + "*/src/core/bench/*" \ + "*/faiss_ep-prefix/*" \ "*/boost/*" \ - "*/cmake_build/*" \ + "*/unittest/*" \ "*/thirdparty/*" -if [ $? -ne 0 ]; then - echo "generate ${FILE_INFO_OUTPUT_NEW} failed" - exit -2 -fi -# gen html report -${LCOV_GEN_CMD} "${FILE_INFO_OUTPUT_NEW}" --output-directory ${DIR_LCOV_OUTPUT}/ +# generate html report +${LCOV_GEN_CMD} ${FILE_INFO_OUTPUT} --output-directory ${DIR_LCOV_OUTPUT}/ +