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

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 閱讀(2887) 評論(2)  編輯 收藏 引用 所屬分類: C++隨筆而已

評論

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

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

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

@smagle
very great article. thanks!  回復  更多評論   

公告

Using C++

導航

統(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>
            制服丝袜激情欧洲亚洲| 在线视频你懂得一区| 欧美中文字幕久久| 国产视频在线一区二区 | 久久久综合精品| 久久一二三区| 午夜精品亚洲一区二区三区嫩草| 国产精品亚洲综合| 久久av资源网站| 久久久久这里只有精品| 亚洲国产成人高清精品| 亚洲福利小视频| 欧美日韩国产综合视频在线观看| 这里只有精品视频在线| 亚洲小说春色综合另类电影| 国产亚洲一区在线| 免费成人高清视频| 欧美人与禽猛交乱配| 亚洲欧美一区二区激情| 欧美亚洲自偷自偷| 亚洲人成网站777色婷婷| 99精品视频免费| 国语自产在线不卡| 欧美激情一区二区在线 | 亚洲在线观看免费| 好吊妞**欧美| 亚洲三级观看| 国产午夜亚洲精品羞羞网站| 欧美国产精品一区| 欧美性大战久久久久久久蜜臀| 欧美在线亚洲| 欧美极品aⅴ影院| 午夜在线播放视频欧美| 另类av一区二区| 性欧美办公室18xxxxhd| 另类春色校园亚洲| 欧美一级一区| 欧美精品在线观看| 久久女同互慰一区二区三区| 欧美日韩一卡| 免费观看久久久4p| 国产精品久久久久久久久免费| 久久精品一区二区三区不卡| 欧美高清在线观看| 久久精品国产清高在天天线| 欧美精品二区三区四区免费看视频| 新67194成人永久网站| 欧美成人精品一区二区| 久久精品国产精品亚洲精品| 欧美午夜精品久久久久久人妖| 欧美成人a视频| 国产日韩欧美91| 亚洲午夜在线视频| 最新中文字幕亚洲| 久久久久久9| 久久蜜桃精品| 国产日韩免费| 午夜精品国产| 亚洲一区亚洲二区| 欧美—级高清免费播放| 欧美成年人视频| 极品尤物av久久免费看| 亚洲欧美国产日韩中文字幕| 亚洲欧美激情在线视频| 欧美色道久久88综合亚洲精品| 亚洲高清免费在线| 永久久久久久| 久久免费视频在线| 久久影院午夜论| 今天的高清视频免费播放成人 | 亚洲一区二区毛片| 亚洲午夜国产一区99re久久| 欧美久久视频| 亚洲全部视频| 一区二区三区欧美| 欧美日韩精品福利| 夜夜精品视频| 亚洲综合三区| 国产精品自在线| 性欧美videos另类喷潮| 久久久久久91香蕉国产| 国产一区二区日韩| 久久久精品国产一区二区三区| 狼狼综合久久久久综合网 | 国产精品一香蕉国产线看观看| 亚洲婷婷综合久久一本伊一区| 亚洲一区久久久| 国产欧美日韩免费| 久久久精品国产99久久精品芒果| 欧美电影在线观看完整版| 亚洲黄色影院| 欧美偷拍一区二区| 亚洲一区中文| 你懂的国产精品| 99re6热在线精品视频播放速度| 欧美日韩国产在线播放网站| 亚洲影院在线| 免费在线日韩av| 99日韩精品| 国产日韩亚洲欧美精品| 久久人人爽人人| 日韩一级网站| 久久一日本道色综合久久| 亚洲免费观看| 国产网站欧美日韩免费精品在线观看 | 久久久久国产一区二区三区| 亚洲欧洲精品一区| 国产精品video| 久久久久久9| 中文在线不卡| 欧美激情一区二区久久久| 亚洲网站视频福利| 精品999久久久| 欧美视频成人| 美女脱光内衣内裤视频久久影院| 亚洲午夜在线| 亚洲欧洲中文日韩久久av乱码| 亚洲一区二区在线免费观看视频| 国内揄拍国内精品少妇国语| 欧美日本国产精品| 久久久久久久综合日本| 亚洲图片在区色| 亚洲激情校园春色| 久久性色av| 久久成人羞羞网站| 一本色道久久综合亚洲91| 韩日在线一区| 国产伦精品一区二区三区高清版| 欧美国产精品va在线观看| 欧美亚洲三区| 亚洲免费在线| 国产精品99久久久久久久女警| 亚洲第一综合天堂另类专| 久久久久久亚洲精品中文字幕| 亚洲一区国产视频| 亚洲最新中文字幕| 亚洲精品一二三| 亚洲国产裸拍裸体视频在线观看乱了中文| 国产精品美女www爽爽爽视频| 欧美另类一区二区三区| 欧美不卡视频| 欧美成人视屏| 欧美成人免费va影院高清| 欧美伊人影院| 久久国产精品毛片| 欧美一级理论片| 午夜精品在线看| 欧美一区二区视频免费观看| 亚洲欧美日韩精品在线| 亚洲一二三区视频在线观看| 一本色道久久综合亚洲二区三区| 亚洲激情偷拍| 亚洲精选中文字幕| 亚洲伦理久久| 亚洲天天影视| 亚洲女性喷水在线观看一区| 亚洲字幕一区二区| 亚洲欧美国产制服动漫| 香蕉亚洲视频| 久久免费视频在线| 欧美1区2区| 欧美日韩在线观看一区二区三区| 欧美三级在线| 国产精品综合av一区二区国产馆| 国产精品一区二区在线观看网站| 国产精品网站在线观看| 国产一区二区观看| 在线成人激情黄色| 亚洲免费成人av| 亚洲欧美精品在线| 久久久91精品国产| 牛牛影视久久网| 日韩五码在线| 欧美有码视频| 欧美高清在线| 国产日韩精品在线播放| 一区二区在线观看视频| 亚洲精品社区| 午夜精品久久久久久久蜜桃app| 久久久久天天天天| 最近中文字幕日韩精品| 亚洲午夜女主播在线直播| 久久精品免费看| 欧美巨乳在线观看| 国产一区二区成人久久免费影院| 亚洲欧洲一区二区三区| 在线亚洲欧美| 久久夜色精品亚洲噜噜国产mv| 亚洲国产天堂久久综合网| 99精品国产福利在线观看免费| 欧美一区二区三区的| 欧美精品久久久久久| 国产精品专区第二| 亚洲伦理中文字幕| 久久精品欧美| 在线亚洲电影| 欧美成人a视频| 国产综合第一页| 亚洲欧美一级二级三级| 亚洲国产精品久久精品怡红院|