1
讓我先從例子 - Python調用庫代碼。測量範圍
這是庫代碼(編譯成庫libfoolib
):
#include <stdio.h>
void bar()
{
printf("bar\n");
}
void foo()
{
printf("foo\n");
}
這是Python代碼調用它:
#!/usr/bin/python25
import sys
import libfoolib
import processing
def callFoo():
libfoolib.foo()
libfoolib.bar()
process = processing.Process(target=callFoo)
process.start()
當庫與-ftest-coverage
和-fprofile-arcs
的編譯器編譯適當地產生gcno
文件並執行Python代碼當gcda
文件也被生成。問題是,它僅包含了bar
功能,被蟒蛇的分叉之前調用覆蓋號碼。如果foo
也被稱爲Python的處理通話之外,那麼一切都很好。
這是我所得到的,當我運行對所產生的覆蓋數據gcov
工具:「哪裏是我的foo
覆蓋數據」
-: 0:Source:/codeCoverageTests/pythonSIP/foo.c
-: 0:Graph:debug/CMakeFiles/fooLib.dir/foo.c.gcno
-: 0:Data:debug/CMakeFiles/fooLib.dir/foo.c.gcda
-: 0:Runs:4
-: 0:Programs:1
-: 1:#include <stdio.h>
-: 2:
-: 3:void bar()
function bar called 4 returned 100% blocks executed 100%
4: 4:{
4: 5: printf("bar\n");
call 0 returned 100%
4: 6:}
-: 7:
-: 8:void foo()
function foo called 0 returned 0% blocks executed 0%
#####: 9:{
#####: 10: printf("foo\n");
call 0 never executed
#####: 11:}
-: 12:
我已經是問題
關於環境的一些細節:
- 的CentOS 5.4
- GCC 4.1.2 20080704(紅帽4.1.2-46)
- CMake的構建(2.8.0版)
- 蟒2.5
- 蟒至C使用SIP(4.7.4版本)