简体   繁体   English

多进程覆盖率报告

[英]Multi-process coverage reports

I am trying to monitor the code coverage of my C++ project. 我正在尝试监视我的C ++项目的代码覆盖率。 As I stated in a previous question, I need to use coroutines and other advanced C++2a features, so I am using clang++ to compile it. 如我在上一个问题中所述,我需要使用协程和其他高级C ++ 2a功能,因此我正在使用clang++进行编译。 I found out here that one can use the -coverage flag when compiling with clang++ (along, obviously, with -O0 and -g ). 我在这里发现, 使用clang++编译时(显然,还有-O0-g ),可以使用-coverage标志。

Along with the executable file, this produces a .gcno file, containing the map of the executable. 与可执行文件一起,这将生成一个.gcno文件,其中包含可执行文件的映射。 When the executable is ran, an additional .gcda file is generated, containing the actual profiling data. 运行可执行文件后,将生成一个附加的.gcda文件,其中包含实际的分析数据。

I noticed that if I run the executable multiple times the coverage outputs are nicely and properly merged in the .gcda file, which is very good. 我注意到,如果我多次运行可执行文件,那么coverage输出会很好地并正确地合并到.gcda文件中,这非常好。

Now, I'm wondering if it's safe to run simultaneously multiple instances of the executable. 现在,我想知道同时运行可执行文件的多个实例是否安全。

Before anyone suggests to run the test sequentially: I am running them sequentially, but my application uses a lot of networking, and some of the tests require multiple instances to communicate together (I am using Docker to simulate a network, and netem to get kind-of-realistic link scenarios). 之前有人建议运行测试顺序: 依次运行这些,但我的应用程序使用了大量的联网,以及一些测试需要多个实例一起通信(我用的码头工人来模拟网络,并netem拿到样-现实的链接方案)。

Will running many instances of the same executable together cause any problem? 将同一可执行文件的多个实例一起运行会不会引起任何问题? I can imagine that if any locking mechanism is implemented, the coverage data will be safely and atomically written to the .gcda file, and if other executables need to perform the dump they'll wait until the lock is released. 我可以想象,如果实现了任何锁定机制,覆盖范围数据将被安全且原子地写入.gcda文件,并且如果其他可执行文件需要执行转储,它们将等待直到释放锁定为止。 However, I couldn't find anywhere a guarantee that this actually happens. 但是,我在任何地方都找不到这种情况确实发生的保证。

GCOV profiling should be multi-process safe since Clang 7. 自Clang 7起,GCOV分析应该是多进程安全的。

In Clang 6 there were two bugs preventing it from working, https://bugs.llvm.org/show_bug.cgi?id=34923 and https://bugs.llvm.org/show_bug.cgi?id=35464 , but they are now fixed. 在Clang 6中,有两个错误阻止了它的正常运行: https : //bugs.llvm.org/show_bug.cgi?id =34923https://bugs.llvm.org/show_bug.cgi?id=35464 ,但是它们现在已修复。

Infact, we are currently using it to collect coverage data for Firefox, which is multiprocess. 实际上,我们目前正在使用它来收集Firefox(多进程)的覆盖率数据。 We both have multiple processes in Firefox itself, and we also run tests (for some specific test suites) in parallel. Firefox本身都有多个进程,我们还并行运行测试(针对某些特定的测试套件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM