uCUnit-1.0 +- arm | +- Makefile /* Sample Makefile for arm-elf-gcc */ | +- System.c /* Sample implementation for use with arm-elf-run */ +- avr | +- Makefile /* Sample Makefile for ATmega8 */ | +- System.c /* Stubs for ATmega8 */ +- i386 | +- build.bat /* For users without make */ | +- System.c /* Sample implementation which runs on the host computer*/ +- template | +- Makefile /* Makfile template */ | +- System.c /* System dependend functions stubs */ +- System.h /* System dependend functions declaration */ +- Testsuite.c /* Sample Testsuite (contains main() )*/ +- Testsuite.h /* Public function prototypes */
Open a command prompt or a shell to build the example. The template makefile is in the template folder. It is the basic Makefile for use with the GNU gcc. If you are a windows user without make, you can use the build.bat in the i386 folder.
make -C template all make -C template run
The first command builds the target 'all' in the template folder. The second command runs the test.
Init of hardware finished. Name: uCUnit demo application Compiled: Aug 14 2008 Time: 22:56:55 Version: v1.0 ====================================== DEMO:Simple Checks ====================================== ../Testsuite.c:49: passed:IsEqual(0,a) ../Testsuite.c:50: passed:IsEqual(0,b) ../Testsuite.c:51: passed:IsEqual(0,c) ../Testsuite.c:53: passed:IsEqual(0,(1-1)) ../Testsuite.c:54: passed:IsEqual(0,(-1+1)) ../Testsuite.c:55: passed:IsEqual(-1,(-2+1)) ../Testsuite.c:57: passed:IsNull(s) ====================================== Testcase passed. ====================================== ====================================== DEMO:Checking pointers ====================================== ../Testsuite.c:67: passed:IsNull(s) ../Testsuite.c:72: passed:IsNotNull(s) ../Testsuite.c:73: passed:No end-of-string found(s) ../Testsuite.c:77: passed:IsNotNull(s) ../Testsuite.c:78: passed:String starts not with 'H'(s) ====================================== Testcase passed. ====================================== ====================================== DEMO:Checklists ====================================== ../Testsuite.c:97: passed:IsEqual(-10,c) ../Testsuite.c:98: passed:IsInRange(a,0,10) ../Testsuite.c:99: failed:IsInRange(a,11,20) ../Testsuite.c:100: failed:IsInRange(a,0,9) ../Testsuite.c:101: failed:Checklist() ====================================== ../Testsuite.c:103: failed:EndTestcase() ====================================== ====================================== DEMO:Checking Bits ====================================== ../Testsuite.c:110: passed:IsBitSet(0x0001,0) ../Testsuite.c:111: failed:IsBitSet(0x0000,0) ../Testsuite.c:112: passed:IsBitSet(0x0002,1) ../Testsuite.c:113: failed:IsBitSet(0x0000,6) ../Testsuite.c:114: passed:IsBitSet(0xFFFF,6) ../Testsuite.c:116: failed:IsBitClear(0x0001,0) ../Testsuite.c:117: passed:IsBitClear(0x0001,1) ====================================== ../Testsuite.c:119: failed:EndTestcase() ====================================== ====================================== DEMO:Tracepoints ====================================== ../Testsuite.c:134: failed:Is8Bit(a) ../Testsuite.c:135: passed:Is16Bit(a) ../Testsuite.c:136: passed:Is32Bit(a) ../Testsuite.c:139: passed:TracepointCoverage(0) ../Testsuite.c:140: passed:TracepointCoverage(1) ../Testsuite.c:164: failed:TracepointCoverage(0) ../Testsuite.c:165: passed:TracepointCoverage(1) ../Testsuite.c:166: failed:TracepointCoverage(2) ====================================== ../Testsuite.c:168: failed:EndTestcase() ====================================== Testcases: failed: 3 passed: 2 Checks: failed: 8 passed: 23 System shutdown.
For example, you have to provide concrete implementation to write the output to a serial device, to a network connection or anything else.
If you can use printf() you might use it. Then you need a hardware initializing function to initialize the hardware. At least you must setup a communication device for outputting text to a host computer.
For safety critical systems you have to provide a function to put your system in a safe state and to recover it from this state. Also you have to provide a function to shutdown your hardware.
DO NOT FORGET TO PUT ALL IO PINS IN A SAFE STATE!
The files System.c and System.h contain some stub functions to demonstrate the principle. The File Testsuite.c shows the usage of uCUnit.
msg Message which shall be written.
n Integer number which shall be written