mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests: update to new I2C API
This commit is contained in:
parent
818c127513
commit
b7dda22d6e
@ -129,7 +129,6 @@ static int _print_i2c_error(int res)
|
|||||||
|
|
||||||
int cmd_i2c_acquire(int argc, char **argv)
|
int cmd_i2c_acquire(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int res;
|
|
||||||
int dev;
|
int dev;
|
||||||
|
|
||||||
dev = _check_param(argc, argv, 1, 1, "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);
|
printf("Command: i2c_acquire(%i)\n", dev);
|
||||||
res = i2c_acquire(dev);
|
i2c_acquire(dev);
|
||||||
if (res == I2C_ACK) {
|
|
||||||
printf("Success: i2c_%i acquired\n", dev);
|
printf("Success: i2c_%i acquired\n", dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
return _print_i2c_error(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_i2c_release(int argc, char **argv)
|
int cmd_i2c_release(int argc, char **argv)
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
DEFINE_FFF_GLOBALS
|
DEFINE_FFF_GLOBALS
|
||||||
FAKE_VALUE_FUNC(int, i2c_read_bytes, i2c_t, uint16_t, void *, size_t, uint8_t)
|
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)
|
FAKE_VOID_FUNC(i2c_release, i2c_t)
|
||||||
|
|
||||||
int test_i2c_basic(void *buffer, size_t len);
|
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 test_i2c_basic(void *buffer, size_t len)
|
||||||
{
|
{
|
||||||
int acquire_return_val;
|
|
||||||
int read_return_val;
|
int read_return_val;
|
||||||
int failure = 0;
|
int failure = 0;
|
||||||
|
|
||||||
acquire_return_val = i2c_acquire(device);
|
i2c_acquire(device);
|
||||||
if (acquire_return_val != 0) {
|
|
||||||
failure = 1;
|
|
||||||
}
|
|
||||||
read_return_val = i2c_read_bytes(device, address, buffer, len, flags);
|
read_return_val = i2c_read_bytes(device, address, buffer, len, flags);
|
||||||
if (read_return_val != 0) {
|
if (read_return_val != 0) {
|
||||||
failure = 1;
|
failure = 1;
|
||||||
@ -70,7 +66,6 @@ int main(void)
|
|||||||
puts("Testing fff");
|
puts("Testing fff");
|
||||||
/* Set fake implementation / return values of the mocks */
|
/* Set fake implementation / return values of the mocks */
|
||||||
i2c_read_bytes_fake.custom_fake = read_fake_impl;
|
i2c_read_bytes_fake.custom_fake = read_fake_impl;
|
||||||
i2c_acquire_fake.return_val = 0;
|
|
||||||
/* Run function under test */
|
/* Run function under test */
|
||||||
basic_test_return_val = test_i2c_basic(buffer, fake_read_len);
|
basic_test_return_val = test_i2c_basic(buffer, fake_read_len);
|
||||||
/* Assert correct interaction of the function under test with the mocked API */
|
/* Assert correct interaction of the function under test with the mocked API */
|
||||||
|
Loading…
Reference in New Issue
Block a user