SlideShare a Scribd company logo
Squish Coco
Why Squish Coco?
● Typical question: Are we testing enough? Are we testing the right
things?
● Answer: Code coverage analysis
– Understand which tests excercise which source code
– Understand which tests are redundant
– Discover testing gaps
– More advanced analysis
Squish Coco
● Cross-Plattform Code Coverage Analysis
– Windows, Linux, macOS, Unix, RTOSes
– C, C++, C#, SystemC, Tcl, QML
● Coverage Levels
– Function
– Statement
– Branch (Decision)
– Condition
– Condition/Decision
– MC/DC
– MCC
Coco Agenda
Basics
●
Available coverage metrics
●
Supported platforms
●
Architecture, data formats
●
Approaches to instrumentation
●
Impact on build and execution
Live Demos
●
Interactive analysis via GUI
●
Report generation via command line
●
Overview of result formats
●
Manual validation
●
Analysis: optimzed execution order,
execution comparison, patch review
Integrations
●
Command line tools
●
Unit tests
●
CI systems
●
Build system
Discussion
●
Question and answers
●
Requirements
Coverage Analysis (Example)
Coverage Levels – Function
int f(unsigned int a, unsigned int b, int c) {
int x = 0;
if ((a != 0 || b != 0) && c != 0)
x = a*b / c / max(a, b);
return x;
}
Test
f(0, 1, 1)
Coverage Levels – Line
int f(unsigned int a, unsigned int b, int c) {
int x = 0;
if ((a != 0 || b != 0) && c != 0)
x = a*b / c / max(a, b);
return x;
}
Test
f(0, 1, 1)
Coverage Levels – Statement
int f(unsigned int a, unsigned int b, int c) {
int x = 0;
if ((a != 0 || b != 0) && c != 0)
x = a*b / c / max(a, b);
return x;
}
Test
f(0, 1, 1)
Coverage Levels – Decision / Branch
int f(unsigned int a, unsigned int b, int c) {
int x = 0;
if ((a != 0 || b != 0) && c != 0)
x = a*b / c / max(a, b);
return x;
}
Test (X || Y) && Z Decision
f(0, 1, 1) (FALSE || TRUE) && TRUE TRUE
f(0, 0, 1) (FALSE || FALSE) && …. FALSE
Coverage Levels – Condition
int f(unsigned int a, unsigned int b, int c) {
int x = 0;
if ((a != 0 || b != 0) && c != 0)
x = a*b / c / max(a, b);
return x;
}
Test a != 0 b != 0 c != 0
f(1, 1, 0) TRUE - FALSE
f(0, 1, 1) FALSE TRUE TRUE
f(0, 0, 0) FALSE FALSE -
Coverage Levels – MCC
bool isValidPosition(int x, int y, int z)
{
if ((x > 10 || y > 20) && z > 0)
return true;
else
return false;
}
x > 10 y > 20 z > 0
FALSE TRUE TRUE
TRUE - TRUE
FALSE TRUE FALSE
TRUE - FALSE
FALSE FALSE -
Coverage Levels – MCC #2
bool isSilentSignal(int *line1, int *line2)
{
if ((!line1 || *line1 <= 0) && (!line2 || *line2 <= 0))
return true;
else
return false;
}
!line1 *line1 <= 0 !line2 *line2 <= 0
TRUE - FALSE TRUE
TRUE - FALSE FALSE
FALSE TRUE TRUE -
TRUE - TRUE -
FALSE FALSE - -
FALSE TRUE FALSE TRUE
FALSE TRUE FALSE FALSE
Modified Condition / Decision Coverage
“Every point of entry and exit in the program has been invoked at least once, every
condition in a decision in the program has taken all possible outcomes at least once, and
each condition has been shown to affect that decision outcome independently. A condition
is shown to affect a decision's outcome independently by varying just that condition while
holding fixed all other possible conditions.”
(Formal definition DO-178C)
Coverage Levels – MC/DC
bool isSilentSignal(int *line1, int *line2)
{
if ((!line1 || *line1 <= 0) && (!line2 || *line2 <= 0))
return true;
else
return false;
}
!line1 *line1 <= 0 !line2 *line2 <= 0 Decision
TRUE - FALSE TRUE TRUE
TRUE - FALSE FALSE FALSE
FALSE TRUE TRUE - TRUE
TRUE - TRUE - TRUE
FALSE FALSE - - FALSE
Supported Platforms
Operating systems
● Windows
●
Linux
●
Mac OS X
● Solaris
●
Embedded / RTOS
Programming languages
●
C and C++
●
SystemC
●
C# (Microsoft and Mono)
●
QML
●
Tcl
●
Planned: Java, JavaScript
Architecture
Instrumentation Database
Architecture
Report Generation
Architecture
Regular Product Build
Architecture
Regular Source Compilation
Architecture
Source Instrumentation
Architecture
Instrumentation Linking
Architecture
Alternative to build system change:
● Make use of fake cl.exe and link.exe
● Set PATH to override originals
● Set COVERAGESCANNER_ARGS=--cs-on
Instrumentation Types
●
Source code insertion at compile time
●
Pro: highest possible coverage type
●
Drawback: increased binary size
●
Binary instrumentation at runtime
●
Pro: No recompilation necessary
●
Con: Limited coverage type
●
Con: Less portable
●
Con: wrong results with optimized builds
Instrumentation Overhead
Impact on:
●
Compilation time
●
Binary size
●
Execution time
Influencing factors:
●
Coverage level
●
Optimization level
Live Demo
Report Generation
Command line version:
cmreport --title="Coverage Results"
--csmes=parser.exe.csmes
--select=".*"
--bargraph --toc
--global=all --method=all --source=all
--execution=all
--html=result.html
Additional options: HTML style, watermarks, coverage level, ...
Report Generation
Available formats:
●
HTML (stylable)
●
XML (basic, EMMA)
●
JUnit
●
CSV
●
Text (line format)
●
Cobertura (for SonarQube)
Manual Validation
How to deal with code hard/impossible to automatically cover?
●
Source code annotations
●
Pro: robust
●
Drawback: invasive
●
Example: /* coco validated: only for debugging */
●
Result amendments
●
Pro: product untouched
●
Con: possibly fragile on code changes
Command Line Tools
Execution import via cmcsexeimport:
Command Line Tools
Database merge via cmmerge:
Integration
System test with “dump on exit”:
Integration
Monitor long-running process with “dump on event”:
Integration
Force dump with API calls:
Integration
Control API (guard with #ifdef __COVERAGESCANNER__):
__coveragescanner_testname(const char *name)
__coveragescanner_teststate(const char *state)
__coveragescanner_add_html_comment(const char *comment)
__coveragescanner_save()
__coveragescanner_filename(const char *name)
__coveragescanner_set_custom_io(.....)
Pragmas:
#pragma CoverageScanner(cov-on)
#pragma CoverageScanner(cov-off)
Unit Test Integration
Basic integration
● Rely on “dump on exit”
● Make use of cmcsexeimport, cmmerge and cmreport
Advanced integration
● Set __coveragescanner_test_name()
● Transport __coveragescanner_test_state()
● Add __coveragescanner_html_comment()
● Segment with __coveragescanner_save()
Unit Test Integration (Qt)
Usage in QTestLib:
● Test build, execution and coverage as single step
●
Associate test run and result with respective coverage
...
void MyUnitTest::cleanup()
{
cleanupTest();
#ifdef __COVERAGESCANNER__
QString test_name="unittest/";
test_name += metaObject()->className();
test_name += "/";
test_name += QTest::currentTestFunction();
__coveragescanner_testname(test_name.toLatin1());
if (QTest::currentTestFailed())
__coveragescanner_teststate("FAILED");
else
__coveragescanner_teststate("PASSED") ;
__coveragescanner_save();
#endif
}
Test Framework Integration
●
Continuous Integration (CI):
●
Jenkins
●
Bamboo
●
CruiseControl
●
SonarQube
●
Hooks in revision control system
Open Coverage Service
Code Metrics
Tool Qualification Kit
Thank you!

More Related Content

PDF
Use Variable Rate Shading (VRS) to Improve the User Experience in Real-Time G...
PPTX
Transfer learning-presentation
PPTX
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
PPTX
Unit testing with NUnit
PPTX
Attention in Deep Learning
PPT
POST’s CORRESPONDENCE PROBLEM
PDF
MLIP - Chapter 5 - Detection, Segmentation, Captioning
PDF
What is Python? | Edureka
Use Variable Rate Shading (VRS) to Improve the User Experience in Real-Time G...
Transfer learning-presentation
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
Unit testing with NUnit
Attention in Deep Learning
POST’s CORRESPONDENCE PROBLEM
MLIP - Chapter 5 - Detection, Segmentation, Captioning
What is Python? | Edureka

What's hot (20)

PDF
[Paper] attention mechanism(luong)
PDF
Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...
PDF
우리 제품의 검증 프로세스 소개 자료
PDF
Attention is all you need
PPTX
Linear regression
PDF
Python quick guide1
PDF
Python 2 vs. Python 3
PDF
An introduction to property based testing
PDF
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
PPTX
Bdd – with cucumber and gherkin
PPTX
Natural language processing and transformer models
PDF
Attention is All You Need (Transformer)
PDF
Effective code reviews
PDF
一般化反復射影法に基づく時変劣ガウス独立低ランク行列分析
PPT
4.4.2013 Software Quality - Regression Testing Automated and Manual - RFT/RQM
PPTX
비디오 코덱
PDF
異常音検知の実用化に向けて
PDF
Python Programming Tutorial | Edureka
PPTX
Normalization 방법
ODP
Strategie automatyzacji testow
[Paper] attention mechanism(luong)
Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...
우리 제품의 검증 프로세스 소개 자료
Attention is all you need
Linear regression
Python quick guide1
Python 2 vs. Python 3
An introduction to property based testing
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Bdd – with cucumber and gherkin
Natural language processing and transformer models
Attention is All You Need (Transformer)
Effective code reviews
一般化反復射影法に基づく時変劣ガウス独立低ランク行列分析
4.4.2013 Software Quality - Regression Testing Automated and Manual - RFT/RQM
비디오 코덱
異常音検知の実用化に向けて
Python Programming Tutorial | Edureka
Normalization 방법
Strategie automatyzacji testow
Ad

Similar to froglogic Coco Code Coverage Presentation (20)

PPTX
Development testing
PDF
Session 7 code_functional_coverage
PDF
White Box Testing (Introduction to)
PDF
Code Coverage vs Test Coverage_ A Complete Guide.pdf
PDF
Code Coverage vs Test Coverage_ A Complete Guide.pdf
PDF
Lecture 06 - 07 - 08 - Test Techniques - Whitebox Testing.pdf
PPTX
Test Coverage: An Art and a Science
PPT
Code coverage
PPT
Code Coverage in Theory and in practice form the DO178B perspective
PPT
Code coverage in theory and in practice form the do178 b perspective
PDF
OCCF: A Framework for Developing Test Coverage Measurement Tools Supporting M...
PDF
Coverage analysis from execution traces
PPTX
Automating The Process For Building Reliable Software
PDF
Pragmatic Code Coverage
PPT
Testing foundations
PPT
AutoTest.ppt
PPT
AutoTest.ppt
PPT
AutoTest.ppt
PPTX
System verilog coverage
PDF
Code Coverage
Development testing
Session 7 code_functional_coverage
White Box Testing (Introduction to)
Code Coverage vs Test Coverage_ A Complete Guide.pdf
Code Coverage vs Test Coverage_ A Complete Guide.pdf
Lecture 06 - 07 - 08 - Test Techniques - Whitebox Testing.pdf
Test Coverage: An Art and a Science
Code coverage
Code Coverage in Theory and in practice form the DO178B perspective
Code coverage in theory and in practice form the do178 b perspective
OCCF: A Framework for Developing Test Coverage Measurement Tools Supporting M...
Coverage analysis from execution traces
Automating The Process For Building Reliable Software
Pragmatic Code Coverage
Testing foundations
AutoTest.ppt
AutoTest.ppt
AutoTest.ppt
System verilog coverage
Code Coverage
Ad

Recently uploaded (20)

PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
history of c programming in notes for students .pptx
PDF
System and Network Administraation Chapter 3
PPT
Introduction Database Management System for Course Database
PPTX
Transform Your Business with a Software ERP System
PDF
Understanding Forklifts - TECH EHS Solution
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
Navsoft: AI-Powered Business Solutions & Custom Software Development
How to Migrate SBCGlobal Email to Yahoo Easily
Softaken Excel to vCard Converter Software.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Computer Software and OS of computer science of grade 11.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
How to Choose the Right IT Partner for Your Business in Malaysia
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
history of c programming in notes for students .pptx
System and Network Administraation Chapter 3
Introduction Database Management System for Course Database
Transform Your Business with a Software ERP System
Understanding Forklifts - TECH EHS Solution
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Reimagine Home Health with the Power of Agentic AI​
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Internet Downloader Manager (IDM) Crack 6.42 Build 41
2025 Textile ERP Trends: SAP, Odoo & Oracle

froglogic Coco Code Coverage Presentation

  • 2. Why Squish Coco? ● Typical question: Are we testing enough? Are we testing the right things? ● Answer: Code coverage analysis – Understand which tests excercise which source code – Understand which tests are redundant – Discover testing gaps – More advanced analysis
  • 3. Squish Coco ● Cross-Plattform Code Coverage Analysis – Windows, Linux, macOS, Unix, RTOSes – C, C++, C#, SystemC, Tcl, QML ● Coverage Levels – Function – Statement – Branch (Decision) – Condition – Condition/Decision – MC/DC – MCC
  • 4. Coco Agenda Basics ● Available coverage metrics ● Supported platforms ● Architecture, data formats ● Approaches to instrumentation ● Impact on build and execution Live Demos ● Interactive analysis via GUI ● Report generation via command line ● Overview of result formats ● Manual validation ● Analysis: optimzed execution order, execution comparison, patch review Integrations ● Command line tools ● Unit tests ● CI systems ● Build system Discussion ● Question and answers ● Requirements
  • 6. Coverage Levels – Function int f(unsigned int a, unsigned int b, int c) { int x = 0; if ((a != 0 || b != 0) && c != 0) x = a*b / c / max(a, b); return x; } Test f(0, 1, 1)
  • 7. Coverage Levels – Line int f(unsigned int a, unsigned int b, int c) { int x = 0; if ((a != 0 || b != 0) && c != 0) x = a*b / c / max(a, b); return x; } Test f(0, 1, 1)
  • 8. Coverage Levels – Statement int f(unsigned int a, unsigned int b, int c) { int x = 0; if ((a != 0 || b != 0) && c != 0) x = a*b / c / max(a, b); return x; } Test f(0, 1, 1)
  • 9. Coverage Levels – Decision / Branch int f(unsigned int a, unsigned int b, int c) { int x = 0; if ((a != 0 || b != 0) && c != 0) x = a*b / c / max(a, b); return x; } Test (X || Y) && Z Decision f(0, 1, 1) (FALSE || TRUE) && TRUE TRUE f(0, 0, 1) (FALSE || FALSE) && …. FALSE
  • 10. Coverage Levels – Condition int f(unsigned int a, unsigned int b, int c) { int x = 0; if ((a != 0 || b != 0) && c != 0) x = a*b / c / max(a, b); return x; } Test a != 0 b != 0 c != 0 f(1, 1, 0) TRUE - FALSE f(0, 1, 1) FALSE TRUE TRUE f(0, 0, 0) FALSE FALSE -
  • 11. Coverage Levels – MCC bool isValidPosition(int x, int y, int z) { if ((x > 10 || y > 20) && z > 0) return true; else return false; } x > 10 y > 20 z > 0 FALSE TRUE TRUE TRUE - TRUE FALSE TRUE FALSE TRUE - FALSE FALSE FALSE -
  • 12. Coverage Levels – MCC #2 bool isSilentSignal(int *line1, int *line2) { if ((!line1 || *line1 <= 0) && (!line2 || *line2 <= 0)) return true; else return false; } !line1 *line1 <= 0 !line2 *line2 <= 0 TRUE - FALSE TRUE TRUE - FALSE FALSE FALSE TRUE TRUE - TRUE - TRUE - FALSE FALSE - - FALSE TRUE FALSE TRUE FALSE TRUE FALSE FALSE
  • 13. Modified Condition / Decision Coverage “Every point of entry and exit in the program has been invoked at least once, every condition in a decision in the program has taken all possible outcomes at least once, and each condition has been shown to affect that decision outcome independently. A condition is shown to affect a decision's outcome independently by varying just that condition while holding fixed all other possible conditions.” (Formal definition DO-178C)
  • 14. Coverage Levels – MC/DC bool isSilentSignal(int *line1, int *line2) { if ((!line1 || *line1 <= 0) && (!line2 || *line2 <= 0)) return true; else return false; } !line1 *line1 <= 0 !line2 *line2 <= 0 Decision TRUE - FALSE TRUE TRUE TRUE - FALSE FALSE FALSE FALSE TRUE TRUE - TRUE TRUE - TRUE - TRUE FALSE FALSE - - FALSE
  • 15. Supported Platforms Operating systems ● Windows ● Linux ● Mac OS X ● Solaris ● Embedded / RTOS Programming languages ● C and C++ ● SystemC ● C# (Microsoft and Mono) ● QML ● Tcl ● Planned: Java, JavaScript
  • 22. Architecture Alternative to build system change: ● Make use of fake cl.exe and link.exe ● Set PATH to override originals ● Set COVERAGESCANNER_ARGS=--cs-on
  • 23. Instrumentation Types ● Source code insertion at compile time ● Pro: highest possible coverage type ● Drawback: increased binary size ● Binary instrumentation at runtime ● Pro: No recompilation necessary ● Con: Limited coverage type ● Con: Less portable ● Con: wrong results with optimized builds
  • 24. Instrumentation Overhead Impact on: ● Compilation time ● Binary size ● Execution time Influencing factors: ● Coverage level ● Optimization level
  • 26. Report Generation Command line version: cmreport --title="Coverage Results" --csmes=parser.exe.csmes --select=".*" --bargraph --toc --global=all --method=all --source=all --execution=all --html=result.html Additional options: HTML style, watermarks, coverage level, ...
  • 27. Report Generation Available formats: ● HTML (stylable) ● XML (basic, EMMA) ● JUnit ● CSV ● Text (line format) ● Cobertura (for SonarQube)
  • 28. Manual Validation How to deal with code hard/impossible to automatically cover? ● Source code annotations ● Pro: robust ● Drawback: invasive ● Example: /* coco validated: only for debugging */ ● Result amendments ● Pro: product untouched ● Con: possibly fragile on code changes
  • 29. Command Line Tools Execution import via cmcsexeimport:
  • 30. Command Line Tools Database merge via cmmerge:
  • 31. Integration System test with “dump on exit”:
  • 32. Integration Monitor long-running process with “dump on event”:
  • 34. Integration Control API (guard with #ifdef __COVERAGESCANNER__): __coveragescanner_testname(const char *name) __coveragescanner_teststate(const char *state) __coveragescanner_add_html_comment(const char *comment) __coveragescanner_save() __coveragescanner_filename(const char *name) __coveragescanner_set_custom_io(.....) Pragmas: #pragma CoverageScanner(cov-on) #pragma CoverageScanner(cov-off)
  • 35. Unit Test Integration Basic integration ● Rely on “dump on exit” ● Make use of cmcsexeimport, cmmerge and cmreport Advanced integration ● Set __coveragescanner_test_name() ● Transport __coveragescanner_test_state() ● Add __coveragescanner_html_comment() ● Segment with __coveragescanner_save()
  • 36. Unit Test Integration (Qt) Usage in QTestLib: ● Test build, execution and coverage as single step ● Associate test run and result with respective coverage ... void MyUnitTest::cleanup() { cleanupTest(); #ifdef __COVERAGESCANNER__ QString test_name="unittest/"; test_name += metaObject()->className(); test_name += "/"; test_name += QTest::currentTestFunction(); __coveragescanner_testname(test_name.toLatin1()); if (QTest::currentTestFailed()) __coveragescanner_teststate("FAILED"); else __coveragescanner_teststate("PASSED") ; __coveragescanner_save(); #endif }
  • 37. Test Framework Integration ● Continuous Integration (CI): ● Jenkins ● Bamboo ● CruiseControl ● SonarQube ● Hooks in revision control system