BullsEye的代码覆盖率测试

时间:2018-04-19 10:00:56

标签: c code-coverage bullseye

我使用Bullseye进行代码覆盖率测试和一些C代码。 我成功地用Bullseye检测了我的c代码。然后我试着拆开它,看看那里有什么。

我期待在plt.hist()处插入一些探测功能。例如every control transfer locationforif等。令我惊讶的是,我只看到while。比如这一个:

enter image description here

那么这个单一探测器如何跟踪所有控制传输?

当我查看收集的覆盖数据时,我的所有控制转移都被记录为未覆盖。只有函数入口点被视为已覆盖。

我是否错误配置了Bullseye,因此上面的屏幕截图只是粗略的a single probe at the the beginning of each of my functions?如果是这样,我如何配置Bullseye进行基于细粒度控制传输的覆盖?

1 个答案:

答案 0 :(得分:0)

好的,我明白了。

检测代码如下所示:

#pragma bss_seg(push,".covbss")
static struct cov_V_d934b203 cov_v_d934b203;
#pragma bss_seg(pop)
#pragma const_seg(push,".covconst")
static const struct cov_O_d934b203 cov_o_d934b203 = {
0x5a6b7c8d, 0x6b54972d, &cov_v_d934b203, 0x254972d, cov_V_d934b203_n, "CpuPeimTest.obj 21Apr18 22:20"
};

...

if(!cov_v_d934b203.data[0])cov_probe_v11(&cov_o_d934b203,0);{ // this is right after the function entry.


 do { if (DebugPrintEnabled ()) { do { if (DebugPrintLevelEnabled (0x80000000)) { DebugPrint (0x80000000,"Ming: Code coverage test start.\n"); } } while (((BOOLEAN)(0==1))); } } while (((BOOLEAN)(0==1)));

基本上,它分别在cov_c_xxxcov_v_xxx段中存储了一些覆盖数据收集器对象.covconst.covbss。在运行时,已检测的代码日志数据指向cov_v_xxx对象。

cov_probe_v11在函数入口中调用只需将cov_c_xxxcov_v_xxx链接到最终结果链接列表中。 cov_probe_v11是Bullseye运行时库的一部分。您可以对其进行修改以适应您测试的代码。

链接后,所有其他数据集合都可以在不需要调用cov_probe_v11的情况下进行。