Attention is currently required from: Nico Huber, Edward O'Callaghan, Angel Pons, Anastasia Klimchuk.
Peter Marheine has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/56911 )
Change subject: tests: add init_shutdown test for realtek_mst_i2c_spi
......................................................................
Patch Set 7:
(1 comment)
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/56911/comment/6678b4db_3050ee89
PS5, Line 93: return __wrap_open(pathname, flags);
> Ok, I can agree on that, makes sense! Then let's have the same impl […]
Done
--
To view, visit https://review.coreboot.org/c/flashrom/+/56911
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
Gerrit-Change-Number: 56911
Gerrit-PatchSet: 7
Gerrit-Owner: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Mon, 16 Aug 2021 05:25:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Comment-In-Reply-To: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Edward O'Callaghan, Angel Pons, Peter Marheine.
Hello build bot (Jenkins), Nico Huber, Edward O'Callaghan, Angel Pons, Anastasia Klimchuk,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/56911
to look at the new patch set (#7).
Change subject: tests: add init_shutdown test for realtek_mst_i2c_spi
......................................................................
tests: add init_shutdown test for realtek_mst_i2c_spi
This can catch regressions like the earlier one in this programmer that
caused initialization to always fail. Requires support for mocking POSIX
file I/O functions because the programmer does ioctls on the opened
file.
TEST=ninja test
Signed-off-by: Peter Marheine <pmarheine(a)chromium.org>
Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
---
M tests/init_shutdown.c
M tests/io_mock.h
M tests/meson.build
M tests/tests.c
M tests/tests.h
5 files changed, 100 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/11/56911/7
--
To view, visit https://review.coreboot.org/c/flashrom/+/56911
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
Gerrit-Change-Number: 56911
Gerrit-PatchSet: 7
Gerrit-Owner: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-MessageType: newpatchset
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/+/56911 )
Change subject: tests: add init_shutdown test for realtek_mst_i2c_spi
......................................................................
Patch Set 6:
(1 comment)
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/56911/comment/d4da3569_197c3a6c
PS5, Line 93: return __wrap_open(pathname, flags);
> I think it's so unlikely a test will ever care about the difference that it's better to pretend they […]
Ok, I can agree on that, makes sense! Then let's have the same impl
LOG_ME;
if (current_io && current_io->open)
return current_io->open(current_io->state, pathname, flags);
return MOCK_HANDLE;
for both wraps.
This way LOG_ME will tell which wrap has been called.
--
To view, visit https://review.coreboot.org/c/flashrom/+/56911
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
Gerrit-Change-Number: 56911
Gerrit-PatchSet: 6
Gerrit-Owner: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Comment-Date: Mon, 16 Aug 2021 04:55:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Comment-In-Reply-To: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Edward O'Callaghan, Anastasia Klimchuk.
Hello build bot (Jenkins), Nico Huber, Edward O'Callaghan, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/56753
to look at the new patch set (#4).
Change subject: tests: Use real spi_send_command for all tests except spi25.c
......................................................................
tests: Use real spi_send_command for all tests except spi25.c
At the moment one test (spi25.c) uses wrap of spi_send_command, and
all other existing tests don't care about this function (don't call
it at all). However in the next patch a new test in introduced, which
needs a real spi_send_command.
Following the approach "don't mock unless it is strictly necessary",
all tests that don't care go into real function bucket.
A declaration for __real_spi_send_command is needed for visibility,
this way wrap function can redirect to real function for all other
tests except spi25.c.
Additionally, wrap function moves below mock_chip, so that mock_chip
is visible inside wrap.
BUG=b:181803212
TEST=builds and ninja test
Change-Id: I22945cce3d0f36adaa8032167a3ef4e54eccb611
Signed-off-by: Anastasia Klimchuk <aklm(a)chromium.org>
---
M tests/spi25.c
1 file changed, 32 insertions(+), 16 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/53/56753/4
--
To view, visit https://review.coreboot.org/c/flashrom/+/56753
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I22945cce3d0f36adaa8032167a3ef4e54eccb611
Gerrit-Change-Number: 56753
Gerrit-PatchSet: 4
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: newpatchset
Attention is currently required from: Nico Huber, Edward O'Callaghan, Angel Pons, Anastasia Klimchuk.
Peter Marheine has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/56911 )
Change subject: tests: add init_shutdown test for realtek_mst_i2c_spi
......................................................................
Patch Set 6:
(10 comments)
File tests/init_shutdown.c:
https://review.coreboot.org/c/flashrom/+/56911/comment/e9dcf4c8_ec20130d
PS5, Line 217: if (strcmp(pathname, "/dev/i2c-254") != 0)
> Actually, given that this is test, let's make it an assert. […]
Done
https://review.coreboot.org/c/flashrom/+/56911/comment/596d2939_f0182b21
PS5, Line 219: if ((flags & O_RDWR) != O_RDWR)
> assert_int_equal
Done
https://review.coreboot.org/c/flashrom/+/56911/comment/05d0141c_fef7ee4e
PS5, Line 229: if (fd != REALTEK_MST_MOCK_FD)
> assert_int_equal
Done
https://review.coreboot.org/c/flashrom/+/56911/comment/bbdda22e_899a3ced
PS5, Line 231: if (request != I2C_SLAVE)
> assert_int_equal
Done
https://review.coreboot.org/c/flashrom/+/56911/comment/eeed3ac9_17ec039c
PS5, Line 235: if (addr != 0x4a)
> assert_int_equal
Done
https://review.coreboot.org/c/flashrom/+/56911/comment/33a3fea6_b1f54d2b
PS5, Line 243: if (fd != REALTEK_MST_MOCK_FD || sz != 1)
> assert_int_equal twice (for FD and for sz)
Done
https://review.coreboot.org/c/flashrom/+/56911/comment/1d2502a2_1e73c752
PS5, Line 250: if (fd != REALTEK_MST_MOCK_FD)
> assert_int_equal
Done
https://review.coreboot.org/c/flashrom/+/56911/comment/b2432c8d_784b45d5
PS5, Line 252: if (sz == 1 || sz == 2)
> assert_in_set
Done
File tests/io_mock.h:
https://review.coreboot.org/c/flashrom/+/56911/comment/0c469b81_16142e6f
PS5, Line 78: int (*open)(void *state, const char *pathname, int flags);
> In addition to my comment in tests.c: one more line here: […]
Ack
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/56911/comment/2c5b4a3f_c691b212
PS5, Line 93: return __wrap_open(pathname, flags);
> When I said "wrap doesn't need to redirect to another wrap" I meant this: […]
I think it's so unlikely a test will ever care about the difference that it's better to pretend they're the same. The Linux manual for open(2) doesn't describe open64() at all, because whether open() or open64() is used is generally an implementation detail of the C library determined by whether _FILE_OFFSET_BITS is 32 or 64 at build-time, and that further is only relevant to 32-bit systems (per feature_test_macros(7)).
If a test cared about the difference, that would probably indicate a bug in the implementation that would cause it to fail on some systems when built with some settings!
--
To view, visit https://review.coreboot.org/c/flashrom/+/56911
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
Gerrit-Change-Number: 56911
Gerrit-PatchSet: 6
Gerrit-Owner: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Mon, 16 Aug 2021 01:38:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Edward O'Callaghan, Angel Pons, Peter Marheine.
Hello build bot (Jenkins), Nico Huber, Edward O'Callaghan, Angel Pons, Anastasia Klimchuk,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/56911
to look at the new patch set (#6).
Change subject: tests: add init_shutdown test for realtek_mst_i2c_spi
......................................................................
tests: add init_shutdown test for realtek_mst_i2c_spi
This can catch regressions like the earlier one in this programmer that
caused initialization to always fail. Requires support for mocking POSIX
file I/O functions because the programmer does ioctls on the opened
file.
TEST=ninja test
Signed-off-by: Peter Marheine <pmarheine(a)chromium.org>
Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
---
M tests/init_shutdown.c
M tests/io_mock.h
M tests/meson.build
M tests/tests.c
M tests/tests.h
5 files changed, 99 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/11/56911/6
--
To view, visit https://review.coreboot.org/c/flashrom/+/56911
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
Gerrit-Change-Number: 56911
Gerrit-PatchSet: 6
Gerrit-Owner: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-MessageType: newpatchset
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/+/56911 )
Change subject: tests: add init_shutdown test for realtek_mst_i2c_spi
......................................................................
Patch Set 5:
(10 comments)
File tests/init_shutdown.c:
https://review.coreboot.org/c/flashrom/+/56911/comment/a9169b01_3f4e8764
PS5, Line 217: if (strcmp(pathname, "/dev/i2c-254") != 0)
Actually, given that this is test, let's make it an assert. In the case `assert_string_equal()` , full API is here https://api.cmocka.org/group__cmocka__asserts.html
The reason is: if pathname is incorrect, assert will fail with a message like " <some string> != "/dev/i2c-254" line 217 init_shutdown.c" , and by looking at the line 217 it would be clear where the error comes from.
Without assert, execution returns back to realtek_mst_i2c_spi.c and at some point init function fails, and the test fails with message like "0 != 1 line 29 init_shutdown.c". So you can only know that programmer_init failed and would need to spend more time debugging.
https://review.coreboot.org/c/flashrom/+/56911/comment/ff664d45_3a32c579
PS5, Line 219: if ((flags & O_RDWR) != O_RDWR)
assert_int_equal
https://review.coreboot.org/c/flashrom/+/56911/comment/21a91ca1_00732b77
PS5, Line 229: if (fd != REALTEK_MST_MOCK_FD)
assert_int_equal
https://review.coreboot.org/c/flashrom/+/56911/comment/6f8d2981_822b3fc4
PS5, Line 231: if (request != I2C_SLAVE)
assert_int_equal
https://review.coreboot.org/c/flashrom/+/56911/comment/fc2169fd_e34618cb
PS5, Line 235: if (addr != 0x4a)
assert_int_equal
https://review.coreboot.org/c/flashrom/+/56911/comment/a9d0680d_ef007adc
PS5, Line 243: if (fd != REALTEK_MST_MOCK_FD || sz != 1)
assert_int_equal twice (for FD and for sz)
https://review.coreboot.org/c/flashrom/+/56911/comment/b813e3df_a0becbb4
PS5, Line 250: if (fd != REALTEK_MST_MOCK_FD)
assert_int_equal
https://review.coreboot.org/c/flashrom/+/56911/comment/74028640_6fb3fe95
PS5, Line 252: if (sz == 1 || sz == 2)
assert_in_set
File tests/io_mock.h:
https://review.coreboot.org/c/flashrom/+/56911/comment/b269771c_1d1a2342
PS5, Line 78: int (*open)(void *state, const char *pathname, int flags);
In addition to my comment in tests.c: one more line here:
int (*open64)(void *state, const char *pathname, int flags);
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/56911/comment/f3e73aab_0208fe2d
PS5, Line 93: return __wrap_open(pathname, flags);
When I said "wrap doesn't need to redirect to another wrap" I meant this:
LOG_ME;
if (current_io && current_io->open64)
return current_io->open64(current_io->state, pathname, flags);
return MOCK_HANDLE;
And then if the tests want to handle both open and open64 in the same way,
const struct io_mock realtek_mst_io = {
.open = realtek_mst_open,
.open64 = realtek_mst_open,
......
}
The reason is: this layer (tests.c) is the same for all tests, I don't want to make assumptions what some test needs, test can decide. You are right, in most cases it doesn't matter, but let the test decide.
--
To view, visit https://review.coreboot.org/c/flashrom/+/56911
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
Gerrit-Change-Number: 56911
Gerrit-PatchSet: 5
Gerrit-Owner: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Comment-Date: Mon, 16 Aug 2021 00:15:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Edward O'Callaghan, Angel Pons, Anastasia Klimchuk.
Peter Marheine has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/56911 )
Change subject: tests: add init_shutdown test for realtek_mst_i2c_spi
......................................................................
Patch Set 5:
(1 comment)
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/56911/comment/a94c4a92_c774d233
PS4, Line 96: return __wrap_open(pathname, flags);
> I am sorry I only now noticed this, you don't need to redirect to another wrap, just […]
The point is that in most cases the difference isn't important, but I've decided to handle that by instead always delegating open64 to open and not offering the option to implement them separately.
--
To view, visit https://review.coreboot.org/c/flashrom/+/56911
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
Gerrit-Change-Number: 56911
Gerrit-PatchSet: 5
Gerrit-Owner: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Fri, 13 Aug 2021 07:11:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: comment