diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 1232f213e90c94a09004419d1ed60ebe189f42ea..f67713b3ae852f116f4b06014bbafec0e4ae7ce5 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -1876,6 +1876,11 @@ function main() { cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number} parallel_test ;; + check_xpu_coverage) + cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number} + parallel_test + check_coverage + ;; cmake_gen) cmake_gen ${PYTHON_ABI:-""} ;; diff --git a/tools/coverage/paddle_coverage.sh b/tools/coverage/paddle_coverage.sh index 6cd107b58ed14581f4830ed5308b16bc6dbbc689..471887ca213945de3d8a4649852fcb7168cffb1c 100644 --- a/tools/coverage/paddle_coverage.sh +++ b/tools/coverage/paddle_coverage.sh @@ -60,7 +60,31 @@ function gen_full_html_report() { mv -f coverage-full.tmp coverage-full.info } -gen_full_html_report || true +function gen_full_html_report_xpu() { + lcov --extract coverage.info \ + '/paddle/paddle/fluid/operators/*xpu*' \ + -o coverage-full.tmp \ + --rc lcov_branch_coverage=0 + + mv -f coverage-full.tmp coverage-full.info + + lcov --remove coverage-full.info \ + '/paddle/paddle/fluid/framework/*_test*' \ + '/paddle/paddle/fluid/*/*test*' \ + '/paddle/paddle/fluid/*/*/*test*' \ + '/paddle/paddle/fluid/inference/tests/*' \ + '/paddle/paddle/fluid/inference/api/demo_ci/*' \ + -o coverage-full.tmp \ + --rc lcov_branch_coverage=0 + + mv -f coverage-full.tmp coverage-full.info +} + +if [ ${WITH_XPU:-OFF} == "ON" ]; then + gen_full_html_report_xpu || true +else + gen_full_html_report || true +fi # diff html report @@ -154,7 +178,11 @@ python3.7 ${PADDLE_ROOT}/tools/coverage/coverage_lines.py coverage-diff.info 0.9 echo "Assert Python Diff Coverage" -python3.7 ${PADDLE_ROOT}/tools/coverage/coverage_lines.py python-coverage-diff.info 0.9 || PYTHON_COVERAGE_LINES_ASSERT=1 +if [ ${WITH_XPU:-OFF} == "ON" ]; then + echo "XPU has no python coverage!" +else + python3.7 ${PADDLE_ROOT}/tools/coverage/coverage_lines.py python-coverage-diff.info 0.9 || PYTHON_COVERAGE_LINES_ASSERT=1 +fi if [ "$COVERAGE_LINES_ASSERT" = "1" ] || [ "$PYTHON_COVERAGE_LINES_ASSERT" = "1" ]; then echo "exit 9" > /tmp/paddle_coverage.result diff --git a/tools/test_runner.py b/tools/test_runner.py index 248819a8d475eeab8072d76fe23b78a070bbc481..2d0c9c4a131c9304930f2ddf6f841387afaa8648 100644 --- a/tools/test_runner.py +++ b/tools/test_runner.py @@ -21,6 +21,8 @@ import paddle import paddle.fluid as fluid import importlib from six.moves import cStringIO + +sys.path.append(os.path.abspath(os.path.dirname(__file__))) import static_mode_white_list