April 2011
Intermediate to advanced
356 pages
8h 55m
English
Before we looked under the hood of MockIO, Flash_Write passed a simple test where the device is immediately ready. It is not likely that the device would be ready right away. According to its specification, this device has a typical write time of ten microseconds. When the driver runs in a real device, the StatusRegister may be read hundreds or thousands of times. The driver needs to loop, waiting for the operation to complete, though we can prove the looping logic with just a few reads:
| tests/IO/FlashTest.cpp | |
| | TEST(Flash, WriteSucceeds_NotImmediatelyReady) |
| | { |
| | MockIO_Expect_Write(CommandRegister, ProgramCommand); |
| | MockIO_Expect_Write(address, data); |
| | MockIO_Expect_ReadThenReturn(StatusRegister, 0); |
| | MockIO_Expect_ReadThenReturn(StatusRegister, ... |