Featured Webinar: AI-Enhanced API Testing: A No-Code Approach to Testing | Watch Now

ISO 26262 Software Compliance in the Automotive Industry

Structural Code Coverage

Collecting and analyzing code coverage metrics is an important aspect of safety-critical automotive software development. Code coverage measures the completion of test cases and executed tests. It provides evidence that validation is complete, at least as specified by your stakeholder and compliance requirements.

It also identifies dead code. This is code that can logically never be reached. It demonstrates the existence of unintended behavior. Code that isn’t covered by any test is a liability because its behavior and functionality are unknown.

The amount and extent of code coverage depend on the safety integrity level and coverage percentage goals. For safety-critical applications, 100% code coverage is the norm. The higher the integrity level, the higher the rigor. Inevitably the number and complexity of test cases will grow.

The following table shows the recommendations for types of code coverage at each ISO 26262 ASIL.

ISO 26262 Part 6, 9.4.4:2018 - Structural coverage metrix
ISO 26262 Part 6, 9.4.4:2018
Blue circle with 1a written in the center in white text.

Statement Coverage

Statement coverage requires that each program statement be executed at least once and is recommended at the lower ASIL levels. Branch and MC/DC coverage encompass statement coverage.

Blue circle with 1b written in the center in white text.

Branch Coverage

Branch coverage ensures that each decision path of a branch (if-then-else constructs) is executed.

Blue circle with 1c written in the center in white text.

Modified Condition/Decision Coverage (MC/DC)

Modified condition/decision coverage (MC/DC) requires the most complete code coverage to ensure test cases execute each decision branch and all the possible combinations of inputs that affect the outcome of decision logic. For complex logic, the number of test cases can explode, so the modified condition restrictions are used to limit test cases to those that result in standalone logical expressions changing. See this tutorial from NASA.

Advanced unit test automation tools such as Parasoft C/++test provide all these code coverage metrics. C/C++test automates this data collection on host and target testing and accumulates test coverage history over time. This code coverage history can span unit, integration, and system testing to ensure coverage is complete and traceable at all levels of testing.

Increasing Code Coverage With Automated Unit Test Case Creation

The creation of productive unit tests has always been a challenge. Functional safety standards compliance demands high-quality software, which drives a need for test suites that affect and produce high code coverage statistics. Teams require unit test cases that help them achieve 100% code coverage.

This is easier said than done. Analyzing branches in the code and trying to find reasons why certain code sections are not covered continues to steal cycles from development teams.

Parasoft Coverage Advisor

Parasoft C/C++test resolves the coverage gaps in test suites. Parasoft discovered how to use advanced static code analysis (data and control flow analysis) to find values for the input parameters required to execute specific lines of uncovered code.

In complex code, there are always those elusive code statements of which it is exceedingly difficult to obtain coverage. It’s likely there are multiple input values with various permutations and possible paths that make it mind twisting and time consuming to decipher. But only one combination can get you the coverage you need. Parasoft makes it easy to obtain coverage of those difficult to reach lines of code.

Select the line of code you want to cover, and the Coverage Advisor will tell you what input values, global variables, and external calls you need to stimulate the code and obtain coverage.

Invoking Coverage Advisor by right-clicking
Invoking Coverage Advisor by right-clicking on the line of code.

Code coverage solutions provided by coverage advisor
Two test case solutions provided by Coverage Advisor.

The figure on the right shows an analysis report providing the user with a solution. The Pre-conditions field expresses:

  • The range and input values for mainSensorSignal and coSensorSignal
  • The expected outputs from the external calls

Upon creating the unit test case with these set parameter values and stubs for external calls, the user will obtain coverage of the line selected, plus the additional lines expressed in the Expected Coverage field.

Dark blue banner with image of man talking to woman holding a tablet in hand in a server room.
Image of man and woman with tablet in hand having a discussion in a server room.

Elevate your software testing with Parasoft solutions.