From b7dda22d6e50680be27409c42d2b58f5724a179a Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 25 Nov 2021 13:52:08 +0100 Subject: [PATCH] tests: update to new I2C API --- tests/periph_i2c/main.c | 11 ++++------- tests/pkg_fff/main.c | 9 ++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/periph_i2c/main.c b/tests/periph_i2c/main.c index 367bfa162f..3d27345dd3 100644 --- a/tests/periph_i2c/main.c +++ b/tests/periph_i2c/main.c @@ -129,7 +129,6 @@ static int _print_i2c_error(int res) int cmd_i2c_acquire(int argc, char **argv) { - int res; int dev; dev = _check_param(argc, argv, 1, 1, "DEV"); @@ -138,12 +137,10 @@ int cmd_i2c_acquire(int argc, char **argv) } printf("Command: i2c_acquire(%i)\n", dev); - res = i2c_acquire(dev); - if (res == I2C_ACK) { - printf("Success: i2c_%i acquired\n", dev); - return 0; - } - return _print_i2c_error(res); + i2c_acquire(dev); + + printf("Success: i2c_%i acquired\n", dev); + return 0; } int cmd_i2c_release(int argc, char **argv) diff --git a/tests/pkg_fff/main.c b/tests/pkg_fff/main.c index fad4a9aca0..f2f344ef37 100644 --- a/tests/pkg_fff/main.c +++ b/tests/pkg_fff/main.c @@ -21,7 +21,7 @@ #include DEFINE_FFF_GLOBALS FAKE_VALUE_FUNC(int, i2c_read_bytes, i2c_t, uint16_t, void *, size_t, uint8_t) -FAKE_VALUE_FUNC(int, i2c_acquire, i2c_t) +FAKE_VOID_FUNC(i2c_acquire, i2c_t) FAKE_VOID_FUNC(i2c_release, i2c_t) int test_i2c_basic(void *buffer, size_t len); @@ -35,14 +35,10 @@ const uint8_t flags = 0; int test_i2c_basic(void *buffer, size_t len) { - int acquire_return_val; int read_return_val; int failure = 0; - acquire_return_val = i2c_acquire(device); - if (acquire_return_val != 0) { - failure = 1; - } + i2c_acquire(device); read_return_val = i2c_read_bytes(device, address, buffer, len, flags); if (read_return_val != 0) { failure = 1; @@ -70,7 +66,6 @@ int main(void) puts("Testing fff"); /* Set fake implementation / return values of the mocks */ i2c_read_bytes_fake.custom_fake = read_fake_impl; - i2c_acquire_fake.return_val = 0; /* Run function under test */ basic_test_return_val = test_i2c_basic(buffer, fake_read_len); /* Assert correct interaction of the function under test with the mocked API */