mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-26 22:52:34 +02:00
tests: Add llvm-cov option and run target for code coverage
Code coverage can be requested with -Dllvm_cov and run with ninja llvm-cov-tests or llvm-cov-cli. BUG=b:187647884 BRANCH=None TEST=meson test; ninja llvm-cov-tests TEST=ran test_build.sh with coverage enabled TEST=jenkins ran test_build.sh with coverage disabled Change-Id: Id6c73bff46e7b88d425956a80def97082b201f56 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/69268 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
parent
80408ceafc
commit
048aab6d66
@ -63,12 +63,9 @@ ninja -C buildcov coverage
|
|||||||
#### llvm
|
#### llvm
|
||||||
https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
|
https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
|
||||||
```
|
```
|
||||||
env CFLAGS="-fprofile-instr-generate -fcoverage-mapping" CC=clang meson setup buildclangcov
|
env CC=clang meson setup buildclangcov -Dllvm_cov=enabled
|
||||||
env LLVM_PROFILE_FILE=default.profraw ninja -C buildclangcov test
|
ninja -C buildclangcov test
|
||||||
cd buildclangcov
|
ninja -C buildclangcov llvm-cov-tests
|
||||||
llvm-profdata merge -sparse default.profraw -o default.profdata
|
|
||||||
llvm-cov show ./flashrom_unit_tests -instr-profile=default.profdata --format=html --output-dir=.
|
|
||||||
open index.html
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## System specific information
|
## System specific information
|
||||||
|
14
meson.build
14
meson.build
@ -45,6 +45,7 @@ config_default_programmer_name = get_option('default_programmer_name')
|
|||||||
config_default_programmer_args = get_option('default_programmer_args')
|
config_default_programmer_args = get_option('default_programmer_args')
|
||||||
|
|
||||||
cargs = []
|
cargs = []
|
||||||
|
link_args = []
|
||||||
deps = []
|
deps = []
|
||||||
srcs = files(
|
srcs = files(
|
||||||
'82802ab.c',
|
'82802ab.c',
|
||||||
@ -539,6 +540,11 @@ endif
|
|||||||
|
|
||||||
cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"'
|
cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"'
|
||||||
|
|
||||||
|
if get_option('llvm_cov').enabled()
|
||||||
|
cargs += ['-fprofile-instr-generate', '-fcoverage-mapping']
|
||||||
|
link_args += ['-fprofile-instr-generate', '-fcoverage-mapping']
|
||||||
|
endif
|
||||||
|
|
||||||
install_headers([
|
install_headers([
|
||||||
'include/libflashrom.h',
|
'include/libflashrom.h',
|
||||||
],
|
],
|
||||||
@ -567,7 +573,7 @@ libflashrom = both_libraries(
|
|||||||
cargs,
|
cargs,
|
||||||
],
|
],
|
||||||
install : true,
|
install : true,
|
||||||
link_args : vflag,
|
link_args : link_args + [vflag],
|
||||||
link_depends : mapfile,
|
link_depends : mapfile,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -601,7 +607,7 @@ configure_file(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if get_option('classic_cli').auto() or get_option('classic_cli').enabled()
|
if get_option('classic_cli').auto() or get_option('classic_cli').enabled()
|
||||||
executable(
|
classic_cli = executable(
|
||||||
'flashrom',
|
'flashrom',
|
||||||
files(
|
files(
|
||||||
'cli_classic.c',
|
'cli_classic.c',
|
||||||
@ -612,8 +618,12 @@ if get_option('classic_cli').auto() or get_option('classic_cli').enabled()
|
|||||||
include_directories : include_dir,
|
include_directories : include_dir,
|
||||||
install : true,
|
install : true,
|
||||||
install_dir : get_option('sbindir'),
|
install_dir : get_option('sbindir'),
|
||||||
|
link_args : link_args,
|
||||||
link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom
|
link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom
|
||||||
)
|
)
|
||||||
|
if get_option('llvm_cov').enabled()
|
||||||
|
run_target('llvm-cov-cli', command : ['scripts/llvm-cov', classic_cli])
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('ich_descriptors_tool').auto() or get_option('ich_descriptors_tool').enabled()
|
if get_option('ich_descriptors_tool').auto() or get_option('ich_descriptors_tool').enabled()
|
||||||
|
@ -16,3 +16,4 @@ option('programmer', type : 'array', value : ['auto'], choices : [
|
|||||||
'pickit2_spi', 'pony_spi', 'raiden_debug_spi', 'rayer_spi', 'realtek_mst_i2c_spi', 'satamv',
|
'pickit2_spi', 'pony_spi', 'raiden_debug_spi', 'rayer_spi', 'realtek_mst_i2c_spi', 'satamv',
|
||||||
'satasii', 'serprog', 'stlinkv3_spi', 'usbblaster_spi',
|
'satasii', 'serprog', 'stlinkv3_spi', 'usbblaster_spi',
|
||||||
], description: 'Active programmers')
|
], description: 'Active programmers')
|
||||||
|
option('llvm_cov', type : 'feature', value : 'disabled', description : 'build for llvm code coverage')
|
||||||
|
6
scripts/llvm-cov
Executable file
6
scripts/llvm-cov
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd "${MESON_BUILD_ROOT}"
|
||||||
|
llvm-profdata merge -sparse default.profraw -o default.profdata
|
||||||
|
llvm-cov show -instr-profile=default.profdata -format=html -output-dir=. "$@"
|
||||||
|
echo "file://${MESON_BUILD_ROOT}/index.html"
|
@ -121,7 +121,11 @@ flashrom_tests = executable('flashrom_unit_tests',
|
|||||||
'-U_FORTIFY_SOURCE',
|
'-U_FORTIFY_SOURCE',
|
||||||
],
|
],
|
||||||
export_dynamic : true,
|
export_dynamic : true,
|
||||||
link_args : mocks,
|
link_args : mocks + link_args,
|
||||||
dependencies : [cmocka_dep, flashrom_test_dep],
|
dependencies : [cmocka_dep, flashrom_test_dep],
|
||||||
)
|
)
|
||||||
test('cmocka test flashrom', flashrom_tests)
|
test('cmocka test flashrom', flashrom_tests)
|
||||||
|
|
||||||
|
if get_option('llvm_cov').enabled()
|
||||||
|
run_target('llvm-cov-tests', command : ['../scripts/llvm-cov', flashrom_tests])
|
||||||
|
endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user