Github - silvergasp/embedded_hal_fuzz: A fuzzing framework for embedded drivers

51 points Smart-Blood-8263

https://docs.rs/embedded-hal-fuzz/0.1.0/embedded\_hal\_fuzz/

https://github.com/silvergasp/embedded-hal-fuzz

So recently I was writing a driver for an i2c pressure sensor, and without any calls to unwrap/panic, I had a situation where one of my tests would crash. It turns out that in some cases it was overflowing an integer, which under the 'Debug' compilation mode results in a panic. This was great as it meant that I caught the bug before it went into production.

Inspired to see how many more of these hidden bugs were littered through my driver code I wrote a set of 'fuzzed' backends for the traits in embedded\_hal. This works quite nicely with cargo-fuzz and supports fuzzing of gpio, serial, spi and i2c, including actual inputs as well as randomly returning errors to exercise your error handling code.

Thought I'd share as I've been able to find quite a few bugs in my own code in this way!