Your browser does not support JavaScript! Skip to main content
Free 30-day trial Customer portal Contact
 
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

  CAST-32A Compliance   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

Latest from Rapita HQ

Latest news

Rapita hosts SCADE webinar with ANSYS
FACE Virtual Technical Interchange Meeting
RVS 3.14 Launched
Propelling the next generation of scientists
View News

Latest from the Rapita blog

Software verification on the Solar Orbiter
Metrowerks CodeTest - How and why to upgrade
Leveraging FACE Conformance Artifacts to Support Airworthiness
Assured Multicore Partitioning for FACE Systems
View Blog

Latest discovery pages

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
embedded_software_testing Embedded Software Testing Tools
View Discovery pages

Upcoming events

Future Airborne Capability Environment (FACE) Exihibition
2021-09-14
Safe Use of Multi-Core Processors Seminar
2021-11-10
View Events

Technical resources for industry professionals

Latest White papers

Multicore Timing Analysis for DO-178C
Seven Roadblocks to 100% Structural Coverage (and how to avoid them)
Eight top code coverage questions in embedded avionics systems
View White papers

Latest Videos

Efficient testing with RVS and ANSYS® SCADE® Test™
Enabling cost-effective modular avionics with FACE
Streamlined software verification thumbnail
Streamlined software verification with RVS 3.14
Qualification guidance thumbnail
Clear qualification guidance with RVS qualification kits
View Videos

Latest Case studies

Cobham Aerospace Connectivity: RapiCover continues to deliver on the most challenging targets
DO-178B Level A Embraer FCS
Validation of COTS Ada Compiler for Safety-Critical Applications
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

Careers

Careers menu

  • Current opportunities & application process
  • Working at Rapita

US office

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

UK office

+44 (0)1904 413945
info@rapitasystems.com
Atlas House
York, YO10 3JB
UK

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

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
This block is broken or missing. You may be missing content or you might need to enable the original module.
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

    • CAST-32A Compliance Package
    • 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
    • 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 Testing
    • WCET Tools
    • Worst Case Execution Time
    • Timing analysis (WCET) & Code coverage for Matlab Simulink

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