Attention is currently required from: Nico Huber, Edward O'Callaghan, Angel Pons, Peter Marheine. Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/56413 )
Change subject: tests: Mock file i/o for linux_mtd and linux_spi tests ......................................................................
Patch Set 6:
(7 comments)
File tests/init_shutdown.c:
https://review.coreboot.org/c/flashrom/+/56413/comment/5e27b152_06d61a1a PS4, Line 208: 2021
this number is very arbitrary. […]
I switched to 0x55AA, because I need a "valid" descriptor. Next thing I will do (after this one), move MOCK_HANDLER one level up (in io_mock.h I think) and then it can be used everywhere in tests.
https://review.coreboot.org/c/flashrom/+/56413/comment/074cbb6e_ebd6d286 PS4, Line 214: int num_bytes = 0;
Hmmm, I'd like to get rid of `num_bytes`: […]
Wow thank you for the whole code! I only removed `const char *data = NULL;` it seemed unused.
https://review.coreboot.org/c/flashrom/+/56413/comment/a2ec7ca8_9d6e8016 PS4, Line 219: //
why not just `/` is something special happening here?
"//" is what's in the actual path which is constructed by linux_mtd. This programmer is definitely active and working, right? Or do you mean that one / is more correct and would also work? If that's the case, that better be a separate change, which starts with the programmer itself and test will follow.
https://review.coreboot.org/c/flashrom/+/56413/comment/ca172755_ad549a0a PS4, Line 221: memcpy(buf, "nor", num_bytes);
Use strcpy instead?
Yes right, and I am now using your idea from previous comment anyway
https://review.coreboot.org/c/flashrom/+/56413/comment/ab2a827d_33d05566 PS4, Line 230: num_bytes = 0;
seems like a bug? strings in C are null terminated which is a byte.
Oh yes... how did it even work?? But this chunk is now re-written anyway, number of bytes is strlen.
https://review.coreboot.org/c/flashrom/+/56413/comment/88c779a0_2ed0b5c1 PS4, Line 274: Provide pagesize into buf.
It is better to describe where the value is from and why it has it the particular value than re-desc […]
I added slightly different comment (took it from programmer code), but yes.
https://review.coreboot.org/c/flashrom/+/56413/comment/12e1d50c_c008ab2e PS4, Line 275: memcpy(buf, "1048576", len);
Hmmm, why use `len` here? If its value is larger than the length of "1048576", undefined behavior wo […]
Hope I fixed both comments in one go.