Title: Designing User Interfaces Spring 1999
1SE 746-NT Embedded Software Systems
Development Robert Oshana Lecture
34 For more information, please
contact NTU Tape Orders NTU Media
Services (970) 495-6455
oshana_at_airmail.net
tapeorders_at_ntu.edu
2Embedded Systems Testing Part 1
From Beatty ESC 2002
3Agenda
- Introduction
- Types of software errors
- Finding errors methods and tools
- Embedded systems and RT issues
- Risk management and process
4Introduction
- Testing is expensive
- Testing progress can be hard to predict
- Embedded systems have different needs
- Desire for best practices
5Method
- Know what you are looking for
- Learn how to effectively locate problems
- Plan to succeed manage risk
- Customize and optimize the process
6Entomology
- What are we looking for ?
- How are bugs introduced?
- What are their consequences?
7Entomology Bug Frequency
- Rare
- Less common
- More common
- Common
8Entomology Bug severity
- Non functional doesnt affect object code
- Low correct problem when convenient
- High correct as soon as possible
- Critical change MUST be made
- Safety related or legal issue
- Domain Specific !
9Entomology - Sources
- Non-implementation error sources
- Specifications
- Design
- Hardware
- Compiler errors
- Frequency common 45 to 65
- Severity Non-functional to critical
10Entomology - Sources
- Poor specifications and designs are often
- Missing
- Ambiguous
- Wrong
- Needlessly complex
- Contradictory
Testing can fix these problems !
11Entomology - Sources
- Implementation error sources
- Algorithmic/processing bugs
- Data bugs
- Real-time bugs
- System bugs
- Other bugs
Bugs may fit in more than one category !
12Entomology Algorithm Bugs
- Parameter passing
- Common only in complex invocations
- Severity varies
- Return codes
- Common only in complex functions or libraries
- Reentrance problem
- Less common
- Critical
13Entomology Algorithm Bugs
- Incorrect control flow
- Common
- Severity varies
- Logic/math/processing error
- Common
- High
- Off by 1
- Common
- Varies, but typically high
14Example of logic error
If (( this AND that ) OR ( that AND other ) AND
NOT ( this AND other ) AND NOT ( other OR NOT
another ))
Boolean operations and mathematical calculations
can be easily misunderstood In complicated
algorithms!
15Example of off by 1
for ( x 0, x lt 10 x)
This will execute 11 times, not 10!
for ( x array_min x lt array_max x)
If the intention is to set x to array_max on the
last pass through the loop, then this is in error!
Be careful when switching between 1
based language (Pascal, Fortran) to zero based (C)
16Entomology Algorithm bugs
- Math underflow/overflow
- Common with integer or fixed point math
- High severity
- Be careful when switching between floating point
and fixed point processors
17Entomology Data bugs
- Improper variable initialization
- Less common
- Varies typically low
- Variable scope error
- Less common
- Low to high
18Example - Uninitialized data
int some_function ( int some_param ) int
j if (some_param gt 0) for ( j0 jlt3
j) / iterate through some process
/ else if (some_param lt
-10) some_param j / j is
uninitialized / return some_param
return 0
19Entomology Data bugs
- Data synchronization error
- Less common
- Varies typically high
20Example synchronized data
struct state / an interrupt will trigger
/ GEAR_TYPE gear / sending snapshot in a
message / U16 speed U16 speed_limit U8
last_error_code snapshot snapshot.speed
new_speed / somewhere in code
/ snapshot.gear new gear / somewhere
else / snapshot.speed_limit speed_limit_tb
gear
Interrupt splitting these two would be bad
21Entomology Data bugs
- Improper data usage
- Common
- Varies
- Incorrect flag usage
- Common when hard-coded constants used
- varies
22Example mixed math error
unsigned int a 5 int b -10 / somewhere
in code / if ( a b gt 0 )
ab is not evaluated as 5 ! the signed int b is
converted to an unsigned int
23Entomology Data bugs
- Data/range overflow/underflow
- Common in asm and 16 bit micro
- Low to critical
- Signed/unsigned data error
- Common in asm and fixed point math
- High to critical
- Incorrect conversion/type cast/scaling
- Common in complex programs
- Low to critical
24Entomology Data bugs
- Pointer error
- Common
- High to critical
- Indexing problem
- Common
- High to critical
25Entomology Real-time bugs
- Task synchronization
- Waiting, sequencing, scheduling, race conditions,
priority inversion - Less common
- Varies
- Interrupt handling
- Unexpected interrupts
- Improper return from interrupt
- Rare
- critical
26Entomology Real-time bugs
- Interrupt suppression
- Critical sections
- Corruption of shared data
- Interrupt latency
- Less common
- critical
27Entomology System bugs
- Stack overflow/underflow
- Pushing, pulling and nesting
- More common in asm and complex designs
- Critical
- Resource sharing problem
- Less common
- High to critical
- Mars pathfinder
28Entomology System bugs
- Resource mapping
- Variable maps, register banks, development maps
- Less common
- Critical
- Instrumentation problem
- Less common
- low
29Entomology System bugs
- Version control error
- Common in complex or mismanaged projects
- High to critical
30Entomology other bugs
- Syntax/typing
- if (ptrNULL) Cutpaste errors
- More common
- Varies
- Interface
- Common
- High to critical
- Missing functionality
- Common
- high
31Entomology other bugs
- Peripheral register initialization
- Less common
- Critical
- Watchdog servicing
- Less common
- Critical
- Memory allocation/de-allocation
- Common when using malloc(), free()
- Low to critical
32Entomology Review
- What are you looking for ?
- How are bugs being introduced ?
- What are their consequences ?
- Form your own target list!
33Finding the hidden errors
- All methods use these basic techniques
- Review checking
- Tests demonstrating
- Analysis proving
These are all referred to as testing !
34SE 746-NT Embedded Software Systems
Development Robert Oshana 10 minute
break For more information, please
contact NTU Tape Orders NTU Media
Services (970) 495-6455
oshana_at_airmail.net
tapeorders_at_ntu.edu