d = random_block()
for block in capacity:
block.write(d)
if block.read() != d:
fail("fake disk")
Since that would be fooled by a device mapping all reported blocks to the same actual storage. I guess you basically have to write unique data to all reported blocks first, then read them all back to verify.Since storage devices are often bigger than RAM, the data is probably best to generate procedurally (but deterministically) from the block number.
That sounds like fun!