27
KULeuven – campus KHBO 19/03/2013 EP part of ReMI 1 Embedded software ontwikkeling dr. ing. Jeroen Boydens Hoe passen de principes uit software engineering hierin? Research @ breakfast 19/03/2013 Contents 2 1) EP research: part of ReMI 2) TDD4ES Research overview 3) MC4ES Research overview 4) FS4ES Research proposal 5) Workshop: Testgedreven ontwikkelen van Embedded Software 28/05/13

Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 1

Embedded software ontwikkeling

dr. ing. Jeroen Boydens

Hoe passen de principes uit

software engineering hierin?

Research @ breakfast

19/03/2013

Contents

2

1) EP research: part of ReMI

2) TDD4ES Research overview

3) MC4ES Research overview

4) FS4ES Research proposal

5) Workshop: Testgedreven ontwikkelen van Embedded

Software – 28/05/13

Page 2: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 2

1) EP research: part of ReMI

3

1) EP research: part of ReMI

4

dr. ing. Jeroen Boydens

+ founder

+ instructor

+ project leader

@ep_research

http://ep.khbo.be

Founded: 2006 – 2007

ing. Sille Van Landschoot

+ MC4ES

+ TDD4ES

+ academic staff

ing. Piet Cordemans

+ PhD student

+ TDD4ES

+ academic staff

ing. Wim Catteeuw

+ APS4ES

ing. Nico De Witte

+ MC4ES

+ academic staff

ing. Robbie Vincke

+ MC4ES

Page 3: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 3

EP research: threefold mission

5

Threefold mission:Education Research Social services

Software courses Prof. Bachelor EO/ICT

Ac. Bachelor EO/ICT

Master ICT

Fundamental Concurrent software

Software testing

Transactional behavior

Applied IWT/Tetra, theses Embedded development

methodologies

Embedded multi-core

Seminars Software testing

State-of-the-art

technologies

LED eg. Medical Reminder

System

Internal projects

Contents

6

1) EP research: part of ReMI

2) TDD4ES Research overview

3) MC4ES Research overview

4) FS4ES Research proposal

5) Workshop: Testgedreven ontwikkelen van Embedded

Software – 28/05/13

Page 4: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 4

7

2) TDD4ES research overview

Test on target Test on host Remote testing

Case studies

3 strategies

Literature study

Manual

CMS

http://ep.khbo.be/TDD4ES

Workshop

a

a

a

r

a

a

a

r /{C;}{C++;}

a

a

a

r

User committee TDD4ES IWT/090191

8

www.edna.euwww.tesco.be

www.qstar.be

www.marelec.com

www.unitron.be

www.summa.be

www.sirris.be

www.televic.com

www.newtec.eu

www.vandewiele.com

www.dspvalley.comwww.kdg.be

www.kuleuven.be www.fmtc.be

www.iwt.be

Page 5: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 5

Problem statement

9

Two trends influence the way embedded software is developed

1) Embedded system level:

Embedded software plays a more important role

2) Global level:

Embedded systems are becoming more pervasive in our

lives (even in critical domains)

• Consumer electronics

• Automotive / transportation

• Medical applications

Risk = Importance x Chance of failure

12

Embedded quality assurance

10

Quality assurance in embedded software development is

mostly limited to debugging and final testing, only focusing on

the current issue…

Embedded software testing gap

Importance versus state of testing

Lifecycle

Co

st

of

Re

pa

ir

Specification Programming ProductionDesign

1000

0

100

10

© B.W. Boehm, 1981

Software Engineering Economics

Page 6: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 6

Lifecycle

Co

st

of

Re

pa

ir

Specification Programming ProductionDesign

1000

0

100

10

© B.W. Boehm, 1981

Software Engineering Economics

Automated testing

11

1. Find bugs early

2. Measurable quality

3. Increasing confidence

4. Detecting regression

5. Encapsulating third party

code

Timely detection of bugs by automated testing

Running test suite frequently during development

Incrementally expanding the test suite

Support from unit testing framework

Test-Driven Development

12

TDD cycle

1. Write failing test (red)

• New behavior

• Minimal skeleton to get through compilation

2. Write code to pass test (green)

• Minimal implementation

3. Refactor

• No new behavior

• Clean code

• Keep tests passing

Page 7: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 7

Test-Driven Development

13

Advantages

1. Code is tested while it’s written

2. Fast feedback cycle

3. Extensive & safe refactoring

4. Focus on current functionality

5. Tests become living documentation

Disadvantages

1. 2x code

increase development time

Test framework

14

Why?

• Organization

• Execution

• Reuse

• Reporting

Many exist for C/C++ (>40)minUnit, CppUnitLite, UnitTest++, GoogleTest, CxxTest, EmbUnit,

CppUTest, CppUnit, Unity…

Or: write your own (TDD-style)

Page 8: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 8

xUnit test framework

15

General model

Write test first

• Inspiration (test list)

• Specifications

• Use cases

• Notes

• …

• Procedure

1. Define interface

2. Select values for test

« By writing a test before implementing the item under test,

attention is focussed on the item’s interface and observable behavior »

Beck (2000)

TDD strategy

16

Page 9: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 9

TDD tests

17

Black box tests vs. White box tests

a.k.a. glass box tests

• Internal perspective• Implementation• Focus on developer• 20% coverage• Test Afterwards

• External perspective• Specification• Focus on end-user• 80% coverage• Test First

In conclusion

18

• Broken window syndrome

o One broken test, which remains unresolved,

leads quickly to many broken tests.

• Test cancer [Fowler]

o Removing broken tests is a bad habit.

Testing & Embedded co-design

about changing requirements

Maintaining tests is necessary

Page 10: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 10

Embedded TDD challenges

19

TDD

1. Tests + Program + Unit

test framework

Embedded

1. Limited resources

2. Automated testing

3. Fast programming

cycle

2. Hardware

dependencies

3. Slow programming

cycle

Embedded constraints

20

↔ Embedded TDD challenges

1. Limit the memory footprint needed for TDD on target

hardware

2. Tests for

1. Hardware independent code

2. Hardware aware code

3. Hardware specific code

3. Maintain a fast programming cycle

Page 11: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 11

TDD strategies for embedded

21

Test on target Remote testing

{C;}{C++;}

a

a

a

r

Test on host

{C;}{C++;}

a

a

a

r {C;}{C++;}

a

a

a

r

/

TDD strategies for embedded

22

1. Limited number of

tests

2. Minimalistic

framework

3. Program code

Test on target Test on host Remote testing

1. Unlimited number

of tests

2. Full option

framework

3. Program code with

hardware

virtualization

1. Unlimited number

of tests

2. Full option

framework with

remote testing

functionality

3. Program code with

remote testing

functionality

/{C;}{C++;}

a

a

a

r

a

a

a

r

a

a

a

r

1. No cross-compiling

Page 12: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 12

Evaluation: Test on Target

24

Advantages

• No cross-compiling

Disadvantages

• Isolating hardware behavior typically enlarges

test cases (mocks)

- Processing power

- Memory footprint

• Slow development cycle

- Frequent target programming

1. Develop test on host

o Mock hardware

o Correspondence with driver on target

2. Migrate test to target

o Mock is replaced with real hardware driver

Test passes: mock & implementation = OK

OR

Test fails: mock & implementation != OK

Test on Host: Mock verification

26

Page 13: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 13

Evaluation: Test on Host

28

Advantages

• Fast programming cycle

• Hardware does not need to be available

• Migration supported by test suite

Disadvantages

• Verification on target needed

o Cross-compilation issues

o Mock driver verification

Remote testing

31

Background

• Inter Process Communication (IPC)

• Remote procedure call (RPC)

• Common Object Request Broker Architecture

(CORBA)

Operation

• Tests / framework on host

• Program / drivers on target

• Management mechanism on both

Page 14: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 14

Evaluation: Remote Testing

34

Advantages

• Scalable alternative for test on target (ROI)

• Fast prototyping

o Stable driver base on target

o On host development of higher level tiers

Disadvantages

• Remote testing system

o Development

o Overhead: memory / processing power

TDD4ES strategy evaluation

36

---Test & Program

on target

+++Test & Program

on host

+/-Broker on target

+++Real drivers

---Only virtual

drivers

+++Real drivers

---Frequent target

programming

+++Development

limited to host

-Frequent target

programming*

Resources

Slow

Test on hostTest on target Remote testing

Dependency

a

a

a

r

a

a

a

r /{C;}{C++;}

a

a

a

r

Page 15: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 15

Literature

37

• K. Beck. Test-Driven Development: By Example. Addison-Wesley, 2003.

• K. Beck and C. Andres. Extreme Programming Explained: Embrace Change (2nd ed.).

Addison-Wesley, 2004.

• B.W. Boehm. Software Engineering Economics (Prentice-Hall Advances in Computing

Science & Technology Series). Prentice Hall PTR, October 1981.

• J. Boydens, P. Cordemans, and E. Steegmans. Test-Driven Development of Embedded

Software. In European Conference on the Use of Modern Information and Communication

Technologies, 2010.

• E. Dijkstra. The humble programmer. Commun. ACM, 15(10):859866, 1972.

• M. Feathers. Working Effectively with Legacy Code. Prentice Hall PTR, 2005.

• M. Fowler. UML Distilled (3rd ed.). Addison-Wesley, 2004.

• M. Fowler. Refactoring: Improving the design of existing code. Addison-Wesley, 1999.

• E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design patterns: Elements of Reusable

Object-Oriented Software. Addison-Wesley, 1995.

• J. Grenning. Progress before hardware. Agile Alliance Newsletter, 4:74_79, 2004.

Literature continued

38

• J. Grenning. Test-Driven Development for Embedded C. Pragmatic bookshelf, 2011.

• M. Karlesky, W. Bereza, and C. Erickson. Effective test driven development for embedded

software. In IEEE 2006 Electro/Information Technology Conference, 2006.

• R. Koss, and J. Langr. Test-Driven Development in C. In C/C++ Users Journal, 2002.

• M. Müller and F. Padberg. About the return on investment of test-driven development. In

International Workshop on Economics-Driven Software Engineering Research EDSER-4,

2003.

• R. Osherove. The Art of Unit Testing. Manning, 2009.

Page 16: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 16

Contents

39

1) EP research: part of ReMI

2) TDD4ES Research overview

3) MC4ES Research overview

4) FS4ES Research proposal

5) Workshop: Testgedreven ontwikkelen van Embedded

Software – 28/05/13

3) MC4ES Research overview

40

Focus points

Literature Case Studies

PandaboardARM Cortex-A9

• Nonatomic operations

• Two-stage access bug pattern

• Wrong lock or no lock

• Double-checked locking

• A “blocking” critical section

• The sleep() bug

• Losing a notify

• Orphaned thread bug

TestingDesign patterns

• Thread Pool Pattern• Map/Reduce• Loop parallelism• Planar Pattern• …

Tools

• Performance

• Safety

• Debugging

• Etc.

Implementation

Task Pool

CPU Cores

Scheduler

Busy Busy Idle Busy Idle

Page 17: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 17

User committee MC4ES IWT/110174

41

Multicore Embedded

42

Moore’s Law Amdahl’s Law

Page 18: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 18

Design Patterns

43

• A design pattern is the

description of a general

solution to a recurring

problem [E. Gamma]

• Origin: OO-programming

• Adopted for HPC (UC Berkeley - OPL)

Embedded Parallel Software

Layered Model

44

PARALLEL SOFTWARE

PARALLEL EXECUTION DESIGN SPACE

SUPPORTING STRUCTURES

OPTIMIZATION DESIGN SPACE

FINDING CONCURRENCY DESIGN SPACE

SEQUENTIAL SOFTWARE

Architectural Patterns

Structural Patterns

Algorithm Strategy Patterns

Implementation Strategy Patterns

NEW CONCEPT

INTERFACE TESTS

Page 19: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 19

Some examples …

45

• Thread Pool Pattern

o Implementation Strategy Pattern (lower level)

• Problem? Perform parallel tasks with a static number of

available units of executions

• Solution:

o Create a static thread pool

o Construct a shared task queue

o Each CPU/thread can pop a task from the queue

Some examples …

46

• Map Reduce

o Structural Pattern

• Problem? same operation

on a large dataset

• Solution:

o Construct a set of

data-independent

operations

o Map data-chuncks to

these operations

o Reduce the sub-results

to a general result

DATASET

CPU core

CPU core

CPU core

CPU core

Result

Data A

Data B

Data C

Data D

Page 20: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 20

Academic case study: FFT

47

• Radix-2 Cooley-Tukey Algorithm

Input dataset N = 8

log2N stages

Parallelizing: FFT

51

• Synchronization before last stage to avoid data races

• Parallel speedup 195%

GENERATE TWIDDLE

LUT

BIT REVERSING

BUTTERFLY OPERATIONS

INPUT OUTPUT

BUTTERFLY OPERATIONS

LAST STAGE

LAST STAGE

Synchronization point

Page 21: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 21

Measurements

52

2 CPU’s

Amdahl’sLaw

0

0,25

0,5

0,75

1

1,25

1,5

1,75

2

2,25

64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288

Para

llel S

peed

up

N

Thread createoverhead

Profiling Parallel code

53

• ARM DS-5 Streamline Debugger/Profiler

Bitreversing // twiddleLUT FFT(N/2)

Last stage

Page 22: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 22

Contents

56

1) EP research: part of ReMI

2) TDD4ES Research overview

3) MC4ES Research overview

4) FS4ES Research proposal

5) Workshop: Testgedreven ontwikkelen van Embedded

Software – 28/05/13

4) FS4ES Research proposal

• FS4ES: Functional Safety for Embedded Software

• Project team: KHBO(KU Leuven) + KdG(UA) + FMTC

• If accepted o 2 years, starting in October 2013

o budget for 71 mm

• Tetra project

o funded by IWT

o Tetra = Technology Transfer to improve innovation in SME in Flanders

KHBO, 6/2/2013 57

Page 23: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 23

FS4ES Objectives

58

1) Design patterns for Functional Safety in Embedded

software

2) Applying testing techniques, converting functional

requirements into tests, simulating hardware behavior

3) Collecting implementation guidelines

4) Investigating tool support, focus on tools affordable for

SME’s

5) Providing examples in academic and industrial context

Project User Group:

determines the course of the project• Scientific

- prof. dr. ir. Eric Steegmans (KU Leuven)

- prof. dr. ir. Yolande Berbers(KU Leuven)

- prof. dr. Serge Demeyer (Universiteit Antwerpen)

- Altreonic (Eric Verhulst, CTO)

- ir Isabelle Vervenne (KHBO)

• Valorisation

- DSP-Valley, FMTC, IMEC, Sirris

• Companies

- Atlas Copco Airpower NV

- Bombardier NV

- Cochlear Benelux NV

- Dana - Spicer Off-Highway Product Group - Dana Holding Corporation

- E.D.&A. NV

- EiA – Grammer

- Emrol bvba

- Flanders’ DRIVE

- Ferranti Computer Systems NV

- LMS International NV

- Melexis Technologies NV

- QSpin Vlaanderen bvba

- Silliberty BVBA

- Tass Belgium NV

- Televic RailNV

- Teletask BVBA

- Verhaert New Products & Services NV

• Still open for extension!

59

Page 24: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 24

KHBO, 6/2/2013 60

KHBO, 6/2/2013 61

Page 25: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 25

62

Contact

• KHBO (KHBO, EP)

dr. ing. Jeroen Boydens

[email protected]

• KdG (KdG, CoSys-Lab)

dr. ir. Marijn Temmerman

[email protected]

63

Page 26: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 26

Contents

64

1) EP research: part of ReMI

2) TDD4ES Research overview

3) MC4ES Research overview

4) FS4ES Research proposal

5) Workshop: Testgedreven ontwikkelen van Embedded

Software – 28/05/13

5) Workshop: Testgedreven ontwikkelen van

Embedded Software – 28/03/13

65

Page 27: Embedded software ontwikkeling - CORE · EP part of ReMI 15 Literature 37 • K. Beck. Test -Driven Development: By Example. Addison Wesley, 2003. • K. Beck and C. Andres. Extreme

KULeuven – campus KHBO 19/03/2013

EP part of ReMI 27

66