Unit tests for intermittent code

I am writing a C code for an AVR chip. This code is heavy for interrupt routines that wait for serial ports, ADCs, and timers. ISRs are written to buffers that the main loop analyzes when they get to them.

I create buffers so that ISRs can update them while the main loop reads them. I want to check that this works. I have unit tests for checking the basic operation, but I don’t know how to check what happens if the interrupt is triggered when the main loop is read in the buffer.

My unit test is really basic - some code in main()finction. I run tests in my Linux box.

+3
source share
1 answer

Subject?

Run a high priority thread that calls your ISR at some speed similar to real. Then, basically, repeat reading the buffer over and over in a loop. Verify that the buffer reading is not corrupted.

(Perhaps this is more of an integration test than a pure unit test.)

+3
source

Source: https://habr.com/ru/post/1734973/


All Articles