linglong/scripts/code_coverage.sh

34 lines
872 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 此脚本生成行覆盖率报告路径build/coverage/coverage_report/index.html
dpkg -l | grep lcov
if [ $? -eq 0 ];
then
echo "lcov is install"
else
echo "lcov is not install"
sudo apt install -y lcov
fi
cd ../
if [ ! -d "build" ];then
mkdir build
else
rm -rf build && mkdir build
fi
unset https_proxy http_proxy
cd build && rm -rf ./* && clear && cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make -j12 && sudo make install && sudo ../debian/postinst
cd test
./ll-test
cd ../../
REPORT_FOLDER=build/coverage/coverage_report
mkdir -p ${REPORT_FOLDER}
COVERAGE_FILE=build/coverage/coverage.info
lcov --rc lcov_branch_coverage=1 -c -d build/test/CMakeFiles/ll-test.dir -o ${COVERAGE_FILE}_tmp
lcov --rc lcov_branch_coverage=1 -e ${COVERAGE_FILE}_tmp "*src*" -o ${COVERAGE_FILE}
genhtml --rc genhtml_branch_coverage=1 ${COVERAGE_FILE} -o ${REPORT_FOLDER}