欢迎关注VxWorks567
如转发 请标明出处!
ScopeTools里还有个成员叫做CoverageScope,现改名为Code Coverage Analyzer。不过Vx7里已经不支持它了(以及Data Monitor)。这是一个运行时的代码覆盖度测试工具。顾名思义,这个工具可以用于测试代码是否执行过。它可以检测已调用函数或已执行语句的百分比,并记录未执行的代码
You can configure coverage to gather and display test data on the following aspects:
重点是看看怎么用吧,随便写个例子,多包含一些分支,例如
static void child1(int num)
{
switch(num)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
default:
break;
}
}
static void child2(int num)
{
if(num > 0)
{
}
else if(num == 0)
{
}
else
{
}
}
static void child3(int num)
{
while(num > 0)
{
num--;
}
}
void testCoverage()
{
int i;
for(i=0; i<4; i++)
child1(i);
child2(0);
child2(1);
child3(5);
}
这是它的测试效果
具体操作流程如下