diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-07-23 09:00:31 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-07-23 09:00:31 +0200 |
commit | 08135c85d8e868f7eaf9cebeb356fd1b2816995f (patch) | |
tree | 6255927c9bdcf7bf3f6c2f7ad0644c8b302e35c3 /testsuites/libtests | |
parent | doc: Add SMP section to CPU Arch Supplement (diff) | |
download | rtems-08135c85d8e868f7eaf9cebeb356fd1b2816995f.tar.bz2 |
i2c: Fix return status of i2c dev read/write
Diffstat (limited to 'testsuites/libtests')
-rw-r--r-- | testsuites/libtests/i2c01/init.c | 23 |
1 files changed, 21 insertions, 2 deletions
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(); |