mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 02:48:57 +08:00
add mode asan,lsan,msan,tsan for test
This commit is contained in:
parent
df608c43b0
commit
a9ad514fb8
5
.gitignore
vendored
5
.gitignore
vendored
@ -58,4 +58,7 @@ vs2017
|
||||
vs2019
|
||||
vs2010
|
||||
vs2013
|
||||
vs2015
|
||||
vs2015
|
||||
cover_report
|
||||
cover*.info
|
||||
*.gcno
|
@ -1,5 +1,5 @@
|
||||
target("hikyuu")
|
||||
if is_mode("debug") then
|
||||
if is_mode("debug", "coverage", "asan", "msan", "tsan", "lsan") then
|
||||
set_kind("static")
|
||||
else
|
||||
set_kind("shared")
|
||||
|
@ -1,5 +1,41 @@
|
||||
add_requires("doctest")
|
||||
|
||||
function coverage_report(target)
|
||||
if is_mode("coverage") and not is_plat("windows") and not (linuxos.name() == "ubuntu" and linuxos.version():lt("20.0")) then
|
||||
-- 如需分支覆盖,须在下面 lcov, genhtml 命令后都加入: --rc lcov_branch_coverage=1
|
||||
print("Processing coverage info ...")
|
||||
|
||||
if not os.isfile("cover-init.info") then
|
||||
-- 初始化并创建基准数据文件
|
||||
os.run("lcov -c -i -d ./ -o cover-init.info")
|
||||
end
|
||||
|
||||
-- 移除之前的结果,否则容易出错
|
||||
os.tryrm('cover.info')
|
||||
os.tryrm('cover-total.info')
|
||||
|
||||
-- 收集当前测试文件运行后产生的覆盖率文件
|
||||
os.run("lcov -c -d ./ -o cover.info")
|
||||
|
||||
-- 合并基准数据和执行测试文件后生成的覆盖率数据
|
||||
os.exec("lcov -a cover-init.info -a cover.info -o cover-total.info")
|
||||
|
||||
-- 删除统计信息中如下的代码或文件,支持正则
|
||||
os.run("lcov --remove cover-total.info '*/usr/include/*' \
|
||||
'*/usr/lib/*' '*/usr/lib64/*' '*/usr/local/include/*' '*/usr/local/lib/*' '*/usr/local/lib64/*' \
|
||||
'*/test/*' '*/.xmake*' '*/boost/*' '*/ffmpeg/*' \
|
||||
'*/cpp/yihua/ocr_module/clipper.*' -o cover-final.info")
|
||||
|
||||
-- 生成的html及相关文件的目录名称,--legend 简单的统计信息说明
|
||||
os.exec("genhtml -o cover_report --legend --title 'yhsdk' --prefix=" .. os.projectdir() .. " cover-final.info")
|
||||
|
||||
-- 生成 sonar 可读取报告
|
||||
if is_plat("linux") then
|
||||
os.run("gcovr -r . -e cpp/test -e 'cpp/yihua/ocr_module/clipper.*' --xml -o coverage.xml")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
target("unit-test")
|
||||
set_kind("binary")
|
||||
set_default(false)
|
||||
@ -43,6 +79,7 @@ target("unit-test")
|
||||
-- add files
|
||||
add_files("**.cpp")
|
||||
|
||||
after_run(coverage_report)
|
||||
target_end()
|
||||
|
||||
target("small-test")
|
||||
@ -82,4 +119,6 @@ target("small-test")
|
||||
-- add files
|
||||
add_files("./hikyuu/hikyuu/**.cpp");
|
||||
add_files("./hikyuu/test_main.cpp")
|
||||
|
||||
after_run(coverage_report)
|
||||
target_end()
|
5
setup.py
5
setup.py
@ -99,6 +99,7 @@ def save_current_compile_info(compile_info):
|
||||
|
||||
def build_boost(mode):
|
||||
""" 编译依赖的 boost 库 """
|
||||
new_mode = 'release' if mode == 'release' else 'debug'
|
||||
current_boost_root, current_boost_lib = get_boost_envrionment()
|
||||
if current_boost_root == '' or current_boost_lib == '':
|
||||
print("Can't get boost environment!")
|
||||
@ -230,7 +231,7 @@ def cli():
|
||||
@click.option('-m',
|
||||
'--mode',
|
||||
default='release',
|
||||
type=click.Choice(['release', 'debug']),
|
||||
type=click.Choice(['release', 'debug', 'coverage', 'asan', 'tsan', 'msan', 'lsan']),
|
||||
help='编译模式')
|
||||
def build(verbose, mode, j):
|
||||
""" 执行编译 """
|
||||
@ -245,7 +246,7 @@ def build(verbose, mode, j):
|
||||
@click.option('-m',
|
||||
'--mode',
|
||||
default='release',
|
||||
type=click.Choice(['release', 'debug']),
|
||||
type=click.Choice(['release', 'debug', 'coverage', 'asan', 'msan', 'tsan', 'lsan']),
|
||||
help='编译模式')
|
||||
@click.option('-case', '--case', default='', help="执行指定的 TestCase")
|
||||
def test(all, compile, verbose, mode, case, j):
|
||||
|
Loading…
Reference in New Issue
Block a user