青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Codejie's C++ Space

Using C++

Why the inline function can not be covered?


Please have a look the following codes, they include two source files (source.h, source.c), one test file (test_source.c) and one makefile file.

//source.h
 1 #ifndef __SOURCE_H__
 2 #define __SOURCE_H__
 3 
 4 #include <stdio.h>
 5 
 6 inline void inline_test()
 7 {
 8     printf("\nthis is the inline function.");
 9 }
10 
11 void normal_test();
12 
13 #endif

//source.c
1 #include "source.h"
2 
3 void normal_test()
4 {
5     printf("\nThis is a normal function.");
6 }

//test_source.c
 1 #include "source.h"
 2 
 3 void test_inline() 
 4 {
 5     inline_test();
 6 }
 7 
 8 void test_normal()
 9 {
10     normal_test();
11 }
12 
13 int main()
14 {
15     test_inline();
16     test_normal();
17     
18     return 0;
19 }


//makefile
 1 TEST = test_source.o
 2 
 3 TARGET = a.exe
 4 
 5 all: $(TARGET)
 6 
 7 $(TARGET):$(SOURCE) $(TEST)
 8     gcc -Xlinker --allow-multiple-definition $^ -fprofile-arcs -ftest-coverage -o $(TARGET)    
 9 
10 $(SOURCE): %.o:%.c
11     gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
12     gcc -c $< -o $@ -fprofile-arcs -ftest-coverage
13     
14 $(TEST): %.o:%.c
15     gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
16     gcc -c $< -o $@   
17  
18 clean:
19     -rm -rf $(DIR_COVERAGE)
22     -rm -rf *.d *.o *.gcda *.gcno $(TARGET)

...

My purpose is that get the UT line coverage report of source files by running the test file. I guess I should get the below report of line coverage, because I have called every functions of source file in test file, include the inline function and the normal function.

But after run test file, I got the report is just 50%, the inline function has not been covered. Why? Why it is not be covered? I am sure it is called in test file.
OK, Calming down. If it is not covered, there are two reason, one is that the inline function is not be called, of course it is impossible, because we did it. So the root cause must be the second one that gcov/lcov tools do not process those lines of inline function. Have any idea? gcov/lcov tools process all files with compilation parameters '-fprofile-arcs -ftest-coverage', so let's check makefile file again.
Look here, source files have the compilation paraments, but why normal function has been coverage, but inline function not?

$(SOURCE): %.o:%.c
    gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
    gcc -c $< -o $@ -fprofile-arcs -ftest-coverage

Thinking again, as we knew, the difference between inline function and normal function is just that inline function will be inserted source code while compiling period. Yes, the answer is here! While compiling, the inline function is put into test file, but the test file has not '-fprofile-arcs -ftest-coverage' paramenter. So, so it was not covered.

$(TEST): %.o:%.c
    gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
    gcc -c $< -o $@

To fix it, just add the parameter to test file while compiling. OK, let's update the makefile file like the below line.

$(TEST): %.o:%.c
    gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
    gcc -c $< -o $@ -fprofile-arcs -ftest-coverage    

Done, enjoy it!

posted on 2012-09-21 17:45 codejie 閱讀(2878) 評論(2)  編輯 收藏 引用 所屬分類: C++隨筆而已

評論

# re: Why the inline function can not be coveraged? 2012-09-26 19:35 smagle

gcov原理分析詳細(xì)可參考:http://sdet.org/?p=212  回復(fù)  更多評論   

# re: Why the inline function can not be coveraged?[未登錄] 2012-09-26 22:16 codejie

@smagle
very great article. thanks!  回復(fù)  更多評論   

公告

Using C++

導(dǎo)航

統(tǒng)計

留言簿(73)

隨筆分類(513)

積分與排名

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久国产婷婷国产香蕉| 欧美激情在线狂野欧美精品| 日韩亚洲欧美成人| 欧美午夜激情视频| 午夜国产不卡在线观看视频| 欧美一区高清| 亚洲精品看片| 亚洲一二三四久久| 国产曰批免费观看久久久| 久久久最新网址| 欧美高清一区| 性色一区二区三区| 久久综合网络一区二区| 99综合在线| 欧美一级午夜免费电影| 最新亚洲激情| 亚洲综合社区| 亚洲日本成人网| 亚洲欧美日韩国产成人| 亚洲国产精品v| 亚洲天堂av在线免费| 国产综合视频在线观看| 亚洲美女视频在线观看| 韩国三级电影一区二区| 亚洲精品视频在线播放| 韩国视频理论视频久久| 一区二区三区产品免费精品久久75| 国产目拍亚洲精品99久久精品| 欧美粗暴jizz性欧美20| 国产精品久久久久久久久久尿 | 91久久午夜| 欧美日本在线| 两个人的视频www国产精品| 欧美三级精品| 欧美黄色一区| 好吊妞**欧美| 亚洲综合日韩在线| 99精品欧美一区| 久久久久中文| 欧美制服第一页| 欧美日韩在线第一页| 欧美高清在线观看| 国模套图日韩精品一区二区| 亚洲天堂免费观看| 99热免费精品| 欧美电影打屁股sp| 欧美成人情趣视频| 韩国一区二区三区美女美女秀| 国产精品99久久久久久久vr| 亚洲精品精选| 女同一区二区| 欧美激情一区二区| 亚洲高清在线| 久久综合网hezyo| 欧美91大片| 影音先锋欧美精品| 久久久久久久久伊人| 久久精品国产99精品国产亚洲性色 | 久久久久久久久蜜桃| 久久久噜噜噜久噜久久| 国产精品夜夜夜一区二区三区尤| 亚洲精品欧美日韩| 一个色综合av| 欧美日韩一区二区三区在线视频| 亚洲黄色性网站| 日韩视频在线免费| 欧美日韩国产成人| aa日韩免费精品视频一| 亚洲视频一区| 国产精品毛片a∨一区二区三区| 在线一区二区三区四区五区| 亚洲一区二区毛片| 国产精品视频久久久| 亚洲欧美日韩国产综合在线| 欧美专区在线观看一区| 国产自产精品| 蜜桃久久av一区| 亚洲精品久久久久| 亚洲欧美在线观看| 国产一区二区三区在线观看精品 | 国产色婷婷国产综合在线理论片a| 性欧美videos另类喷潮| 快射av在线播放一区| 在线观看国产一区二区| 免费成人毛片| 中文一区二区在线观看| 欧美中文在线免费| 亚洲国产日韩一区二区| 欧美日韩岛国| 欧美亚洲一区二区三区| 欧美成人有码| 亚洲一区一卡| 一区二区在线不卡| 欧美日韩免费观看一区=区三区| 亚洲一区二区在线免费观看视频| 久久天堂av综合合色| 一区二区三区精品国产| 国产一区二区三区四区三区四 | 老司机成人在线视频| av不卡免费看| 欧美fxxxxxx另类| 亚洲欧美国产精品专区久久| 影音先锋日韩有码| 国产精品第一区| 老司机亚洲精品| 亚洲综合首页| 亚洲免费av片| 欧美激情国产高清| 欧美怡红院视频| 日韩天堂av| 尤物在线观看一区| 国产精品视频午夜| 欧美人在线观看| 久久久久一区二区三区| 亚洲免费视频观看| 99成人在线| 亚洲国产精品黑人久久久| 久久久国产91| 亚洲欧美资源在线| 一区二区三区四区五区在线| 亚洲国产成人在线| 国产资源精品在线观看| 国产精品色婷婷| 欧美日韩免费一区二区三区| 欧美成人精品激情在线观看| 久久九九免费视频| 亚洲欧美韩国| 亚洲一级在线观看| 一本色道久久综合一区| 日韩视频一区| 亚洲精品在线观看免费| 欧美第一黄色网| 乱人伦精品视频在线观看| 欧美一区二区黄| 亚洲欧美精品中文字幕在线| 国产精品99久久久久久久久| 洋洋av久久久久久久一区| 亚洲激情综合| 最近中文字幕日韩精品 | 老司机免费视频一区二区| 欧美自拍偷拍| 久久精品国产亚洲高清剧情介绍| 先锋影音久久| 久久国产精品久久精品国产| 欧美一区影院| 久久久久久97三级| 麻豆精品一区二区综合av| 男同欧美伦乱| 欧美国产欧美亚州国产日韩mv天天看完整| 久久野战av| 亚洲国产国产亚洲一二三| 亚洲国产人成综合网站| 日韩视频免费在线观看| 亚洲视频精选在线| 欧美一区二区视频97| 久久久久久久精| 欧美国产日韩二区| 国产精品v欧美精品v日韩精品| 国产精品女主播| 红桃视频一区| 日韩视频免费在线观看| 亚洲欧美日韩精品久久亚洲区| 欧美诱惑福利视频| 欧美v国产在线一区二区三区| 亚洲激情专区| 亚洲欧美大片| 蜜桃av噜噜一区| 国产精品久久久久av免费| 国产亚洲精品v| 亚洲裸体俱乐部裸体舞表演av| 亚洲图片激情小说| 久久久久久久久久久久久久一区| 亚洲国产精品黑人久久久| 亚洲视频二区| 麻豆亚洲精品| 国产日韩欧美在线播放| 亚洲激情av| 欧美在线播放一区| 91久久综合| 久久精品国产清高在天天线| 欧美日韩免费| 1024精品一区二区三区| 亚洲制服少妇| 亚洲第一福利视频| 欧美在线观看一区二区| 欧美日韩一区二区三区在线视频| 狠狠入ady亚洲精品| 亚洲一品av免费观看| 免播放器亚洲| 香港成人在线视频| 欧美日本高清| 91久久精品国产91久久| 久久精品国产69国产精品亚洲 | 久久综合免费视频影院| 亚洲午夜在线观看视频在线| 欧美国产日本| 伊人蜜桃色噜噜激情综合| 欧美一区二区三区四区在线观看地址 | 美女任你摸久久| 国产在线不卡|