uCUnit Logo



Home | Getting Started | Documentation | Related Sites

Installation

Simply download the zip file to a location of your choice and unzip it. You will see this file structure:

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 */

First run

It is the best to compile the example on your host computer to get familiar with uCUnit.

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.

Output

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.

Customizing

Because every microcontroller and every project differs from each other you need to customize some macros and to provide concrete implementation for these macros.

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.


UCUNIT_WriteString(msg)

          Encapsulates a function which is called for
          writing a message string to the host computer.

msg Message which shall be written.

Note
Implement a function to write an integer to a host computer.
          For most microcontrollers a special implementation of
          printf is available for writing to a serial
          device or network. In some cases you will have
          also to implement a putch(char c) function.

UCUNIT_WriteInt(n)

          Encapsulates a function which is called for
          writing an integer to the host computer.

n Integer number which shall be written

Note
Implement a function to write an integer to a host computer.

For most microcontrollers a special implementation of printf is available for writing to a serial device or network. In some cases you will have also to implement a putch(char c) function.


UCUNIT_Safestate()

          Encapsulates a function which is called for
          putting the hardware to a safe state.
Note
Implement a function to put your hardware into a safe state.

For example, imagine a motor controller application:

  1. Stop the motor
  2. Power brake
  3. Hold the brake
  4. Switch warning lamp on
  5. Wait for acknowledge ...

UCUNIT_Recover()

          Encapsulates a function which is called for
          recovering the hardware from a safe state.
Note
Implement a function to recover your hardware from a safe state.

For example, imagine our motor controller application:

  1. Acknowledge the error with a key switch
  2. Switch warning lamp off
  3. Reboot ...

UCUNIT_Init()

          Encapsulates a function which is called for
          initializing the hardware.
Note
Implement a function to initialize your microcontroller hardware. You need at least to initialize the communication device for transmitting your results to a host computer.

UCUNIT_Shutdown()

          Encapsulates a function which is called to
          stop the tests if a checklist fails.
Note
Implement a function to stop the execution of the tests.


Impressum  |  Datenschutz  |  Terms of use  |  Copyright (C) 2008-2012 Sven Stefan Krauß. Last site update: 10-Sept-2012