Top Banner
Introduction to Test Driven Development Building tests and code for a “software radio”
28

Introduction to Test Driven Development

Dec 31, 2015

Download

Documents

quinn-armstrong

Introduction to Test Driven Development. Building tests and code for a “software radio”. Concepts. Stages in a conventional radio Stages in a software radio Goals for the “long term” project Concept of test driven development Digital rectification Tests for integer array rectification - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to  Test Driven Development

Introduction to Test Driven Development

Building tests and code for a“software radio”

Page 2: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

2 / 28

Concepts

Stages in a conventional radio Stages in a software radio Goals for the “long term” project Concept of test driven development Digital rectification

Tests for integer array rectification Tests for float array rectification (C++

compiler) Tests for rectification in assembly code

More details of test driven development

Page 3: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

3 / 28

Conventional “AM” radio

AntennaPickup

LocalOscillator

Mixer Low passFilter

RectifierLow pass

Filter+ amplifier

Audio out

RF STAGE

IF STAGE

AUDIO STAGE

Page 4: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

4 / 28

Software “AM” radio concept

AntennaPickup

LocalOscillator

Mixer Low passFilter

Rectifier

Audio out

RF STAGE

IF STAGE

AUDIO STAGE

Most stages handled with high speed software

Low passFilter

+ amplifier

Page 5: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

5 / 28

Software “FM” radio concept

AntennaPickup What ever

is neededRectifier

Audio out

RF STAGE AUDIO STAGE

Most stages handled with high speed software

Low passFilter

+ amplifier

Page 6: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

6 / 28

Real “software” radio

Looking at RF stage to bring in wireless signal Software radio is the rest of it

Update communication protocols Change noise suppression characteristics “on the fly” Etc.

Excellent topic for individual presentation (8 minute talk – 10 slides max – at the end of term) or possible joint presentation (16 minute talk – 20 slides max)

Page 7: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

7 / 28

Rectification algorithm

Choices are C++ compiler in DEBUG mode

int *RectifyDEBUG(int initial[ ], int final, int N); float *RectifyDEBUG (float initial[ ], float final, int N);

C++ compiler in RELEASE mode int *RectifyRELEASE(int initial[ ], int final, int N); float *RectifyRELEASE(float initial[ ], float final, int N);

“US” in ASSEMBLY mode int *RectifyASM(int initial[ ], int final, int N); float *RectifyASM(float initial[ ], float final, int N);

“US” in OPTIMIZED ASSEMBLY mode int *RectifyOPTASM (int initial[ ], int final, int N); float *RectifyOPTASM (float initial[ ], float final, int N);

Page 8: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

8 / 28

Expected relative advantages

Compiler debug mode

Compiler release (optimized) mode

“US” – assembly mode

“US” – optimized assembly mode

Page 9: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

9 / 28

Standard testing practice

Heavy on documentationDescribe

Requirements

Design Solution

Build Solution

Test Solution

WriteAnalysis Document

WriteDesign Document

WriteTest Plan Document

TLD

TestLast

Development

Page 10: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

10 / 28

Test Driven Development

Customer Tests – personally find these hard to do Not clear if there is yet “a real process available”

Developer Tests – have found many advantages

DescribeRequirements

Design Solution

Build Solution Test Solution

WriteAcceptance Tests

WriteUnit Tests

CUSTOMER

DEVELOPER

Page 11: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

11 / 28

Lets apply TDD to rectification issue

Overall technique Decide on a particular test action Write the test(s) Write the simplest possible code to satisfy the test(s) “Refactor” the code to improve “quality”

Definition of “quality” is unclear in the literature Ease of “use” or “reuse” of code Reliable to use – “robust” My additional idea – meets speed requirements for the

embedded situation

TDD in an embedded / ubiquitous computing environment is a major part of my current research with funding from NSERC and Analog Devices

Page 12: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

12 / 28

First unit test

Can I link to a particular test file and activate the tests within that files?

This include file provides all the macros needed for the TDD environment

Simple test to indicate the test set being run.Also indicates that a link is possible

Page 13: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

13 / 28

First unit test

Can I link to a particular test file and activate the tests within that files?

This include file provides defines needed for the project

Test control. Certain tests always need to be run (totally automated). Others are more difficult to automate

Page 14: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

14 / 28

First unit test

Can I link to a particular test file and activate the tests within that files?

NOTE: REQUIREMENT – CUSTOMER TEST CODE MUST BE AVAILABLE TO DEVELOPER

(Does not mean customer might not have other test code

Page 15: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

15 / 28

Running the tests Need a fast – easy to use – way of switching between running the tests,

and demonstrating the working customer product

Page 16: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

16 / 28

Running the customer product code

Page 17: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

17 / 28

Test code – Report Mode

Report all tests.Success and failures

Report successes only

Page 18: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

18 / 28

Test code – test level control

Page 19: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

19 / 28

Result of “link test”

Results in VisualDSP CONSOLE WINDOW

Disassemblerwindow

Source or“Mixed mode”

window

Editor tabs selected

Projectwindow

Twinprocessors

can be controlled

Page 20: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

20 / 28

Obvious test – actually contained a hidden bug

Page 21: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

21 / 28

Integer array tests ZERO-LENGTH ARRAY

Unspecified requirement – shown as part of test functionality Function return pointer = NULL if error

condition present

Page 22: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

22 / 28

Float tests

You write the required tests for testing rectification of floating point arrays Test for correct zero-length error response Test for correct rectification operation

Page 23: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

23 / 28

Zero-length test

Modify the integer test case

Page 24: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

24 / 28

Float rectification test

Page 25: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

25 / 28

Take notes from the screen

Page 26: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

26 / 28

Speed tests – integer code versions

Page 27: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

27 / 28

Using the tests – practical approach

Just because all the tests are known, does not mean that you use all of them immediately

If you use all of them immediately, you get a lot of failure messages, which is very soul destroying I bring first test in – write the code to satisfy that test

Keep track of “defects” and “errors” as QA Bring second test in – write the code to satisfy that test

Keep track of “defects” and “errors” as QA Run all available tests to make sure nothing “broke”

Keep track of “defects” and “errors” as QA Bring third test in – write the code to satisfy that test

Keep track of “defects” and “errors” as QA Run all available tests to make sure nothing “broke”

Keep track of “defects” and “errors” as QA

Page 28: Introduction to  Test Driven Development

04/19/23 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

28 / 28

Concepts covered

Stages in a conventional radio Stages in a software radio Goals for the “long term” project Concept of test driven development Digital rectification

Tests for integer array rectification Tests for float array rectification (C++

compiler) Tests for rectification in assembly code

More details of test driven development