Attention is currently required from: Edward O'Callaghan, Angel Pons, Anastasia Klimchuk. Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/51487 )
Change subject: tests: Add unit test to run init/shutdown for mec1308.c ......................................................................
Patch Set 7:
(1 comment)
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/51487/comment/2cf17884_0732a9b5 PS6, Line 102: return ((port == 0x2e /* MEC1308_SIO_PORT1 */ : || port == 0x4e /* MEC1308_SIO_PORT2 */) : ? 0x20 /* MEC1308_DEVICE_ID_REG */ : : ((outb_val == 0x84 /* MEC1308_MBX_DATA_START */) : ? 0xaa /* MEC1308_CMD_PASSTHRU_SUCCESS */ : : 0));
The tricky thing is: inb needs to know what was the value of the last outb call. […]
I think I mentioned something about a set of function pointers per tested programmer before ;) together with the state that is needed per programmer, that could be moved out of `tests.c`, closer to the actual test. I'll sketch and push something quickly, it's easier to show than to explain ^^
It's not a perfect solution. It would rely on global state and that means we could never test code for multiple programmers in parallel in one process. But I guess there is no way around it. We basically emulate PC hardware, the ports used by different programmers could overlap (e.g. 0x2e/0x4e are very common) so we can only emulate one at a time, or have to run tests in separate processes.