This repository has been archived by the owner on Jul 22, 2020. It is now read-only.
unit.introduction
Klemens David Morgenstern edited this page May 6, 2018
·
3 revisions
metal.test.unit
is a very light-weight unit-testing library for gcc, to be used with metal.runner. It's purpose is to allow fast and simple unit-testing on embedded systems.
It can be used without the metal.runner, having minimal functionality.
- two test levels (assertion/expecation)
- flow control (cancel tests/critical tests)
- log messages
- test cases
- human-readable-format or json output
- success indication through the exit-code
- C and C++ implementation
Here's a simple example of a test with metal.test.unit
:
#include <metal/unit.hpp>
int main(int argc, char *argv[])
{
int i = 41;
i++;
METAL_ASSERT_EQUAL(i, 42);
return METAL_REPORT();
}
Using the metal.runner
we can launch the test on a remote arm device, which would look like this:
metal.runner --debug --gdb=arm-none-eabi-gdb --exe=test.elf --lib metal-test-backend metal-exitcode --remote localhost:3333 --other "openocd -f ..\scripts\interface\stlink-v2.cfg -f ..\scripts\target\stm32f4x.cfg -c init"
This call will start the dbg-runner, load the backend plugin and thus execute the code and give a detailed report on the results of the test and the values put in.
[endsect]
- Overview
- Runner Introduction
- Runner Invocation
- Runner Plugins
- Runner Extender
- Runner FAQ
- Runner Reference
- Unit Introduction
- Unit Tutorial
- Unit FAQ
- Unit Reference
- Calltrace Introduction
- Calltrace Tutorial
- Calltrace FAQ
- Calltrace Plugin
- Calltrace Reference
- Serial Introduction
- Serial Tutorial
- Serial Invocation
- Serial Reference