Skip to content

Commit

Permalink
firmware: tests: drivers: Update sl_ttc2 driver test #346
Browse files Browse the repository at this point in the history
  • Loading branch information
c-porto committed May 15, 2024
1 parent 3f2234f commit 92050c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion firmware/tests/drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SL_EPS2_TEST_FLAGS=$(FLAGS),--wrap=tca4311a_init,--wrap=tca4311a_enable,--wrap=t

MT25Q_TEST_FLAGS=$(FLAGS),--wrap=spi_init,--wrap=spi_select_slave,--wrap=spi_write,--wrap=spi_read,--wrap=spi_transfer,--wrap=gpio_init,--wrap=gpio_set_state,--wrap=gpio_get_state,--wrap=gpio_toggle

SL_TTC2_TEST_FLAGS=$(FLAGS),--wrap=spi_init,--wrap=spi_select_slave,--wrap=spi_write,--wrap=spi_read,--wrap=spi_transfer,--wrap=gpio_init,--wrap=gpio_set_state,--wrap=gpio_get_state,--wrap=gpio_toggle,--wrap=sl_ttc2_mutex_create,--wrap=sl_ttc2_mutex_take,--wrap=sl_ttc2_mutex_give,--wrap=sl_ttc2_spi_read
SL_TTC2_TEST_FLAGS=$(FLAGS),--wrap=spi_init,--wrap=spi_select_slave,--wrap=spi_write,--wrap=spi_read,--wrap=spi_transfer,--wrap=gpio_init,--wrap=gpio_set_state,--wrap=gpio_get_state,--wrap=gpio_toggle,--wrap=spi_mutex_take,--wrap=spi_mutex_give,--wrap=sl_ttc2_spi_read

.PHONY: all
.PHONY: all
Expand Down
31 changes: 14 additions & 17 deletions firmware/tests/drivers/sl_ttc2_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ static inline void read_adr(uint8_t adr, uint32_t val);

static void sl_ttc2_init_test(void **state)
{
/* Mutex creation */
will_return(__wrap_sl_ttc2_mutex_create, 0);

/* SPI init */
expect_value(__wrap_spi_init, port, SL_TTC2_SPI_PORT);
expect_value(__wrap_spi_init, config.speed_hz, SL_TTC2_SPI_CLOCK_HZ);
Expand All @@ -84,7 +81,7 @@ static void sl_ttc2_init_test(void **state)
ans[3] = 0xCC; /* Radio 0 ID */
ans[4] = 0x2A; /* Radio 0 ID */

will_return(__wrap_sl_ttc2_mutex_take, 0);
will_return(__wrap_spi_mutex_take, 0);

expect_value(__wrap_spi_write, port, SL_TTC2_SPI_PORT);
expect_value(__wrap_spi_write, cs, SL_TTC2_SPI_CS);
Expand All @@ -107,7 +104,7 @@ static void sl_ttc2_init_test(void **state)

will_return(__wrap_sl_ttc2_spi_read, 0);

will_return(__wrap_sl_ttc2_mutex_give, 0);
will_return(__wrap_spi_mutex_give, 0);

assert_return_code(sl_ttc2_init(conf), 0);
}
Expand Down Expand Up @@ -241,7 +238,7 @@ static void sl_ttc2_write_reg_test(void **state)
break;
}

will_return(__wrap_sl_ttc2_mutex_take, 0);
will_return(__wrap_spi_mutex_take, 0);

expect_value(__wrap_spi_write, port, SL_TTC2_SPI_PORT);
expect_value(__wrap_spi_write, cs, SL_TTC2_SPI_CS);
Expand All @@ -250,7 +247,7 @@ static void sl_ttc2_write_reg_test(void **state)

will_return(__wrap_spi_write, 0);

will_return(__wrap_sl_ttc2_mutex_give, 0);
will_return(__wrap_spi_mutex_give, 0);

assert_return_code(sl_ttc2_write_reg(conf, adr, val), 0);
}
Expand Down Expand Up @@ -375,7 +372,7 @@ static void sl_ttc2_read_reg_test(void **state)
break;
}

will_return(__wrap_sl_ttc2_mutex_take, 0);
will_return(__wrap_spi_mutex_take, 0);

expect_value(__wrap_spi_write, port, SL_TTC2_SPI_PORT);
expect_value(__wrap_spi_write, cs, SL_TTC2_SPI_CS);
Expand All @@ -398,7 +395,7 @@ static void sl_ttc2_read_reg_test(void **state)

will_return(__wrap_sl_ttc2_spi_read, 0);

will_return(__wrap_sl_ttc2_mutex_give, 0);
will_return(__wrap_spi_mutex_give, 0);

assert_return_code(sl_ttc2_read_reg(conf, adr, &res), 0);

Expand Down Expand Up @@ -762,7 +759,7 @@ static void sl_ttc2_set_tx_enable_test(void **state)
cmd[2] = adr; /* Address */
cmd[3] = val;

will_return(__wrap_sl_ttc2_mutex_take, 0);
will_return(__wrap_spi_mutex_take, 0);

expect_value(__wrap_spi_write, port, SL_TTC2_SPI_PORT);
expect_value(__wrap_spi_write, cs, SL_TTC2_SPI_CS);
Expand All @@ -771,7 +768,7 @@ static void sl_ttc2_set_tx_enable_test(void **state)

will_return(__wrap_spi_write, 0);

will_return(__wrap_sl_ttc2_mutex_give, 0);
will_return(__wrap_spi_mutex_give, 0);

assert_return_code(sl_ttc2_set_tx_enable(conf, (bool)val), 0);
}
Expand Down Expand Up @@ -873,7 +870,7 @@ static void sl_ttc2_transmit_packet_test(void **state)
cmd[1] = SL_TTC2_CMD_TRANSMIT_PKT; /* Transmit packet command */
cmd[2] = data_len; /* Data lenght */

will_return(__wrap_sl_ttc2_mutex_take, 0);
will_return(__wrap_spi_mutex_take, 0);

expect_value(__wrap_spi_write, port, SL_TTC2_SPI_PORT);
expect_value(__wrap_spi_write, cs, SL_TTC2_SPI_CS);
Expand All @@ -895,7 +892,7 @@ static void sl_ttc2_transmit_packet_test(void **state)

will_return(__wrap_spi_write, 0);

will_return(__wrap_sl_ttc2_mutex_give, 0);
will_return(__wrap_spi_mutex_give, 0);

assert_return_code(sl_ttc2_transmit_packet(conf, &cmd[3], data_len), 0);
}
Expand Down Expand Up @@ -924,7 +921,7 @@ static void sl_ttc2_read_packet_test(void **state)

read_adr(adr, (uint32_t)pkt_len);

will_return(__wrap_sl_ttc2_mutex_take, 0);
will_return(__wrap_spi_mutex_take, 0);

expect_value(__wrap_spi_write, port, SL_TTC2_SPI_PORT);
expect_value(__wrap_spi_write, cs, SL_TTC2_SPI_CS);
Expand All @@ -951,7 +948,7 @@ static void sl_ttc2_read_packet_test(void **state)

will_return(__wrap_sl_ttc2_spi_read, 0);

will_return(__wrap_sl_ttc2_mutex_give, 0);
will_return(__wrap_spi_mutex_give, 0);

assert_return_code(sl_ttc2_read_packet(conf, res_pkt, &res_pkt_len), 0);

Expand Down Expand Up @@ -1120,7 +1117,7 @@ static inline void read_adr(uint8_t adr, uint32_t val)
break;
}

will_return(__wrap_sl_ttc2_mutex_take, 0);
will_return(__wrap_spi_mutex_take, 0);

expect_value(__wrap_spi_write, port, SL_TTC2_SPI_PORT);
expect_value(__wrap_spi_write, cs, SL_TTC2_SPI_CS);
Expand All @@ -1143,7 +1140,7 @@ static inline void read_adr(uint8_t adr, uint32_t val)

will_return(__wrap_sl_ttc2_spi_read, 0);

will_return(__wrap_sl_ttc2_mutex_give, 0);
will_return(__wrap_spi_mutex_give, 0);
}

/** \} End of sl_ttc2_test group */

0 comments on commit 92050c3

Please sign in to comment.