36
Satisfying ASIL-D Code Coverage Objectives in the Target Environment without Code Instrumentation Embedded Testing ─ Munich 04 / July / 2019

Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

Satisfying ASIL-D Code Coverage Objectives in the

Target Environment without Code Instrumentation

Embedded Testing ─ Munich • 04 / July / 2019

Page 2: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

2 / 37 04/July/2019

• Introduction

• Modern Automotive Chips

• Making Use of the Trace Capability

• Measuring Code Coverage without Instrumentation

• Conclusion

Agenda

Page 3: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

3 / 37 04/July/2019

Functional Safety for Complex Software

“Software is eating the world”* is catching the automotive industry

• Increasing software complexity

• Bundling of software components with mixed criticality into a small number of powerful ECUs

• Demand for high software portability across different configurations and platforms

* Marc Andreessen, 2011

Software Complexity Functional Safety ISO 26262

Page 4: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

4 / 37 04/July/2019

Software Verification in ISO 26262

• Multiple testing stages with different focuses

• Code coverage as measure of completeness and adequacy of testing activities

• Emphasis of testing in the target environment

Statement Coverage

Branch Coverage

MC/DC (ASIL D)

Function Coverage (ASIL D)

Call Coverage (ASIL D)

Testing of the

Embedded Software

Integration test

Unit test

Coding

Page 5: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

5 / 37 04/July/2019

Goal of the Presentation

Introduce a code coverage measurement method that

• is applicable to all code coverage metrics mentioned in ISO 26262

• works without code instrumentation

• is carried out in the target environment

Page 6: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

6 / 37 04/July/2019

ELF File

ELF File

Object

Code

for selected

optimization level

Debug

Information

source code

object code

Cross Compiler/

Linker

AUTOSAR

Source Code

Application

Source Code

Page 7: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

7 / 37 04/July/2019

Agenda

• Introduction

• Modern Automotive Chips

• Making Use of the Trace Capability

• Measuring Code Coverage without Instrumentation

• Conclusion

Page 8: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

8 / 37 04/July/2019

Test Environment (Automotive Component)

Application Layer

AUTOSAR Software Stack

Target

Applications

Runtime environment

Complex

device

driver

Microcontroller

Services layer

ECU abstraction layer

Microcontroller abstraction layer

Page 9: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

9 / 37 04/July/2019

Test Environment (Automotive Component)

• Debug and Trace interface offer the possibility to get details about the program execution

• Debug and Trace interface is already used in many projects for profiling purposes

a

Target

Hardware multicore chip

Debug Interface

Trace Interface

Page 10: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

10 / 37 04/July/2019

Parallel Trace Port: Zynq UltraScale+

16-bit TPIU parallel trace port

250 Mhz DDR

1 Gbyte/s

a

Trace Data in ETM/PTM Protocol a

MicroBlaze

Cortex-A53

SWD two debug pins and a clock

Performance

Cores

Realtime

Cores

Platform

Management

Cortex-R5

Page 11: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

11 / 37 04/July/2019

Serial Trace Port: High-End RH850

Aurora Trace Serial trace port

4 lane, 6,25 Gbit/s per lane

2,5 Gbyte/s

JTAG a

Trace Data in Nexus Protocol a

RH 850

RH 850

RH 850

Master

Cores

Performance

Cores

Auxiliary

Cores

ICU-M

Page 12: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

12 / 37 04/July/2019

Debug and Trace Tools for All Test Phases

Testing of the Embedded Software

JTAG Debugger

with Trace

JTAG Debugger

with Trace

Emulation System

Debugger for Instruction Set

Simulator with Trace

Debugger for Virtual Target

with Trace

Hardware assisted

Software-only

Unit and Integration Test

Early Testing

without Hardware

Evaluation Board ECU

Scalability and

Quick Feedback

Debugger for Virtual Target

with Trace

Debugger for Instruction Set

Simulator with Trace

Page 13: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

13 / 37 04/July/2019

Agenda

• Introduction

• Modern Automotive Chips

• Making Use of the Trace Capability

• Measuring Code Coverage without Instrumentation

• Conclusion

Page 14: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

14 / 37 04/July/2019

Core Trace

Trace Packets

• Branches taken

• Loads/stores

• Other information

Trace

Generation

Logic

Core

Page 15: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

15 / 37 04/July/2019

Program Execution Details Derived from Trace Packets

Branches Taken + Object Code

Branches Taken (Nexus)

Sequential program flow between

two branches can be reconstructed

with the help of the object code Object Code

for selected

optimization level

ELF File

Page 16: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

16 / 37 04/July/2019

Bridging the Gap to the Source Code

Trace Packets + Object Code + Source Code

The debug information

provided by the elf file

can be used to merge the

source code lines into the

trace listing

ELF File

Debug

Information

(source code

object code)

Debug

Information

source code

object code

Page 17: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

17 / 37 04/July/2019

Agenda

• Introduction

• Modern Automotive Chips

• Making Use of the Trace Capability

• Measuring Code Coverage without Instrumentation

• Conclusion

Page 18: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

18 / 37 04/July/2019

Trace-based Code Coverage

Unit Testing

• Statement Coverage

• Branch Coverage

• MC/DC (ASIL D)

Integration Test

• Function Coverage (ASIL D)

• Call Coverage (ASIL D)

Page 19: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

19 / 37 04/July/2019

Function Coverage

Analyzes: Functions

Definition: Every function in the program has been invoked at least once.

Trace-based Code Coverage: A function achieved Function Coverage when

at least one corresponding object code instruction has been executed

Page 20: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

20 / 37 04/July/2019

Function Coverage

Execution of an object code line

function coverage 100%

Page 21: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

21 / 37 04/July/2019

Function Coverage

Page 22: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

22 / 37 04/July/2019

Function Coverage

Function Coverage can be performed on final code

Object Code fully optimized

Code Coverage Test Result

Target Hardware multicore chip

Test Run

Page 23: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

23 / 37 04/July/2019

Modified Condition/Decision Coverage (MC/DC) Analyzes: Decisions based on independence pairs

Definition: - each point of entry and exit is invoked

- each decision has taken all possible outcomes

- each condition in a decision is shown to independently

affect the outcome of that decision

Page 24: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

24 / 37 04/July/2019

Independence Pairs

Independence Pairs for condition

(A&&B)||C

• All conditions except the one to be

tested are fixed

• The decision has to change its outcome

when the condition under test is

changed

# A B C

1 F F F F

2 T F F F

3 F T F F

4 F F T T

5 T T F T

6 T F T T

7 F T T T

8 T T T T

Page 25: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

25 / 37 04/July/2019

Bridging the MC/DC Gap

Interpretation Trace-based Code Coverage:

All independence pairs are successfully tested

?

Page 26: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

26 / 37 04/July/2019

Bridging the MC/DC Gap

1. To verify the conditions

When analyzing the program execution,

it must be clear from the object code

whether a condition was TRUE or

FALSE.

2. To check the independence pairs

a mapping of decisions to object code

is needed.

Page 27: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

27 / 37 04/July/2019

1. When analyzing the program

execution, it must be clear from the

object code whether a condition was

TRUE or FALSE.

For this, each condition must be

mapped to the object code by a

conditional jump / instruction. This

can, however, only be ensured if

code optimization is switched off.

Bridging the MC/DC Gap – Disable Optimization

Page 28: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

28 / 37 04/July/2019

Bridging the MC/DC Gap – Perform Static Code Analysis

2. Mapping of decisions to object code

is needed

Answers the question of whether Branch

Taken/Instruction Executed means

TRUE or FALSE

Page 29: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

29 / 37 04/July/2019

Modified Condition/Decision Coverage (MC/DC)

Extended code analysis: Mapping between a decision statement an its conditions

to the conditional branches/instructions in the object code

Page 30: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

30 / 37 04/July/2019

Modified Condition/Decision Coverage (MC/DC)

Page 31: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

31 / 37 04/July/2019

Modified Condition/Decision Coverage (MC/DC)

Code Coverage Test Result

Target Hardware multicore chip

Test Run 1

Object Code fully optimized

Test Result

Both Results

have to be equal

Target Hardware multicore chip

Test Run 2

Object Code not optimized

Page 32: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

32 / 37 04/July/2019

Agenda

• Introduction

• Modern Automotive Chips

• Making Use of the Trace Capability

• Measuring Code Coverage without Instrumentation

• Conclusion

Page 33: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

33 / 37 04/July/2019

Metric Code Coverage Extended Code Analysis

Statement Coverage On final code ─

Branch Coverage Reduced optimization Mapping of decisions to object

code

MC/DC On not-optimized code Mapping of decisions/

conditions to object code

Function Coverage On final code ─

Call Coverage On final code

To tag inline function, function

pointer, call-less function

Summary

Page 34: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

34 / 37 04/July/2019

• Trace-based code coverage is applicable to all methods of ISO 26262

• Trace-based code coverage can be performed at any stage of the project

• Trace-based code coverage allows testing at handwritten and autogenerated code

• Trace tools already employed can be used at no extra cost

• Long-term testing by streaming trace to host computer

• Testing with cross-compiler used to generate final code

• Virtual verification or hardware-based testing

Advantages

Page 35: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

35 / 37 04/July/2019

Trace-based Code Coverage

• Live coverage for all metrics

• Improved display for MC/DC

• ADA support

Compiler

• Special optimizations adapted to Code Coverage requirements

• Source code analysis results for method in use included in debug information

Further Improvements

Page 36: Satisfying ASIL-D Code Coverage Objectives in the Target ...nohau.eu/wp-content/uploads/presentation_asild_coverage.pdf · 04/July/2019 34 / 37 •Trace-based code coverage is applicable

Andrea Martin • [email protected] • 04 / July / 2019