Skip to content

Debugging and Unit Testing

Pedro A. Hortas edited this page Apr 15, 2015 · 6 revisions

Enabling Debugging

Enable uSched debug messages by setting the CONFIG_DEBUG definition to 1 in include/config.h file:

#define CONFIG_DEBUG 1

Compiler Flags

Always use, at least, the following compiler flags when using gcc or clang:

-fstrict-aliasing -pedantic -Wall -Werror

If you're using another compiler, make sure you setup it correctly to trigger the same warnings that are issued on gcc (or clang) by the above flags.

Runtime Analysis

After Enabling Debugging, build and install the project. Then start uSched modules using valgrind in the following order:

~# valgrind --leak-check=full --show-reachable=yes --track-origins=yes uss
~# valgrind --leak-check=full --show-reachable=yes --track-origins=yes use
~# valgrind --leak-check=full --show-reachable=yes --track-origins=yes usd

Static Analysis

Always use splint to analyze the code. If you're unsure about what flags you should use, cleanup the project (running the undo script) and perform:

~# make test

This will run several static analysis tools, including splint, scan-build and pscan.

Behavioral Testing

Grant that all features behave as expected. Although the make test procedure will perform some behavioral testing by using uSched Client, it's not granted that everything is covered there at all times. Think about what you've done and what will be directly or indirectly affected and run some tests of your own.

Clone this wiki locally