From 08135c85d8e868f7eaf9cebeb356fd1b2816995f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 23 Jul 2015 09:00:31 +0200 Subject: i2c: Fix return status of i2c dev read/write --- testsuites/libtests/i2c01/init.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'testsuites/libtests/i2c01/init.c') diff --git a/testsuites/libtests/i2c01/init.c b/testsuites/libtests/i2c01/init.c index ddce494120..0d6fc839f3 100644 --- a/testsuites/libtests/i2c01/init.c +++ b/testsuites/libtests/i2c01/init.c @@ -71,6 +71,7 @@ typedef struct { typedef struct { test_device base; + bool eio; unsigned current_address; uint8_t data[EEPROM_SIZE]; } test_device_eeprom; @@ -198,6 +199,10 @@ static int test_eeprom_transfer( i2c_msg *msg = &msgs[0]; uint32_t i; + if (dev->eio) { + return -EIO; + } + if (msg_count > 0 && (msg->flags & I2C_M_RD) == 0) { if (msg->len < 1) { return -EIO; @@ -406,7 +411,7 @@ static void test_gpio_nxp_pca9535(void) rtems_test_assert(rv == 0); } -static void test_eeprom(void) +static void test_eeprom(test_bus *bus) { int rv; int fd_in; @@ -442,6 +447,20 @@ static void test_eeprom(void) memset(&out[0], 0, sizeof(out)); + bus->eeprom.eio = true; + + errno = 0; + n = read(fd_in, &in[0], 1); + rtems_test_assert(n == -1); + rtems_test_assert(errno == EIO); + + errno = 0; + n = write(fd_out, &out[0], 1); + rtems_test_assert(n == -1); + rtems_test_assert(errno == EIO); + + bus->eeprom.eio = false; + n = read(fd_in, &in[0], sizeof(in) + 1); rtems_test_assert(n == (ssize_t) sizeof(in)); @@ -608,7 +627,7 @@ static void test(void) rtems_test_assert(bus->base.timeout == 0); test_simple_read_write(bus, fd); - test_eeprom(); + test_eeprom(bus); test_gpio_nxp_pca9535(); test_switch_nxp_pca9548a(); -- cgit v1.2.3