Unit Testing with VectorCAST and AUTOSAR
Vector TechDay – Software Testing with VectorCAST
V1.0 | 2018-11-15 Agenda
u Introduction Unit Testing Demo Working with AUTOSAR Generated Code Unit Testing AUTOSAR SWCs Conclusions
2 Introduction Types of Testing
Unit Testing Integration Testing System Testing
Individual units or modules are Individual modules are grouped Testing is performed on the whole tested. It involves testing of source together and tested. The purpose is system by checking whether the code by developers. to determine that modules are system or application meets the working as expected once they are requirement specification integrated. document.
3 Introduction How Does Unit Testing Work?
Source Code Test Harness
Test Unit(s) Driver Under Test Real Dependents (.obj files)
Unit(s) Under Test Stubbed Dependents
4 Introduction What is VectorCAST?
ALM Analysis Model-Based Requirements Gateway Metrics Reporting Development
Parallel Continuous Testing Integration
System Test Code Coverage Unit Test Static Analysis Compiler, Debugger, Technical Debt RTOS, Simulator Legacy Testing
5 Introduction How Does VectorCAST Help You?
Time to Test Weeks Minutes
Frequency of Test Per Release Per Change
Who Runs Tests QA Everyone
Level of Automation Manual Automatic
6 Introduction How Does VectorCAST Enable Unit Testing?
u Creates an automated and repeatable process for developers
u Automatically generates your Test Harness including Smart Stubs Requirements System Specification u Provides an intuitive user interface for Testing generating test cases
u Contains a Command Line Interface (CLI) Architecture Integration Testing for headless test execution
u Supports C, C++, and Ada System Unit Design Testing
Coding
7 Introduction VectorCAST Enables Multi-Target Testing?
Source Code Host Environment Target/Simulator
parse raw VectorCAST RSP source code Test Harness Execute Tests
auto generate all drivers and stubs
Test Tests Reports PASS FAIL PASS Pass/Fail Results PASS and Ethernet, Serial Link, JTAG Code Coverage 100% Coverage
8 Introduction VectorCAST Supports Your Embedded Tool Chain
u Push button on-target and simulator test execution
u Built-in support for more than 30 compiler families u Hundreds of chip and runtime combinations
u Full-featured integrations with: u Cross Compiler Language Extensions u Embedded Debuggers u JTAG Probes u Real-Time Operating Systems
Q What do all these companies have in common?
A None of these companies offer a test automation platform. VectorCAST provides test automation to all of these environments.
9 Introduction What is AUTOSAR?
Learn More About AUTOSAR
https://www.autosar.org/
10 Introduction AUTOSAR Partners
Core Partners
Development Partners
Associate Partners
Attendees
Premium Partners
Vector Informatik GmbH
Generic Standard Tools and Semi- TIER 1 Software Services conductor
11 Introduction Automotive Trends
Cloud / Backend u support of high performance processors u high bandwidth
u service based architectures
u open source, agile development
u dynamic and updatable
u internet
u safe
u secure Embedded Systems u embedded integration and debugging
u automotive supply chain
u automotive communication protocols
u automotive diagnostics AUTOSAR Classic
12 Introduction Adaptive – best of two worlds
Cloud / Backend u supportAdaptive of high performance AUTOSAR processors system and mobility strategies u high bandwidth deep learning u service based architectures u open source, agile development
u dynamic and updatable
u internet On board Supercomputers multipurpose computing servers connectivity, gateways, HMI u safe automated driving u secure mastered by OEM u embedded integration and debugging AUTOSAR Adaptive u safe u automotive supply chain u secure Embedded Systems u automotive communication protocols u embedded integration and debugging intelligent sensors and actuators u automotive diagnostics basic functions u automotive supply chain fallback computing u automotive communication protocols
u automotive diagnostics AUTOSAR Classic
13 Introduction Being Prepared for the Next-Generation of ECUs
Infotainment Adaptive MICROSAR is a Seamless complete basic software interoperability with solution up to ASIL D classic AUTOSAR ECUs
Additional, high source: fotolia performance ECUs hosting applications for ADAS upcoming use cases
Applications installed and Connectivity started during runtime
Development of
applications in the Dynamic Software Platform ecosystem of POSIX- based OS (Linux, PikeOS, QNX, Integrity, …)
14 Introduction AUTOSAR Product Comparison
AUTOSAR Classic Platform - CP AUTOSAR Adaptive Platform - AP
Application Actuator Sensor Application Software Software Software Software SWC SWC AUTOSAR SWC Component Component Application Layer Component Component Runtime Environment for Adaptive Applications AUTOSAR Interface AUTOSAR Interface AUTOSAR Interface AUTOSAR Interface ARA ARA ARA
Runtime Environment API API Adaptive AUTOSAR Services
Time Execution Service Service Service Management Management Update Memory Communication Security System Services Configuration Diagnostics Services Services Management API API Management I/O Hardware Abstraction Persistency Memory Communication Operating Onboard Device Complex Hardware Hardware System Abstraction Drivers Abstraction Abstraction API API API API Platform Logging and Hardware Communication Health Tracing Acceleration Management Bootloader Management Microcontroller Communication Memory Drivers I/O Drivers Drivers Drivers Adaptive AUTOSAR Foundation
Microcontroller (Virtual) Machine / Hardware
Real Time Requirements
Safety Critical
Computing Power
15 Agenda
Introduction u Unit Testing Demo Working with AUTOSAR Generated Code Unit Testing AUTOSAR SWCs Conclusions
16 Unit Testing Demo Complete Ethernet Demo
The demo has several ECUs with different tasks. The central ECU is MyECU. MyECU is connected to one Ethernet channel Ethernet1 and to two CAN channels CAN1 and CAN2. On each CAN channel there are two ECUs connected, USDnode01, USDnode02 on CAN1 and USDnode03, USDnode04 on CAN2.
On Ethernet side there are seven further ECUs designed for the different demo cases.
u DownloadUDSnode01 to DownloadUDSnode04 are used for flash simulation of UDSnodes0x on CAN
u TimeSync being the Slave node to receive synchronized global time from MyECU
u AvTPAudio to show AVB behavior
u Terminal for the SOME/IP demo.
17 Unit Testing Demo Focus on MyECU
MyECU is the central ECU of the Ethernet Demo. It is running MICROSAR4 BSW and implements following functionality:
u Provider of SOME/IP services u Maths including methods Add, Divide, Multiply and Subtract as well as the event Triangle. These methods implement a simple version of a calculator, and the event generates a triangle signal.
u Many additional included features not described here…
18 Unit Testing Demo Test the SOME/IP Math Service
u We will select the AUTOSAR Software Component (SWC) SWC_service_Math_Server.c from the application source folder to unit test
19 Unit Testing Demo Sample function to be tested
20 Unit Testing Demo Create Requirements
u SOME/IP Maths Requirements:
21 Agenda
Introduction Unit Testing Demo u Working with AUTOSAR Generated Code Unit Testing AUTOSAR SWCs Conclusions
22 Working with AUTOSAR Generated Code What do I Unit Test?
u Most of the time your Application SWCs
u Possibly Complex Device Drivers (CDDs) or Microcontroller Abstraction Layer (MCAL) Drivers
u Maybe custom BSW components
AUTOSAR Classic Platform - CP AUTOSAR Adaptive Platform - AP
Application Actuator Sensor Application Software Software Software Software SWC SWC AUTOSAR SWC Component Component Application Layer Component Component Runtime Environment for Adaptive Applications AUTOSAR Interface AUTOSAR Interface AUTOSAR Interface AUTOSAR Interface ARA ARA ARA
Runtime Environment API API Adaptive AUTOSAR Services
Time Execution Service Service Service Management Management Update Memory Communication Security System Services Configuration Diagnostics Services Services Management API API Management I/O Hardware Abstraction Persistency Memory Communication Operating Onboard Device Complex Hardware Hardware System Abstraction Drivers Abstraction Abstraction API API API API Platform Logging and Hardware Communication Health Tracing Acceleration Management Bootloader Management Microcontroller Communication Memory Drivers I/O Drivers Drivers Drivers Adaptive AUTOSAR Foundation
Microcontroller (Virtual) Machine / Hardware
23 Working with AUTOSAR Generated Code Tips & Techniques
u From the Project View right click your environment | Properties
24 Working with AUTOSAR Generated Code Tips & Techniques
u Monitor your build times
u Tools | Options | GUI | Message window timestamps
25 Working with AUTOSAR Generated Code Tips & Techniques
u Disable comments on the Preprocessor command for your compiler
u For Visual Studio 2013 remove “/C”
u One sample environment reduce u Build time from 9:03 to 6:11 (32%) u Build size from 1.5GB to 322MB (79%)
u Why? u See next slide
26 Working with AUTOSAR Generated Code Tips & Techniques
u By design AUTOSAR multiply includes many header files
u VectorCAST flattens the include chain during the harness generation process
u This results in very large source files
u Unit testing does not need source code comments
u Use the Preprocess comment to strip them out
u MemMap.h tends to be the biggest contributor
27 Working with AUTOSAR Generated Code Tips & Techniques
u AUTOSAR Macros such as FUNC, P2VAR, and defines get expanded in the coverage viewer
u Source code
u Coverage viewer
28 Agenda
Introduction Unit Testing Demo Working with AUTOSAR Generated Code u Unit Testing AUTOSAR SWCs Conclusions
29 Unit Testing AUTOSAR SWCs Start with a VectorCAST Project
u File | New | VectorCAST Project | Empty Project
30 Unit Testing AUTOSAR SWCs Create Unit Test Environments
u Under Group_1 | Create Unit Test Environment | Interactive
31 Unit Testing AUTOSAR SWCs Import Requirements
u In three steps: u Set options, get fields
u Map attributes to fields, import
u View
32 Unit Testing AUTOSAR SWCs Write Test Cases
u Insert Test Case
u Set Input & Expected Values
u Execute
33 Unit Testing AUTOSAR SWCs Increase Your Coverage
34 Unit Testing AUTOSAR SWCs Link Requirements & Execute Tests
35 Unit Testing AUTOSAR SWCs Export Results
36 Unit Testing AUTOSAR SWCs Workflow
u Start with a VectorCAST Project
u Create Unit Test Environments
u Import Requirements
u Write Test Cases
u Increase Your Coverage
u Link Requirements & Execute Tests
u Export Results
uLive Demo
37 Conclusions
Do your AUTOSAR Unit Testing Faster with VectorCAST
u Fast building and executing of your unit test harnesses on host or your ECU
u Quickly create test cases and increase your test coverage with the GUI
u Easy requirement to test case linking and exporting test results
38 More Information! Visit our Website for: > News > Products > Demo Software > Support > Workshops > Contact Addresses
www.vector.com Author: Krueger, Kurt Vector North America
39 © 2018. Vector North America Inc. All rights reserved. Any distribution or copying is subject to prior written approval by Vector. V1.0 | 2018-11-15