collect C++ code coverage (#23619)
* collect cpp coverage * install llvm * compile with coverage * cd to root * remove broken gcda files * remove newline * delete more stuff * script to collect coverage * Update tools/collect_coverage.sh * actually deletepull/23626/head
parent
ea2da86e81
commit
698ab6ac97
|
@ -209,7 +209,7 @@ jobs:
|
||||||
run: eval "$BUILD"
|
run: eval "$BUILD"
|
||||||
- name: Run valgrind
|
- name: Run valgrind
|
||||||
run: |
|
run: |
|
||||||
${{ env.RUN }} "scons -j$(nproc) && \
|
${{ env.RUN }} "scons -j$(nproc) --coverage && \
|
||||||
FILEREADER_CACHE=1 python selfdrive/test/test_valgrind_replay.py"
|
FILEREADER_CACHE=1 python selfdrive/test/test_valgrind_replay.py"
|
||||||
- name: Print logs
|
- name: Print logs
|
||||||
if: always()
|
if: always()
|
||||||
|
@ -244,7 +244,7 @@ jobs:
|
||||||
run: eval "$BUILD"
|
run: eval "$BUILD"
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: |
|
run: |
|
||||||
${{ env.RUN }} "scons -j$(nproc) --test && \
|
${{ env.RUN }} "scons -j$(nproc) --test --coverage && \
|
||||||
coverage run selfdrive/test/test_fingerprints.py && \
|
coverage run selfdrive/test/test_fingerprints.py && \
|
||||||
$UNIT_TEST common && \
|
$UNIT_TEST common && \
|
||||||
$UNIT_TEST opendbc/can && \
|
$UNIT_TEST opendbc/can && \
|
||||||
|
@ -265,7 +265,7 @@ jobs:
|
||||||
./selfdrive/proclogd/tests/test_proclog && \
|
./selfdrive/proclogd/tests/test_proclog && \
|
||||||
./selfdrive/ui/replay/tests/test_replay && \
|
./selfdrive/ui/replay/tests/test_replay && \
|
||||||
./selfdrive/camerad/test/ae_gray_test && \
|
./selfdrive/camerad/test/ae_gray_test && \
|
||||||
coverage xml"
|
tools/collect_coverage.sh"
|
||||||
- name: "Upload coverage to Codecov"
|
- name: "Upload coverage to Codecov"
|
||||||
uses: codecov/codecov-action@v2
|
uses: codecov/codecov-action@v2
|
||||||
|
|
||||||
|
@ -299,9 +299,9 @@ jobs:
|
||||||
run: eval "$BUILD"
|
run: eval "$BUILD"
|
||||||
- name: Run replay
|
- name: Run replay
|
||||||
run: |
|
run: |
|
||||||
${{ env.RUN }} "scons -j$(nproc) && \
|
${{ env.RUN }} "scons -j$(nproc) --coverage && \
|
||||||
FILEREADER_CACHE=1 CI=1 coverage run selfdrive/test/process_replay/test_processes.py && \
|
FILEREADER_CACHE=1 CI=1 coverage run selfdrive/test/process_replay/test_processes.py && \
|
||||||
coverage xml"
|
tools/collect_coverage.sh"
|
||||||
- name: "Upload coverage to Codecov"
|
- name: "Upload coverage to Codecov"
|
||||||
uses: codecov/codecov-action@v2
|
uses: codecov/codecov-action@v2
|
||||||
- name: Print diff
|
- name: Print diff
|
||||||
|
@ -354,10 +354,12 @@ jobs:
|
||||||
- name: Test longitudinal
|
- name: Test longitudinal
|
||||||
run: |
|
run: |
|
||||||
${{ env.RUN }} "mkdir -p selfdrive/test/out && \
|
${{ env.RUN }} "mkdir -p selfdrive/test/out && \
|
||||||
scons -j$(nproc) && \
|
scons -j$(nproc) --coverage && \
|
||||||
cd selfdrive/test/longitudinal_maneuvers && \
|
cd selfdrive/test/longitudinal_maneuvers && \
|
||||||
coverage run ./test_longitudinal.py && \
|
coverage run ./test_longitudinal.py && \
|
||||||
coverage xml"
|
coverage xml && \
|
||||||
|
cd ../../.. && \
|
||||||
|
tools/collect_coverage.sh"
|
||||||
- name: "Upload coverage to Codecov"
|
- name: "Upload coverage to Codecov"
|
||||||
uses: codecov/codecov-action@v2
|
uses: codecov/codecov-action@v2
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
|
@ -401,9 +403,9 @@ jobs:
|
||||||
run: eval "$BUILD"
|
run: eval "$BUILD"
|
||||||
- name: Test car models
|
- name: Test car models
|
||||||
run: |
|
run: |
|
||||||
${{ env.RUN }} "scons -j$(nproc) --test && \
|
${{ env.RUN }} "scons -j$(nproc) --test --coverage && \
|
||||||
FILEREADER_CACHE=1 coverage run -m pytest selfdrive/test/test_models.py && \
|
FILEREADER_CACHE=1 coverage run -m pytest selfdrive/test/test_models.py && \
|
||||||
coverage xml && \
|
tools/collect_coverage.sh && \
|
||||||
chmod -R 777 /tmp/comma_download_cache"
|
chmod -R 777 /tmp/comma_download_cache"
|
||||||
env:
|
env:
|
||||||
NUM_JOBS: 4
|
NUM_JOBS: 4
|
||||||
|
|
|
@ -83,3 +83,7 @@ models/*.thneed
|
||||||
build/
|
build/
|
||||||
|
|
||||||
!**/.gitkeep
|
!**/.gitkeep
|
||||||
|
|
||||||
|
*.gcno
|
||||||
|
*.gcda
|
||||||
|
coverage.info
|
||||||
|
|
13
SConstruct
13
SConstruct
|
@ -52,6 +52,11 @@ AddOption('--no-thneed',
|
||||||
dest='no_thneed',
|
dest='no_thneed',
|
||||||
help='avoid using thneed')
|
help='avoid using thneed')
|
||||||
|
|
||||||
|
AddOption('--coverage',
|
||||||
|
action='store_true',
|
||||||
|
dest='coverage',
|
||||||
|
help='outpute covarge information')
|
||||||
|
|
||||||
real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
|
real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
|
||||||
if platform.system() == "Darwin":
|
if platform.system() == "Darwin":
|
||||||
arch = "Darwin"
|
arch = "Darwin"
|
||||||
|
@ -168,6 +173,10 @@ else:
|
||||||
ccflags = []
|
ccflags = []
|
||||||
ldflags = []
|
ldflags = []
|
||||||
|
|
||||||
|
if GetOption('coverage'):
|
||||||
|
ccflags += ["-fprofile-arcs", "-ftest-coverage"]
|
||||||
|
ldflags += ["-fprofile-arcs", "-ftest-coverage"]
|
||||||
|
|
||||||
# no --as-needed on mac linker
|
# no --as-needed on mac linker
|
||||||
if arch != "Darwin":
|
if arch != "Darwin":
|
||||||
ldflags += ["-Wl,--as-needed", "-Wl,--no-undefined"]
|
ldflags += ["-Wl,--as-needed", "-Wl,--no-undefined"]
|
||||||
|
@ -285,6 +294,10 @@ elif arch == "aarch64":
|
||||||
else:
|
else:
|
||||||
envCython["LINKFLAGS"] = ["-pthread", "-shared"]
|
envCython["LINKFLAGS"] = ["-pthread", "-shared"]
|
||||||
|
|
||||||
|
if GetOption('coverage'):
|
||||||
|
envCython['CCFLAGS'] += ["-fprofile-arcs", "-ftest-coverage"]
|
||||||
|
envCython['LINKFLAGS'] += ["-fprofile-arcs", "-ftest-coverage"]
|
||||||
|
|
||||||
Export('envCython')
|
Export('envCython')
|
||||||
|
|
||||||
# Qt build environment
|
# Qt build environment
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
find opendbc/can/dbc_out -name "*.gcda" -delete
|
||||||
|
find rednose/helpers -name "*.gcda" -delete
|
||||||
|
find rednose_repo/rednose/helpers -name "*.gcda" -delete
|
||||||
|
find cereal/gen -name "*.gcda" -delete
|
||||||
|
|
||||||
|
lcov --capture --directory . --gcov-tool tools/gcov_for_clang.sh --output-file coverage.info
|
||||||
|
lcov --remove coverage.info '*/third_party/*' --output-file coverage.info
|
||||||
|
lcov --remove coverage.info '/usr/*' --output-file coverage.info
|
||||||
|
|
||||||
|
coverage xml || true
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
exec llvm-cov gcov "$@"
|
|
@ -31,8 +31,9 @@ function install_ubuntu_common_requirements() {
|
||||||
git \
|
git \
|
||||||
git-lfs \
|
git-lfs \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
libavformat-dev \
|
lcov \
|
||||||
libavcodec-dev \
|
libavcodec-dev \
|
||||||
|
libavformat-dev \
|
||||||
libavdevice-dev \
|
libavdevice-dev \
|
||||||
libavutil-dev \
|
libavutil-dev \
|
||||||
libavfilter-dev \
|
libavfilter-dev \
|
||||||
|
@ -50,6 +51,7 @@ function install_ubuntu_common_requirements() {
|
||||||
libusb-1.0-0-dev \
|
libusb-1.0-0-dev \
|
||||||
libzmq3-dev \
|
libzmq3-dev \
|
||||||
libsystemd-dev \
|
libsystemd-dev \
|
||||||
|
llvm \
|
||||||
locales \
|
locales \
|
||||||
opencl-headers \
|
opencl-headers \
|
||||||
ocl-icd-libopencl1 \
|
ocl-icd-libopencl1 \
|
||||||
|
|
Loading…
Reference in New Issue