My weekend project consists of writing a cross-platform concurrency primitives library (critical sections, read/write mutexes, interlocked integers, events, etc) and was wondering how to unit test this stuff. I realize that testing concurrent code is hard in itself, but testing the primitives of said code couldn't be that hard, could it?
Turns out, it is that hard. At least, for me it is.
So how would you go about approaching this? Just as an example, I don't even know where to start with testing critical sections.