VisualGDB started supporting unit tests in version 5.2. Having out-of-the-box support for CppUTest, GoogleTest and TinyEmbeddedTest, VisualGDB made it easy to check whether every separable component of your system works. However the size overhead and the necessity to create a separate test project makes it hard to use them for testing the behavior of the entire embedded system.
So in VisualGDB 5.3 Preview 7 we introduced a new mechanism called Embedded Integration Tests that does exactly that – lets you conveniently verify the behavior of your firmware without any significant overhead.
Embedded Integration Tests let you modify the flow of the program using the debugger functionality (via commands like ‘Set Next Statement’ and ‘Set variable value’), record the program response and allow adding extra checks (e.g. verifying that a variable value falls within a certain range). You can create Embedded Integration Tests inside any embedded project by simply selecting Test->Record Embedded Integration Test:
VisualGDB will automatically start a new debug session and will stop in the main() function. Now you can use the normal debugging functionality to make your program follow a certain path and check its consistency along the way. For example, you can:
- Ensure that the critical interrupt handlers get invoked and don’t get stuck.
- Set a breakpoint inside a critical function and ensure that the stack pointer does not exceed the expected limit.
- Use ARM Cortex performance counter to validate timing of the critical functions.
- Set a breakpoint in the function that checks for user input, imitate various input events by forcing the function to exit with different status codes and check that the program responds as expected.
- Step through some critical functions, simulate common error conditions by manipulating hardware registers, check that the errors are handled correctly.
VisualGDB will record (and replay when testing) the following actions:
- Setting, enabling/disabling and deleting breakpoints
- Resuming execution/stepping (and checking whether a specific breakpoint triggers)
- Running custom GDB commands (you can check their output with regular expressions)
- Modifying values of variables or hardware registers
- Setting next statement
If you have just checked a variable value by hovering your mouse over it, you can tell VisualGDB to always check for the same value by adding a check. VisualGDB will automatically suggest recently evaluated expressions:
Editing and Running Tests
Embedded Integration Tests are stored in test set files (.vgdbtest) that are added to the project via Solution Explorer. You can view and edit the tests by simply opening the test set file in Visual Studio:
Give It a Try
You can download VisualGDB 5.3 Preview 7 here. As always, we appreciate your feedback, suggestions for more recordable actions and general ideas, so don’t hesitate to drop us a line via our support form or the VisualGDB forum.