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

What's hot (20)

PDF
Kotlin for Android Development
Speck&Tech
 
PDF
Qt Application Programming with C++ - Part 1
Emertxe Information Technologies Pvt Ltd
 
PPTX
Qt Qml
Steven Song
 
PDF
Qt programming-using-cpp
Emertxe Information Technologies Pvt Ltd
 
PDF
Best Practices in Qt Quick/QML - Part 1 of 4
ICS
 
PDF
Docker From Scratch
Giacomo Vacca
 
PDF
Zephyr-Overview-20230124.pdf
ibramax
 
PDF
TRex Traffic Generator - Hanoch Haim
harryvanhaaren
 
PDF
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Danielle Womboldt
 
PPTX
UI Programming with Qt-Quick and QML
Emertxe Information Technologies Pvt Ltd
 
PPTX
Building CRUD Wrappers
OutSystems
 
PDF
Introduction to FreeRTOS
ICS
 
PPTX
Hello, QML
Jack Yang
 
PPTX
Protocol buffers
Fabricio Epaminondas
 
PDF
Approaches for Power Management Verification of SOC
DVClub
 
PDF
Graal and Truffle: One VM to Rule Them All
Thomas Wuerthinger
 
PDF
A quick and fast intro to Kotlin
XPeppers
 
PPTX
Logging, Serilog, Structured Logging, Seq
Doruk Uluçay
 
PDF
Elastic Cloud keynote
Elasticsearch
 
PDF
Qt for beginners
Sergio Shevchenko
 
Kotlin for Android Development
Speck&Tech
 
Qt Application Programming with C++ - Part 1
Emertxe Information Technologies Pvt Ltd
 
Qt Qml
Steven Song
 
Best Practices in Qt Quick/QML - Part 1 of 4
ICS
 
Docker From Scratch
Giacomo Vacca
 
Zephyr-Overview-20230124.pdf
ibramax
 
TRex Traffic Generator - Hanoch Haim
harryvanhaaren
 
Ceph Day Beijing - Ceph All-Flash Array Design Based on NUMA Architecture
Danielle Womboldt
 
UI Programming with Qt-Quick and QML
Emertxe Information Technologies Pvt Ltd
 
Building CRUD Wrappers
OutSystems
 
Introduction to FreeRTOS
ICS
 
Hello, QML
Jack Yang
 
Protocol buffers
Fabricio Epaminondas
 
Approaches for Power Management Verification of SOC
DVClub
 
Graal and Truffle: One VM to Rule Them All
Thomas Wuerthinger
 
A quick and fast intro to Kotlin
XPeppers
 
Logging, Serilog, Structured Logging, Seq
Doruk Uluçay
 
Elastic Cloud keynote
Elasticsearch
 
Qt for beginners
Sergio Shevchenko
 

Similar to froglogic Coco Code Coverage Presentation (20)

PPTX
Development testing
Yury Kisliak
 
PDF
Session 7 code_functional_coverage
Nirav Desai
 
PDF
White Box Testing (Introduction to)
Henry Muccini
 
PDF
Code Coverage vs Test Coverage_ A Complete Guide.pdf
flufftailshop
 
PDF
Code Coverage vs Test Coverage_ A Complete Guide.pdf
kalichargn70th171
 
PDF
Lecture 06 - 07 - 08 - Test Techniques - Whitebox Testing.pdf
mkhawar5
 
PPTX
Test Coverage: An Art and a Science
TeamQualityPro
 
PPT
Code coverage
Return on Intelligence
 
PPT
Code Coverage in Theory and in practice form the DO178B perspective
Engineering Software Lab
 
PPT
Code coverage in theory and in practice form the do178 b perspective
Engineering Software Lab
 
PDF
OCCF: A Framework for Developing Test Coverage Measurement Tools Supporting M...
Kazunori Sakamoto
 
PDF
Coverage analysis from execution traces
AdaCore
 
PPTX
Automating The Process For Building Reliable Software
guest8861ff
 
PDF
Pragmatic Code Coverage
Alexandre (Shura) Iline
 
PPT
Testing foundations
Neha Singh
 
PPT
AutoTest.ppt
PrashanthJanakiraman
 
PPT
AutoTest.ppt
Rohit846825
 
PPT
AutoTest.ppt
CHANDUKAYALA
 
PPTX
System verilog coverage
Pushpa Yakkala
 
PDF
Code Coverage
Ernani Omar Cruz
 
Development testing
Yury Kisliak
 
Session 7 code_functional_coverage
Nirav Desai
 
White Box Testing (Introduction to)
Henry Muccini
 
Code Coverage vs Test Coverage_ A Complete Guide.pdf
flufftailshop
 
Code Coverage vs Test Coverage_ A Complete Guide.pdf
kalichargn70th171
 
Lecture 06 - 07 - 08 - Test Techniques - Whitebox Testing.pdf
mkhawar5
 
Test Coverage: An Art and a Science
TeamQualityPro
 
Code coverage
Return on Intelligence
 
Code Coverage in Theory and in practice form the DO178B perspective
Engineering Software Lab
 
Code coverage in theory and in practice form the do178 b perspective
Engineering Software Lab
 
OCCF: A Framework for Developing Test Coverage Measurement Tools Supporting M...
Kazunori Sakamoto
 
Coverage analysis from execution traces
AdaCore
 
Automating The Process For Building Reliable Software
guest8861ff
 
Pragmatic Code Coverage
Alexandre (Shura) Iline
 
Testing foundations
Neha Singh
 
AutoTest.ppt
PrashanthJanakiraman
 
AutoTest.ppt
Rohit846825
 
AutoTest.ppt
CHANDUKAYALA
 
System verilog coverage
Pushpa Yakkala
 
Code Coverage
Ernani Omar Cruz
 
Ad

Recently uploaded (20)

PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Ad

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