2013-03-25 100 views
7

我在macosx平臺中使用gcov進行覆蓋測試。我完成了配置的Xcode由集:有沒有辦法將兩個gcov文件合併爲一個

1. Build Settings ==> Generate Test Coverage Files == Yes 
2. Build Settings ==> Instrument Progaram Flow == Yes 
3. Build Phases ==> Link Binary with library ==> add "libprofile_rt.dylib" 

然後生成文件「Test.d, Test.dia, Test.gcno, Test.gcda, Test.o」 然後我用gcov-4.2 -b Test.gcno命令生成Test.m.gcov文件(這是我想要什麼),但是當我運行測試用例下一次再次生成文件「Test.d, Test.dia, Test.gcno, Test.gcda, Test.o」,數據將被重置。

所以我有兩個問題:

  1. 有什麼辦法,我要在積累這些覆蓋文件中的數據,這樣我可以運行我的項目這麼多次,然後在接收端生成的文件。
  2. 如果#1無望,你能告訴我如何將merge two Test.gcno文件(由兩次運行生成)合併爲一個文件。我嘗試的gcov在終端,下面是對gcov命令的選項:

    gcov-4.2 -help 
    Usage: gcov [OPTION]... SOURCEFILE 
    
    Print code coverage information. 
    
        -h, --help      Print this help, then exit 
        -v, --version     Print version number, then exit 
        -a, --all-blocks    Show information for every basic block 
        -b, --branch-probabilities  Include branch probabilities in output 
        -c, --branch-counts    Given counts of branches taken 
                rather than percentages 
        -n, --no-output     Do not create an output file 
        -l, --long-file-names   Use long output file names for included 
                source files 
        -f, --function-summaries  Output summaries for each function 
        -o, --object-directory DIR|FILE Search for object files in DIR or called FILE 
        -p, --preserve-paths   Preserve all pathname components 
        -u, --unconditional-branches Show unconditional branch counts too 
    
    For bug reporting instructions, please see: 
    <URL:http://developer.apple.com/bugreporter>. 
    

感謝提前你的幫助

回答

15

gcov通常的工作流程

  1. 編譯和鏈接與覆蓋支持(-fprofile-arcs -ftest-coverage
  2. 運行您的可執行文件,可能多次,可能與不同的參數/設置吊環。這將創建在.gcda文件
  3. 調用gcov累加使用信息來獲得在人類可讀的格式(.gcov

所以基本上,應用程序的連續運行會導致累積覆蓋率統計覆蓋的統計信息。只是這些積累將發生在.gcda文件中,而不是.gcov文件中,因此每次要查看更新後的統計信息時都必須重新運行gcov

相關問題