aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lifecycle.c
diff options
context:
space:
mode:
authorDaniel Campello <campello@chromium.org>2022-03-29 20:47:46 -0600
committerAnastasia Klimchuk <aklm@chromium.org>2022-04-06 03:05:19 +0000
commit9454336970806b9b869ae1ee2515280051e60780 (patch)
tree1f50affa4a52c6044ccdad33965a420c74c8271c /tests/lifecycle.c
parentbd2d070f9fb2c8d89276a9e17ae7e4db1356d26e (diff)
downloadflashrom-9454336970806b9b869ae1ee2515280051e60780.tar.gz
flashrom-9454336970806b9b869ae1ee2515280051e60780.tar.bz2
flashrom-9454336970806b9b869ae1ee2515280051e60780.zip
tests: use MOCK_FD instead of NON_ZERO
With this change the mocks are able to return a non-negative value for the file descriptor expected from open operations. This avoid issues with subsequent error checks of the form `if (fd < 0)` BUG=b:227404721 TEST=./test_build.sh; FEATURES=test emerge-amd64-generic flashrom BRANCH=none Signed-off-by: Daniel Campello <campello@chromium.org> Change-Id: Ib6bac051852aea2465665a6fd669b7f5e3772985 Reviewed-on: https://review.coreboot.org/c/flashrom/+/63193 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'tests/lifecycle.c')
-rw-r--r--tests/lifecycle.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/tests/lifecycle.c b/tests/lifecycle.c
index 282a6b5d..c37f3b99 100644
--- a/tests/lifecycle.c
+++ b/tests/lifecycle.c
@@ -370,18 +370,16 @@ void linux_spi_probe_lifecycle_test_success(void **state)
#endif
}
-#define REALTEK_MST_MOCK_FD 0x10ec
-
static int realtek_mst_open(void *state, const char *pathname, int flags)
{
assert_string_equal(pathname, "/dev/i2c-254");
assert_int_equal(flags & O_RDWR, O_RDWR);
- return REALTEK_MST_MOCK_FD;
+ return MOCK_FD;
}
static int realtek_mst_ioctl(void *state, int fd, unsigned long request, va_list args)
{
- assert_int_equal(fd, REALTEK_MST_MOCK_FD);
+ assert_int_equal(fd, MOCK_FD);
assert_int_equal(request, I2C_SLAVE);
/* Only access to I2C address 0x4a is expected */
unsigned long addr = va_arg(args, unsigned long);
@@ -392,14 +390,14 @@ static int realtek_mst_ioctl(void *state, int fd, unsigned long request, va_list
static int realtek_mst_read(void *state, int fd, void *buf, size_t sz)
{
- assert_int_equal(fd, REALTEK_MST_MOCK_FD);
+ assert_int_equal(fd, MOCK_FD);
assert_int_equal(sz, 1);
return sz;
}
static int realtek_mst_write(void *state, int fd, const void *buf, size_t sz)
{
- assert_int_equal(fd, REALTEK_MST_MOCK_FD);
+ assert_int_equal(fd, MOCK_FD);
const LargestIntegralType accepted_sizes[] = {1, 2};
assert_in_set(sz, accepted_sizes, ARRAY_SIZE(accepted_sizes));
return sz;