FreeEMS Issues - Firmware
View Issue Details
0000156FirmwareTestingpublic2011-06-15 17:342012-10-24 15:58
Fred 
Fred 
normalminorN/A
assignedopen 
 
Future 
Task
low
0000156: Add unit tests for unit testable functions
Copy/paste:

    // each case:
                // checks length, fails if wrong
                // parses data into args
                // calls function on data/args
                // assembles response OR sets error
                // breaks


// testable:
                // lookupPagedMainTableCellValue - pass this RPAGE so that it remains unchanged
                // validateMainTable
                // validateTwoDTable
                // set table values - leave this till last, currently unused by mtx, likely to be removed anyway
                // generateDerivedVars - convert to pointers, remove headers, privatise a lot of data!
                // calculateFuelAndIgnition - ditto
                // scheduling algorithm - ditto
                // safeAdd
                // safeTrim
                // safeScale
                // sleep (milliseconds)
                // sleepMicro (microseconds)
                // checksum
                // stringCopy
                // compare
                // utils that can't be checked: sampleLoopADC sampleBlockADC sampleEachADC - can check for how long each takes! adjustPWM (test only anyway), resetToNonRunningState and setupPagedRAM (would interfere with functioning of device)
                // init code may be able to be partially checked
                // most other code at this stage is ISR code, flash writing code, or could interfere with the running of the engine
                // more testable code will appear with time, such as the HAL layer, and most accessory functions.

Refactor whatever we can to be testable and add tests.
No tags attached.

Notes
(0000208)
Fred   
2011-06-28 19:06   
risk = low assumes functions already testable. Those things migrating to a testable form could break in the process.
(0002363)
Fred   
2012-10-24 15:48   
For testing times, I'll use floating point tests, and provide a tolerance. They don't have to be perfect.
(0002365)
Fred   
2012-10-24 15:58   
Need to ensure the functionality for each wrapper is in the same page as the target functionality, too.

Function's doxygen should be marked with @Tested or @NOT_TESTED so as to be collated during the doxy build.