Introduction to Test Driven Development Building tests and code for a “software radio”
Concepts of TDD, M. Smith, ECE, University of Calgary, Canada 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 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Conventional “AM” radio RF STAGE Antenna Pickup AUDIO STAGE Low pass Filter + amplifier Low pass Filter Rectifier Mixer Local Oscillator IF STAGE Audio out 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Software “AM” radio concept RF STAGE Antenna Pickup AUDIO STAGE Low pass Filter + amplifier Low pass Filter Rectifier Mixer Local Oscillator IF STAGE Audio out Most stages handled with high speed software 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Software “FM” radio concept RF STAGE AUDIO STAGE Antenna Pickup Low pass Filter + amplifier What ever is needed Rectifier Audio out Most stages handled with high speed software 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Concepts of TDD, M. Smith, ECE, University of Calgary, Canada 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) 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
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); 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Expected relative advantages Compiler debug mode Compiler release (optimized) mode “US” – assembly mode “US” – optimized assembly mode 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Standard testing practice Heavy on documentation TLD Test Last Development 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
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 CUSTOMER DEVELOPER 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
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 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Concepts of TDD, M. Smith, ECE, University of Calgary, Canada 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 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
First unit test Can I link to a particular test file and activate the tests within that files? Test control. Certain tests always need to be run (totally automated). Others are more difficult to automate This include file provides defines needed for the project 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Concepts of TDD, M. Smith, ECE, University of Calgary, Canada 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 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Running the tests Need a fast – easy to use – way of switching between running the tests, and demonstrating the working customer product 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Running the customer product code 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Test code – Report Mode Report all tests. Success and failures Report successes only 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Test code – test level control 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Result of “link test” Disassembler window Source or “Mixed mode” window Project window Editor tabs selected Twin processors can be controlled Results in VisualDSP CONSOLE WINDOW 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Obvious test – actually contained a hidden bug 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Integer array tests ZERO-LENGTH ARRAY Unspecified requirement – shown as part of test functionality Function return pointer = NULL if error condition present 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Concepts of TDD, M. Smith, ECE, University of Calgary, Canada 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 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Concepts of TDD, M. Smith, ECE, University of Calgary, Canada Zero-length test Modify the integer test case 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Float rectification test 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Take notes from the screen 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Speed tests – integer code versions 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
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 Run all available tests to make sure nothing “broke” Bring third test in – write the code to satisfy that test 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Concepts of TDD, M. Smith, ECE, University of Calgary, Canada 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 11/20/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada