SlideShare a Scribd company logo
Embedded Test Code Coverage
Coverage Tools
1. tcov
2. gcov
3. "C Test Coverage Tool"
4. "C++ Test Coverage Tool"
5. "Squish Coco"
6. "C++ Coverage Validator"
Common program
gcov
gcov is a tool you can use in conjunction with GCC to test code coverage in your programs.
How it works?
gcov
● how often each line of code executes
● what lines of code are actually executed
● how much computing time each section of code uses
How to use?
$ gcc -fprofile-arcs -ftest-coverage tmp.c
$ a.out
$ gcov tmp.c
File 'tmp.c'
Lines executed:90.00% of 10
Creating 'tmp.c.gcov'
-: 0:Source:tmp.c
-: 0:Graph:tmp.gcno
-: 0:Data:tmp.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:#include <stdio.h>
-: 2:
-: 3:int main (void)
1: 4:{
1: 5: int i, total;
-: 6:
1: 7: total = 0;
-: 8:
11: 9: for (i = 0; i < 10; i++)
10: 10: total += i;
-: 11:
1: 12: if (total != 45)
#####: 13: printf ("Failuren");
-: 14: else
1: 15: printf ("Successn");
1: 16: return 0;
-: 17:}
Beyond..
lcov
lcov is a graphical front-end for GCC's coverage testing tool gcov.
CFLAGS += -fprofile-arcs -ftest-coverage
LDFLAGS += -lgcov
lcov --base-directory . --directory . --capture --output-file example.info
genhtml -o /coverage/example.info
lcov
result
cpputest framework
CppUTest is a C /C++ based unit xUnit test framework for unit testing and for test-driving
your code.
Basic Makefile
PROJECT_HOME_DIR = .
CPP_PLATFORM = Gcc
CPPUTEST_USE_EXTENSIONS = Y
CPPUTEST_WARNINGFLAGS += -Wall
CPPUTEST_WARNINGFLAGS += -Werror
CPPUTEST_WARNINGFLAGS += -Wswitch-default
CPPUTEST_WARNINGFLAGS += -Wswitch-enum
CPPUTEST_WARNINGFLAGS += -Wno-self-assign
CPPUTEST_CFLAGS += -std=c89
CPPUTEST_CFLAGS += -Wextra
CPPUTEST_CFLAGS += -pedantic
CPPUTEST_CFLAGS += -Wstrict-prototypes
Flags
SRC_DIRS = 
src/*
TEST_SRC_DIRS = 
tests 
tests/util 
tests/devices 
tests/HomeAutomation
mocks
INCLUDE_DIRS =
$(CPPUTEST_HOME)/include/
include/*
mocks
Path
include $(CPPUTEST_HOME)/build/MakefileWorker.mk
Include Framwork
CPPUTEST_HOME/build/MakefileWorker.mk
CPPUTEST_USE_GCOV = Y
Enable gcov
$ cd PROJECT_HOME_DIR
$ make gcov
Get gcov output
lcov --base-directory . --directory objs/ -c -o temp.info
lcov --remove temp.info "/usr*" -o temp.info
rm -rf test_coverage
mkdir test_coverage
genhtml -o test_coverage temp.info
Generate lcov html

More Related Content

PDF
Pragmatic Code Coverage
PPTX
PHPUnit - Unit testing
PPTX
Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...
ODP
Tdd in php a brief example
PDF
Python Testing Fundamentals
PDF
Presentation slides: "How to get 100% code coverage"
PDF
PVS-Studio advertisement - static analysis of C/C++ code
PDF
Python and test
Pragmatic Code Coverage
PHPUnit - Unit testing
Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...
Tdd in php a brief example
Python Testing Fundamentals
Presentation slides: "How to get 100% code coverage"
PVS-Studio advertisement - static analysis of C/C++ code
Python and test

What's hot (20)

PDF
Unit testing legacy code
PPTX
Debugging C# Applications
PPTX
PVS-Studio and static code analysis technique
PDF
Test Driven Development Methodology and Philosophy
ODP
Android Test Driven Development
PDF
Unit testing (eng)
PPTX
TDD & BDD
PDF
Semi-Automatic Code Cleanup with Clang-Tidy
PPTX
PVS-Studio, a static analyzer detecting errors in the source code of C/C++/C+...
PPT
TDD And Refactoring
PDF
ES3-2020-05 Testing
PDF
Refactoring Legacy Code
PDF
Behavior Driven Development with SpecFlow
ODP
Gcc opt
PDF
TDD and Simple Design Workshop - Session 1 - March 2019
PPTX
Refactoring legacy code driven by tests - ENG
ODP
TDD in PHP - Memphis PHP 2011-08-25
PDF
Develop Maintainable Apps - edUiConf
PDF
Php unit (eng)
KEY
TDD refresher
Unit testing legacy code
Debugging C# Applications
PVS-Studio and static code analysis technique
Test Driven Development Methodology and Philosophy
Android Test Driven Development
Unit testing (eng)
TDD & BDD
Semi-Automatic Code Cleanup with Clang-Tidy
PVS-Studio, a static analyzer detecting errors in the source code of C/C++/C+...
TDD And Refactoring
ES3-2020-05 Testing
Refactoring Legacy Code
Behavior Driven Development with SpecFlow
Gcc opt
TDD and Simple Design Workshop - Session 1 - March 2019
Refactoring legacy code driven by tests - ENG
TDD in PHP - Memphis PHP 2011-08-25
Develop Maintainable Apps - edUiConf
Php unit (eng)
TDD refresher
Ad

Similar to IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자 (20)

PDF
GNU Compiler Collection - August 2005
PDF
Code quality par Simone Civetta
PDF
100 bugs in Open Source C/C++ projects
PPTX
Process (OS),GNU,Introduction to Linux oS
PDF
MASTER-CLASS: "CODE COVERAGE ON Μ-CONTROLLER" Sebastian Götzinger
PDF
GCC Compiler as a Performance Testing tool for C programs
PDF
How to Perform Memory Leak Test Using Valgrind
PDF
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
PDF
Checking the Qt 5 Framework
PDF
100 bugs in Open Source C/C++ projects
PPTX
Александр Куцан: "Static Code Analysis in C++"
PDF
Two C++ Tools: Compiler Explorer and Cpp Insights
PPTX
C++Basics2022.pptx
PDF
2022 Cauldron analyzer talk from david malcolm
PPTX
Using openCV 3.2.0 with CodeBlocks
PDF
DOCX
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
DOCX
Programming in c
DOC
Introduction-to-C-Part-1 (1).doc
GNU Compiler Collection - August 2005
Code quality par Simone Civetta
100 bugs in Open Source C/C++ projects
Process (OS),GNU,Introduction to Linux oS
MASTER-CLASS: "CODE COVERAGE ON Μ-CONTROLLER" Sebastian Götzinger
GCC Compiler as a Performance Testing tool for C programs
How to Perform Memory Leak Test Using Valgrind
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
Checking the Qt 5 Framework
100 bugs in Open Source C/C++ projects
Александр Куцан: "Static Code Analysis in C++"
Two C++ Tools: Compiler Explorer and Cpp Insights
C++Basics2022.pptx
2022 Cauldron analyzer talk from david malcolm
Using openCV 3.2.0 with CodeBlocks
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
Programming in c
Introduction-to-C-Part-1 (1).doc
Ad

Recently uploaded (20)

PDF
Best Practices for Rolling Out Competency Management Software.pdf
PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PPTX
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
PDF
How to Confidently Manage Project Budgets
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPT
Introduction Database Management System for Course Database
PPTX
L1 - Introduction to python Backend.pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
PPTX
Transform Your Business with a Software ERP System
PDF
Understanding Forklifts - TECH EHS Solution
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PDF
Build Multi-agent using Agent Development Kit
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
top salesforce developer skills in 2025.pdf
PPTX
AIRLINE PRICE API | FLIGHT API COST |
Best Practices for Rolling Out Competency Management Software.pdf
A REACT POMODORO TIMER WEB APPLICATION.pdf
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
How to Confidently Manage Project Budgets
How to Migrate SBCGlobal Email to Yahoo Easily
Introduction Database Management System for Course Database
L1 - Introduction to python Backend.pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
Transform Your Business with a Software ERP System
Understanding Forklifts - TECH EHS Solution
The Role of Automation and AI in EHS Management for Data Centers.pdf
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
ManageIQ - Sprint 268 Review - Slide Deck
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Materi-Enum-and-Record-Data-Type (1).pptx
Build Multi-agent using Agent Development Kit
PTS Company Brochure 2025 (1).pdf.......
top salesforce developer skills in 2025.pdf
AIRLINE PRICE API | FLIGHT API COST |

IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자