diff options
author | Simon Glass <sjg@chromium.org> | 2020-05-10 12:52:45 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-05-19 14:01:47 -0400 |
commit | f91f366bd56ef290b7b1f24a40a8be02c148d6d9 (patch) | |
tree | d7c6b993a6fd5f5a4dea7731855baabde6ff16b1 /test/dm/i2c.c | |
parent | d934b43a0294148267c88f22d47aa2ebd77512a5 (diff) |
test: Use ut_asserteq_mem() where possible
Quite a few tests still use ut_assertok(memcmp(...)) and variants. Modify
them to use the macro designed for this purpose.
Suggested-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Diffstat (limited to 'test/dm/i2c.c')
-rw-r--r-- | test/dm/i2c.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/test/dm/i2c.c b/test/dm/i2c.c index cadbb43b9e..2025c4216d 100644 --- a/test/dm/i2c.c +++ b/test/dm/i2c.c @@ -51,10 +51,10 @@ static int dm_test_i2c_read_write(struct unit_test_state *uts) ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus)); ut_assertok(i2c_get_chip(bus, chip, 1, &dev)); ut_assertok(dm_i2c_read(dev, 0, buf, 5)); - ut_assertok(memcmp(buf, "\0\0\0\0\0", sizeof(buf))); + ut_asserteq_mem(buf, "\0\0\0\0\0", sizeof(buf)); ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2)); ut_assertok(dm_i2c_read(dev, 0, buf, 5)); - ut_assertok(memcmp(buf, "\0\0AB\0", sizeof(buf))); + ut_asserteq_mem(buf, "\0\0AB\0", sizeof(buf)); return 0; } @@ -123,7 +123,7 @@ static int dm_test_i2c_bytewise(struct unit_test_state *uts) ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus)); ut_assertok(i2c_get_chip(bus, chip, 1, &dev)); ut_assertok(dm_i2c_read(dev, 0, buf, 5)); - ut_assertok(memcmp(buf, "\0\0\0\0\0", sizeof(buf))); + ut_asserteq_mem(buf, "\0\0\0\0\0", sizeof(buf)); /* Tell the EEPROM to only read/write one register at a time */ ut_assertok(uclass_first_device(UCLASS_I2C_EMUL, &eeprom)); @@ -132,34 +132,34 @@ static int dm_test_i2c_bytewise(struct unit_test_state *uts) /* Now we only get the first byte - the rest will be 0xff */ ut_assertok(dm_i2c_read(dev, 0, buf, 5)); - ut_assertok(memcmp(buf, "\0\xff\xff\xff\xff", sizeof(buf))); + ut_asserteq_mem(buf, "\0\xff\xff\xff\xff", sizeof(buf)); /* If we do a separate transaction for each byte, it works */ ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS)); ut_assertok(dm_i2c_read(dev, 0, buf, 5)); - ut_assertok(memcmp(buf, "\0\0\0\0\0", sizeof(buf))); + ut_asserteq_mem(buf, "\0\0\0\0\0", sizeof(buf)); /* This will only write A */ ut_assertok(i2c_set_chip_flags(dev, 0)); ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2)); ut_assertok(dm_i2c_read(dev, 0, buf, 5)); - ut_assertok(memcmp(buf, "\0\xff\xff\xff\xff", sizeof(buf))); + ut_asserteq_mem(buf, "\0\xff\xff\xff\xff", sizeof(buf)); /* Check that the B was ignored */ ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS)); ut_assertok(dm_i2c_read(dev, 0, buf, 5)); - ut_assertok(memcmp(buf, "\0\0A\0\0\0", sizeof(buf))); + ut_asserteq_mem(buf, "\0\0A\0\0\0", sizeof(buf)); /* Now write it again with the new flags, it should work */ ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_WR_ADDRESS)); ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2)); ut_assertok(dm_i2c_read(dev, 0, buf, 5)); - ut_assertok(memcmp(buf, "\0\xff\xff\xff\xff", sizeof(buf))); + ut_asserteq_mem(buf, "\0\xff\xff\xff\xff", sizeof(buf)); ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_WR_ADDRESS | DM_I2C_CHIP_RD_ADDRESS)); ut_assertok(dm_i2c_read(dev, 0, buf, 5)); - ut_assertok(memcmp(buf, "\0\0AB\0\0", sizeof(buf))); + ut_asserteq_mem(buf, "\0\0AB\0\0", sizeof(buf)); /* Restore defaults */ sandbox_i2c_eeprom_set_test_mode(eeprom, SIE_TEST_MODE_NONE); |