Hacker News new | ask | show | jobs
by roland35 2577 days ago
There was one weird bug reported to me in an microcontroller based project I was recently working on which shut off half the LCD screen. I wrote a test which blasted the LCD screen with random characters and commands and did not see the same error for awhile... but it finally happened during a test! I was able to then see that when I was checking the LCD state between commands I only would toggle the chip select for the first half of the LCD (there were 2 driver chips built into the screen and you had to read each chip individually). There would be no way I could have recreated the bug without automated tests.

I have had to deal with non-deterministic tests with my embedded systems and robotic test suites and have found a few solutions to deal with them:

- Do a full power reset between tests if possible, or do it between test suites when you can combine tests together in suites that don't require a complete clean slate

- Reset all settings and parameters between tests. A lot of embedded systems have settings saved in Flash or EEPROM which can affect all sorts of behaviors, so make sure it always starts at the default setting.

- Have test commands for all system inputs and initialize all inputs to known values.

- Have test modes for all system outputs such as motors. If there is a motor which has a speed encoder you can make the test mode for the speed encoder input to match the commanded motor value, or also be able to trigger error inputs such as a stalled motor.

- Use a user input/dialog option to have user feedback as part of the test (for things like the LCD bug).

Robot Framework is a great tool which can do all these things with a custom Python library! I think testing embedded systems is generally much harder so people rarely do it, but I think it is a great tool which can oftentimes uncover these flaky errors.