Your browser does not support JavaScript! Skip to main content
Free 30-day trial Customer portal Careers DO-178C Handbook
 
Rapita Systems
 

Industry leading verification tools & services

Rapita Verification Suite (RVS)

  RapiTest - Unit/system testing   RapiCover - Structural coverage analysis   RapiTime - Timing analysis (inc. WCET)   RapiTask - Scheduling visualization   RapiCoverZero - Zero footprint coverage analysis   RapiTimeZero - Zero footprint timing analysis   RapiTaskZero - Zero footprint scheduling analysis

Multicore verification

  MACH178   Multicore Timing Solution   RapiDaemons

Services

  V & V Services   Qualification   Training   Tool Integration  Support

Industries

  Aerospace (DO-178C)   Automotive (ISO 26262)   Space

Other

  RTBx   Mx-Suite   Software licensing   Product life cycle policy  RVS development roadmap

Latest from Rapita HQ

Latest news

Danlaw Acquires Maspatechnologies - Expanding Rapita Systems to Spain
Rapita co-authored paper wins ERTS22 Best paper award
A look back on Rapita's Multicore DO-178C training in Huntsville
RVS 3.17 Launched
View News

Latest from the Rapita blog

Why mitigating interference alone isn’t enough to verify timing performance for multicore DO-178C projects
There are how many sources of interference in a multicore system?
Supporting modern development methodologies for verification of safety-critical software
Flexible licensing software fit for modern working
View Blog

Latest discovery pages

do178c DO-178C Guidance: Introduction to RTCA DO-178 certification
matlab_simulink MATLAB® Simulink® MCDC coverage and WCET analysis
code_coverage_ada Code coverage for Ada, C and C++
amc-20-193 AMC 20-193
View Discovery pages

Upcoming events

Aerospace Tech Week Europe 2023
2023-03-29
Certification Together International Conference
2023-05-10
View Events

Technical resources for industry professionals

Latest White papers

DO178C Handbook
Efficient Verification Through the DO-178C Life Cycle
A Commercial Solution for Safety-Critical Multicore Timing Analysis
Compliance with the Future Airborne Capability Environment (FACE) standard
View White papers

Latest Videos

Efficient DO-178C verification - WCET analysis
Efficient DO-178C verification - Code coverage
Efficient DO-178C verification - Functional testing
SCADE Test video thumbnail
Complementary DO-178C verification with Ansys(R) SCADE Test(TM) and RVS
View Videos

Latest Case studies

Supporting ISO 26262 ASIL D software verification for EasyMile
RapiCover’s advanced features accelerate the certification of military UAV Engine Control
Front cover of whitepaper collins
Delivering world-class tool support to Collins Aerospace
View Case studies

Other Downloads

 Webinars

 Brochures

 Product briefs

 Technical notes

 Research projects

Discover Rapita

Who we are

The company menu

  • About us
  • Customers
  • Distributors
  • Locations
  • Partners
  • Research projects
  • Contact us

US office

+1 248-957-9801
info@rapitasystems.com
Rapita Systems, Inc.
41131 Vincenti Ct.
Novi
MI 48375
USA

UK office

+44 (0)1904 413945
info@rapitasystems.com
Rapita Systems Ltd.
Atlas House
Osbaldwick Link Road
York, YO10 3JB
UK

Spain office

+34 930 46 42 72
info@rapitasystems.com
Rapita Systems S.L.
Parc UPC, Edificio K2M
c/ Jordi Girona, 1-3, Office 306-307
Barcelona 08034
Spain

Working at Rapita

Careers

Careers menu

  • Current opportunities & application process
  • Working at Rapita
Back to Top

Breadcrumb

  1. Home
  2. Code coverage for Ada, C and C++

Discover Code Coverage for Ada, C and C++

  • Intro
  • Testing code coverage
  • Types
  • Languages
  • Untested code
  • Code coverage webinar

What is code coverage?

Code coverage (also known as structural coverage) is a measurement of how much code is executed during testing and is a metric often used to assess the completeness of requirements-based testing. In requirements-based testing, which is encouraged when following certification guidelines or standards such as DO-178C (aerospace) or ISO 26262 (automotive), source code and associated tests are derived from high- and low-level requirements.

When performing requirements-based testing, every requirement may have one or more test cases verifying its correct implementation, and all source code should be traceable to a requirement. Measuring the code coverage achieved through testing can help demonstrate this requirement traceability.

Testing code coverage

Code coverage testing can help to ensure that all source code can be traced back to requirements. This can be demonstrated by showing that, when requirements-based tests are run, 100% code coverage is achieved through either testing (of testable code) or justification (of untestable code).

DO-178C and ISO 26262 recommend the use of code coverage analysis (also known as structural coverage analysis) for measuring the effectiveness of test cases on the road to certification.

The main benefits of testing code coverage are to show that:

  • Requirements are complete
  • Tests are complete i.e. there is a test for every requirement
  • No unnecessary code is deployed
  • Deactivated code (code that is only active in configurations different from the deployed configuration) is identified

While testing code coverage manually is possible, using an automated code coverage analysis tool such as RapiCover is much more efficient and can help avoid program delays.

code coverage for Ada
Code coverage for Ada analyzed using RapiCover – covered sections of code shown in green, uncovered sections of code shown in red

Types of Coverage

Different types of code coverage exist, which are used to consider code at varying levels of granularity. It is necessary to analyze code coverage at higher granularities when working with higher integrity software (e.g. higher DO-178C DAL Level or ISO 26262 ASIL).

From lowest to highest granularity, the main forms of code coverage are:

  • Function coverage – has every function (or Ada subprogram) in the code been called?
  • Statement coverage – has every statement been executed?
  • Branch/Decision coverage – have the true and false branches of every decision in the code been executed? This type of code coverage is called Branch coverage in ISO 26262 and Decision coverage in DO-178C.
  • Modified condition/decision coverage (MC/DC) – has each condition in every decision in the code been shown to independently affect the outcome of that decision? This is the most stringent code coverage metric and used with DO-178C DAL A software.

Analyzing code coverage for different languages

Whether your software is written in Ada, C or C++, code coverage is likely to be a crucial part of your software verification. If you choose to use an automated structural coverage analysis tool, you should ensure that it supports all of the languages you’re using. RapiCover supports code coverage for Ada, C, C++, and mixed language projects.

Depending on the language you’re using and coding standards you’re following, you may be unable to achieve 100% code coverage through testing alone and may need to supplement your test coverage by justifying your code as covered by analysis. Justifications may also be used for code that you’ve chosen not to test, for example because it’s more efficient to review the code structure manually.

An example of untestable code arising due to following a coding standard is that your standard could require you to include default clauses in C switch statements or when others clauses in Ada case statements.

In such a situation, you may have untestable code if all of the cases in the code include the full range of possible values.

case x is
when 0 => Ada.Text_IO.Put ("zero");
when 1 => Ada.Text_IO.Put ("one");
when 2 => Ada.Text_IO.Put ("two");
when others => Ada.Text_IO.Put ("none of the above");
end case;
An Ada when others clause may be untestable and may need to be justified as covered by analysis. In the code above, if the type of x is constrained to the range 0-2, the when others statement would be untestable. However, you may need to include such a clause because of your coding standards.

Handling untested code

Whether untested code is untestable or you’ve simply chosen not to test it, it can either be justified manually or by using an automated code coverage analysis tool.

Manually justifying untested code would be a painstaking process, especially in larger projects. If any changes were made to code that was justified manually, considerable review effort would be needed to ensure that any justifications are applied are still valid.

Automated code coverage analysis tools that let you justify your untested code and migrate justifications such as RapiCover mitigate the cost of justifying untested code.

When your code changes, RapiCover can analyze the impact of changes on justifications and often identify the new location of justified code that has changed, even when it has moved to a different line in the source file. This can save a huge amount of review effort.

RapiCover helps migrate justifications
RapiCover helps migrate justifications for untested code when code changes by identifying the new location of justified code
RapiCover

Low-overhead coverage analysis for critical software

 
Choose your free resource:
When you contact us, we will process your personal data in accordance with our data protection policy, please see our Customer Privacy Information for more information.
  • Solutions
    • Rapita Verification Suite
    • RapiTest
    • RapiCover
    • RapiTime
    • RapiTask
    • MACH178

    • Verification and Validation Services
    • Qualification
    • Training
    • Integration
  • Latest
  • Latest menu

    • News
    • Blog
    • Events
    • Videos
  • Downloads
  • Downloads menu

    • Brochures
    • Webinars
    • White Papers
    • Case Studies
    • Product briefs
    • Technical notes
    • Software licensing
  • Company
  • Company menu

    • About Rapita
    • Careers
    • Customers
    • Distributors
    • Industries
    • Locations
    • Partners
    • Research projects
    • Contact
  • Discover
    • AMC 20-193
    • What is CAST-32A?
    • Multicore Timing Analysis
    • MC/DC Coverage
    • Code coverage for Ada, C & C++
    • Embedded Software Testing Tools
    • Aerospace Software Testing
    • Automotive Software Testing
    • Certifying eVTOL
    • DO-178C
    • WCET Tools
    • Worst Case Execution Time
    • Timing analysis (WCET) & Code coverage for MATLAB® Simulink®

All materials © Rapita Systems Ltd. 2023 - All rights reserved | Privacy information | Trademark notice Subscribe to our newsletter