Chapter 15. Run an eCos test case

In the section called Verification in Chapter 12 you ran the prebuilt test case on real hardware; now you are ready to run one of the test programs in the simulated environment.

Start a command window, for example a bash shell or an MS-DOS command prompt with the environment variables set up as described in the GNUPro documentation. Change to the directory in which you set up your build tree, and invoke GDB on the test program. To run the bin_sem0 test (which will test the kernel for the correct creation and destruction of binary semaphores) type:

$ gdb -nw install/tests/kernel/bin_sem0

You should see the following in the command window:

Example 15-1. Starting up GDB


GNU gdb 4.17-ecos-98r1p3
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.  This version of GDB is supported
for customers of Cygnus Solutions.  Type "show warranty" for details.
This GDB was configured as "--host=THIS-HOST --target=THIS-TARGET".
(gdb) 

To specify that you are using the simulator target (rather than real hardware) you can type:

(gdb) target sim --board=stdeval1

on the MN10300, or

(gdb) target sim --board=jmr3904

on the TX39, or

(gdb) target sim -f BASE_DIR/hal/powerpc/sim/v1_1/runtime/tree

on the PowerPC.

You will see the following lines on your screen:


Connected to the simulator.
(gdb) 

Tip: The PowerPC instruction for GDB involves typing a lengthy line to set up some parameters for the simulator. One way to reduce the amount of typing is to put the following code in your personal GDB startup file (gdb.init on Windows and .gdbinit on UNIX):


define psim
target sim -f BASE_DIR/hal/powerpc/sim/v1_1/runtime/tree
load
break cyg_test_exit
break cyg_assert_fail
end

Now download the program to the (simulator) target with

(gdb) load

You should see the following output on your screen:

You are now ready to run your program as if this were an ordinary debugging session with GDB. If you type

(gdb) run

you will see the something like following output:


Starting program: /ecos-work/./install/tests/kernel/bin_sem0.exe
PASS:<Binary Semaphore 0 OK>
EXIT:<done> 

You must kill your GDB session with Control-C, or it will sit in the "idle" thread and use up CPU time. Type quit and you are done.

Note: If you are using a CD distribution of the eCos Developer's Kit, the GNUPro tool chain which accompanies it comes with the graphical front end to GDB, GDB/Tk, which will be invoked if you do not specify the -nw option to gdb. We have used the command line version in this tutorial.