Professional Documents
Culture Documents
In this topic we will discuss some methods for testing and debugging Embeddedsystem software so that it will really work when you deliver it to customers. Most
experienced engineers said that lots of bugs in the code will not accepted and require
more time and money to reduce that bugs that is a product with fewer bugs is to write
software with fewer bugs in the first place. The techniques for keeping bugs out of your
embedded-system software are much the same as for keeping them out of your
application software. However, they are more important for two reasons. First, testing
and debugging embedded systems is a difficult and time-consuming problem, even more
so than testing and debugging applications. The fewer bugs, the less aggravation. Second,
the world is extremely intolerant of buggy embedded systems. Consumers seem willing
to buy applications for personal computers that lock up occasionally, presenting either a
stiff, uninformative message or a cute bomb icon. No one accepts cash registers that crash
in the middle of checking out customers, telephone switching equipment that
occasionally connects you to the wrong person, medical instruments that stop working
during surgery, or printers that stop printing for no apparent reason.
development.
Testing and debugging is done at each stage and at final stage testing is done
Scaffold code provides the same entry points as the HW independent code.
The target system is a troublesome testing environment. Consider the goals of the
typical testing process:
Find the bugs early in the development process:
Testing early gives you some idea of how many bugs you have and therefore how
much trouble in program but the target system very often is not available early in the
process, or the hardware may be buggy and unstable.
Exercise all of the code:
This includes all of the exceptional cases, even though you hope that they will
never happen but it varies from difficult to impossible to exercise all the code in the
target, because in an embedded system, a fair amount of code invariably deals with
unlikely situations.
Develop reusable, repeatable tests:
It is extraordinarily frustrating to see a bug once but then not be able to find it
because it refuses to happen
Leave an "audit trail" of test results:
In Telegraph "seems to work" in the network environment is not nearly as
valuable as knowing and storing exactly what data it sends out in response to received
data. But since most embedded systems do not have a disk drive or other permanent
storage medium, it is often difficult to keep track of what results we got.
From this we know that don't test on the target any more than you have to. The
alternative is to test as much of your code as you possibly can on your development host.
Figure1 shows the basic method for testing embedded software on the development host.
the test scaffold must execute the interrupt routines. This turns out not to be difficult:
interrupt routines tend to divide into two parts: one that deals with the hardware and one
that deals with the rest of the system. For test purposes you structure your interrupt
routines so that the hardware-dependent part calls the hardware- independent part. We
write this latter part in C, and the test scaffold can simply call it.
Calling the Timer Interrupt Routine:
One interrupt routine your test scaffold should call is the timer interrupt routine.
In most embedded-system software the passage of time and the timer interrupt routine
initiate at least some of the activity. You could have the passage of time in your host
system call the timer interrupt routine automatically, so that time goes by in your test
system without the test scaffold's participation. This, however, is usually a mistake. It
causes your test scaffold to lose control of the timer interrupt routine. The timer interrupt
routine will sometimes execute just before or just after other things that your test scaffold
software is doing, causing intermittent bugs. In short, you will import into your host test
environment some of the aggravating problems that bedevil the target test environment.
Script Files and Output Files:
You could write a test scaffold that calls the various interrupt routines in a certain
sequence and with certain data, but you can get a lot of testing done more easily by
writing a test scaffold that reads a script from the keyboard or from a file and then makes
calls as directed by the script. A script file parser need not be a major project; script files
can be very simple.
EXAMPLE:
There are numerous similar examples. When the hardware-independent code in
the cordless bar-code scanner sends a frame on the radio, the test scaffold captures it and
then automatically calls the interrupt routine to indicate that the frame has been sent.
When hardware-independent code sets a short timer say 200 microseconds-the
test scaffold might call the timer interrupt routine right away, rather than forcing you to
tell the test scaffold to do it every time. Whenever the system produces output that the
test scaffold captures, you may be able to make your testing life easier by having the test
scaffold software respond automatically. Another technique to consider if your project
includes multiple systems that must communicate with each other is to set up a test
scaffold that contains multiple instances of the hardware-independent code and that acts
as the communications medium among them. For the cordless bar-code scanner, for
example, the test scaffold would have multiple instances of the hardware-independent
code for the scanner and multiple instances of the hardware-independent code for the
cash register. To each instance of the hardware-independent code the test scaffold appears
to be the radio hardware, and it sends and receives data just as the real radio will on the
target hardware.