Presentation is loading. Please wait.

Presentation is loading. Please wait.

VisualDSP++ and Test Driven Development What happened last lecture?

Similar presentations


Presentation on theme: "VisualDSP++ and Test Driven Development What happened last lecture?"— Presentation transcript:

1 VisualDSP++ and Test Driven Development What happened last lecture?
Note – Developing the C++ Rectify code will be part of Familiarization Lab. and Pre-lab 1 Assignments

2 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Developing software radio on the TigerSHARC Concept of test driven development – An “Agile” software development concept Writing the customer tests Understanding the E-TDD testing framework Writing the CPP rectify code Will be trying these ideas out in the laboratory this afternoon. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

3 Conventional “AM” radio
RF STAGE Antenna Pickup AUDIO STAGE Low pass Filter + amplifier Low pass Filter Rectifier Mixer Local Oscillator IF STAGE Audio out 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

4 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 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

5 A basic example for the coding practices adopted through the term
Going to use the rectification stage of this “soft-radio” as a “code example” all through the course. We may also look at “single-side band modulation” (involves IIR filtering) as a second “code example” followed all though the term. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

6 Customer Requirements
Wants to get “product out of the door” as fast as possible Less time spend on development the better, but it has to work Developing in C++ is easier than developing in assembler code, but is it fast enough Risk analysis – take one representative part of the code and explain the differences between the speeds from C++ code (Debug and Release Mode) and assembly code 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

7 Standard testing practice
Heavy on documentation TLD Test Last Development 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

8 Test Driven Development
Work with customer to check that the tests properly express what the customer wants done. Iterative process with customer “heavily involved” – “Agile” methodology. CUSTOMER DEVELOPER 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

9 Lets apply TDD to rectification issue
Overall technique Decide on a particular test action with the customer 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 See paper handed out for more details 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

10 Files and directories needed TDD and many tests files available on web
ENCM515 WEB Rectify Tests – Assign1Tests HalfWaveDebugModeTests.cpp HalfWaveReleaseModeTests.cpp HalfWaveAMSTests.cpp TDD files in E-TDDIncludes dir ActivateTests.cpp TS201_char32_TDDLib_dlb Various TDD_includes.h TDD_Tests1Jan05.h Rectify code developed in Assign1 directory Rectify.h TS201.ldf (loader description file for 1 processor) HalfWaveDebugMode.cpp (float and int code) HalfWaveReleaseMode.cpp (float and int code) HalfWaveIntASM.asm HalfWaveFLoatASM.asm Lab1 Lab1Tests Lab2 Lab2Tests LabX LabXTests 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

11 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
E-TDD Test.cpp files have four main components. Many error messages if not present Include Files – cut-and-paste (always the same) TEST_CONNECT (TestFileInfo) TEST(testNAME, testTYPE) NOTE: Tests execute from LAST in file to FIRST. As normally the LAST test is the most recently added test, this is good. You test if new code works and then check (regression test) that you did not break anything LINK_TEST(TestFileInfo, testTYPE) 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

12 Now expand the Customer Tests to do what the customer has requested
12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

13 Now expand the Customer Tests to do what the customer has requested
E-TDD TEST SYNTAX CHECK( ) – if condition is true XF_CHECK( ) – expected failure meaning you know its wrong and plan to fix later. Passing an XF_CHECK( ) (SUCCESS) is considered a failure. ARRAYS_EQUAL( ) – basically a loop of CHECK( )s. MEASURE_EXECUTION_TIME( ) automatically uses an internal TigerSHARC clock. Value returned in “processor cycles”. REPORT – currently printf( ) 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

14 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Note that writing the tests has automatically generated the function interface information Why int* and float* rather than just void as you are passing in the address of the output Design decision – sort of standard with “C” to pass back a pointer to thing being changed 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

15 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Floating point version of the Tests Essentially a cut-and-paste version of integer code 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

16 Stage 1 – Compile / Link the tests
Obviously the Link is not going to work – as the code for functions HalfWaveRectifyXXX( ) have not been written If obviously going to fail – WB (why bother)? Basically – You are TESTING THE TESTS Are you calling the functions you expect to call. Better handled by doing Code Review first, and then use compiler / linker to CHECK the Code Review did not miss something (PSP – personal software process). C++ can overload function names (done via name mangling). What are the name-mangled names needed for the assembly code? – This stage will show you. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

17 Name mangled names can be seen from linker
C++ name as used The name mangled name generated by in C++ code by the C++ compiler in response to function overloading. These are the “assembly code” names 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

18 Next step: Write just enough code to satisfy the linker – C++ stubs
12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

19 Write the assembly language stub
We lost control of the processors in the debug environment. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

20 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Recovery process Don’t lose control – write good code Do incremental builds so you are continually writing and testing code E-TDD encourages this – write a test, then write just enough code to satisfy the tests If you lose control Try selecting each processor (DSPA then DSPB) in processor window. Then select DEBUG | HALT If that fails, then in this order (easier restart process) Exit from E-TDD GUI, Exit from VisualDSP IDDE Power down the board Walk-around your chair twice (or count to 10)  Power up board, then reactivate VisualDSP IDDE and the GUI 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

21 We “accidentally” pass some tests without writing any code
12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

22 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Write “just enough code to satisfy” Cpp tests. During design may identify more tests. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

23 Build the code incrementally to satisfy tests
See speed change now we Are executing code – but why failures Note what if N < = 0 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

24 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Add test to check that works if N <= 0 Do another code review and spot problemS NEW TESTS CHECKING WRONG THING OVER-WRITING EXPECTED RESULTS 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

25 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Weird test results 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

26 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Weird test results I forgot to add the new code for the pt = NULL if N <= 0, yet some tests pass ASM passes since stub sets pt = NULL before returning I did not do any assembly code – yet the tests act as if the code is working Release code passes ASM code passes Poor test design because we did not set the “result_array[ ]” back to zero FIX THE TEST AS PART OF ASSIGNMENT 1 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

27 Incrementally added the code to HalfWaveReleaseMode( )
Test that past before are now failing Compiler does not know difference between “debug” and “release” mode 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

28 Select file – then right click and select FILE OPTIONS
12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

29 Click on “File Specific Settings” and then on COMPILE | General
12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

30 Click on ENABLE OPTIMIZATION, Click okay and then rerun the tests
12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

31 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Note Special marker Compiler optimization FLOATS 927  THREE FOLD INTS 960  150 – SIX FOLD Why the difference, and can we do better, and do we want to? Note the failures – what are they 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

32 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Use GUI to find out Okay – at this point in time – we are expecting that to fail 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada

33 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada
Concepts tackled Developing software radio on the TigerSHARC Concept of test driven development – An “Agile” software development concept Writing the customer tests Understanding the E-TDD testing framework Writing the CPP rectify code Will be trying these ideas out in the laboratory this afternoon. 12/31/2018 Concepts of TDD, M. Smith, ECE, University of Calgary, Canada


Download ppt "VisualDSP++ and Test Driven Development What happened last lecture?"

Similar presentations


Ads by Google