并行运行时使用 gcov 的代码覆盖率 [英] Code coverage using gcov on parallel run

查看:110
本文介绍了并行运行时使用 gcov 的代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 gcov 为项目中的几个文件设置了 C/C++ 代码覆盖率.可执行文件并行运行.这会导致一些共享代码并行运行.

I have C/C++ code coverage setup with gcov for several files in the project. The executables are being run in parallel. This results in some shared piece of code to be run in parallel.

我收到损坏的 .da 文件或零大小的 .da 文件.这是并行运行的问题吗?

I am getting corrupt .da files or zero sized .da files. Is this a problem on parallel run?

因为两个或多个可执行实例试图在同一个 .da 文件上写入,以便为每个执行中的语句写入覆盖计数?

Because two or more executable instance is trying to write on the same .da file for writing the coverage count for each statement in execution?

如果是这样,有什么解决方法吗?

If so, is there any workaround?

使用的 Gcov 版本是 1.5

Gcov version being used is 1.5

推荐答案

我也有类似的需求,我通过设置 GCOV_PREFIX 环境变量解决了这个问题.

I had a similar need and I solved it by setting up the GCOV_PREFIX environment variable.

根据文档:

GCOV_PREFIX 包含要添加到目标文件中的绝对路径的前缀.前缀可以是绝对的,也可以是相对的.默认为无前缀.

GCOV_PREFIX contains the prefix to add to the absolute paths in the object file. Prefix can be absolute, or relative. The default is no prefix.

GCOV_PREFIX 设置为自定义目录,对于每个可执行文件+执行都是唯一的,将强制运行时在指定目录中生成.gcda",而不是使用编译目录(其中'.gcno' 是).

Setting GCOV_PREFIX to a custom directory, unique for each executable+execution, will force the runtime to generate '.gcda' in the specified directory instead of using the compilation one (where the '.gcno' are).

完成所有执行后,您将能够使用它们生成合并运行报告.

Once all the executions completed you'll be able to use them to generate the merged-run report.

这篇关于并行运行时使用 gcov 的代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆