Sample walkthrough or examples
Hello,
I came across your framework a while ago and was wanting to explore more with it. As I understand it, this framework is a counterpart to a host based unit testing approach, where you can test with the HIL. It is a very interesting and useful tool. However, the documentation is rather sparse and not easy to grasp for someone just getting into this.
Can I trouble you to provide a rudimentary example, say like blinking an led with an STM32 board that demonstrates the usage of the tool??
Thanks in advance!!
Sorry for the super late response. The issue with those is that every hardware is different. Do you have a specific eval board you'd want to work with?
Hello @klemens-morgenstern . Not an issue about the delay at all.. :-) Nothing specific in mind.. Just curiosity and wanting to experiment. Lets just keep it simple.. Say I wanted to test an Arduino Uno, test whether the built in LED is blinking or not.. Is that a reasonable case?
Or since we are limiting it to gdb.. Say any STM32 discovery board.. Say STM32F030R8.. Its what I have sitting on my bench prezently.. and it has 2 leds on PC8 and PC9. So if I was running a blinky with the two leds.. how would I go about using metal to test / validate it
Do you have any suggestions how I can go about this?
You can't test if the LED is on or not, you can only test the value of the registers. For an arduino you'd need to setup metal.serial, for gdb metal-gdb. Both of them provide compatible testing APIs so that you (in theory) could switch over.
As for the rest, you do not really test the hardware, but the code. So let's say you have a function turn_on_led that should switch on the led. You can then test this by checking if the appropriate register has been set to true.
#include <my_led_functions.hpp>
#include <metal/gdb/unit.hpp>
int main(int argc, char *argv[])
{
turn_on_led();
METAL_ASSERT(HAL_GPIO_ReadPin(GPIOA, 3) == GPIO_PIN_SET);
return METAL_REPORT();
}
That's basically what it does, the whole test case stuff is just for convenience, i.e.:
#include <my_led_functions.hpp>
#define METAL_UNIT_MAIN
#include <metal/serial/unit.hpp>
TEST_CASE(" led-test-case")
{
turn_on_led();
METAL_ASSERT(HAL_GPIO_ReadPin(GPIOA, 3) == GPIO_PIN_SET);
}
Nice!! Looks pretty easy! Thank you for the pointers.. I ll experiment and report back with any progress.. :-) Once again thank you for the help and (what looks like an awesome ) toolkit!!