tests: drivers: i2s: ZTest ordering issue fix
The test was executing the expected functions out of order. I have created a config functions and explicitly declared them to be setup functions for this ZTest framework. Signed-off-by: Emilio Benavente <emilio.benavente@nxp.com>
This commit is contained in:
parent
d4cfc35b8d
commit
3ffc64a92d
2 changed files with 56 additions and 51 deletions
|
@ -8,4 +8,7 @@
|
|||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
ZTEST_SUITE(drivers_i2s_speed, NULL, NULL, NULL, NULL, NULL);
|
||||
extern void *test_i2s_speed_configure(void);
|
||||
extern void *test_i2s_speed_rxtx_configure(void);
|
||||
ZTEST_SUITE(drivers_i2s_speed, NULL, test_i2s_speed_configure, NULL, NULL, NULL);
|
||||
ZTEST_SUITE(drivers_i2s_speed_both_rxtx, NULL, test_i2s_speed_rxtx_configure, NULL, NULL, NULL);
|
||||
|
|
|
@ -178,31 +178,6 @@ static int configure_stream(const struct device *dev_i2s, enum i2s_dir dir)
|
|||
return TC_PASS;
|
||||
}
|
||||
|
||||
/** Configure I2S TX transfer. */
|
||||
ZTEST(drivers_i2s_speed, test_i2s_tx_transfer_configure)
|
||||
{
|
||||
int ret;
|
||||
|
||||
dev_i2s_tx = DEVICE_DT_GET_OR_NULL(I2S_DEV_NODE_TX);
|
||||
zassert_not_null(dev_i2s_tx, "transfer device not found");
|
||||
zassert(device_is_ready(dev_i2s_tx), "transfer device not ready");
|
||||
|
||||
ret = configure_stream(dev_i2s_tx, I2S_DIR_TX);
|
||||
zassert_equal(ret, TC_PASS);
|
||||
}
|
||||
|
||||
/** Configure I2S RX transfer. */
|
||||
ZTEST(drivers_i2s_speed, test_i2s_rx_transfer_configure)
|
||||
{
|
||||
int ret;
|
||||
|
||||
dev_i2s_rx = DEVICE_DT_GET_OR_NULL(I2S_DEV_NODE_RX);
|
||||
zassert_not_null(dev_i2s_rx, "receive device not found");
|
||||
zassert(device_is_ready(dev_i2s_rx), "receive device not ready");
|
||||
|
||||
ret = configure_stream(dev_i2s_rx, I2S_DIR_RX);
|
||||
zassert_equal(ret, TC_PASS);
|
||||
}
|
||||
|
||||
/** @brief Short I2S transfer.
|
||||
*
|
||||
|
@ -373,29 +348,6 @@ ZTEST(drivers_i2s_speed, test_i2s_transfer_long)
|
|||
zassert_equal(num_verified, NUM_BLOCKS, "Invalid RX blocks received");
|
||||
}
|
||||
|
||||
ZTEST(drivers_i2s_speed, test_i2s_dir_both_transfer_configure)
|
||||
{
|
||||
int ret;
|
||||
|
||||
dev_i2s_rxtx = DEVICE_DT_GET_OR_NULL(I2S_DEV_NODE_RX);
|
||||
zassert_not_null(dev_i2s_rxtx, "receive device not found");
|
||||
zassert(device_is_ready(dev_i2s_rxtx), "receive device not ready");
|
||||
|
||||
ret = configure_stream(dev_i2s_rxtx, I2S_DIR_BOTH);
|
||||
zassert_equal(ret, TC_PASS);
|
||||
|
||||
/* Check if the tested driver supports the I2S_DIR_BOTH value.
|
||||
* Use the DROP trigger for this, as in the current state of the driver
|
||||
* (READY, both TX and RX queues empty) it is actually a no-op.
|
||||
*/
|
||||
ret = i2s_trigger(dev_i2s_rxtx, I2S_DIR_BOTH, I2S_TRIGGER_DROP);
|
||||
dir_both_supported = (ret == 0);
|
||||
|
||||
if (IS_ENABLED(CONFIG_I2S_TEST_USE_I2S_DIR_BOTH)) {
|
||||
zassert_true(dir_both_supported,
|
||||
"I2S_DIR_BOTH value is supposed to be supported.");
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Short I2S transfer using I2S_DIR_BOTH.
|
||||
*
|
||||
|
@ -403,7 +355,7 @@ ZTEST(drivers_i2s_speed, test_i2s_dir_both_transfer_configure)
|
|||
* - Sending / receiving a short sequence of data returns success.
|
||||
* - DRAIN trigger empties the transmit queue and stops both streams.
|
||||
*/
|
||||
ZTEST(drivers_i2s_speed, test_i2s_dir_both_transfer_short)
|
||||
ZTEST(drivers_i2s_speed_both_rxtx, test_i2s_dir_both_transfer_short)
|
||||
{
|
||||
if (!dir_both_supported) {
|
||||
TC_PRINT("I2S_DIR_BOTH value is not supported.\n");
|
||||
|
@ -470,7 +422,7 @@ ZTEST(drivers_i2s_speed, test_i2s_dir_both_transfer_short)
|
|||
* - Sending / receiving a long sequence of data returns success.
|
||||
* - DRAIN trigger empties the transmit queue and stops both streams.
|
||||
*/
|
||||
ZTEST(drivers_i2s_speed, test_i2s_dir_both_transfer_long)
|
||||
ZTEST(drivers_i2s_speed_both_rxtx, test_i2s_dir_both_transfer_long)
|
||||
{
|
||||
if (!dir_both_supported) {
|
||||
TC_PRINT("I2S_DIR_BOTH value is not supported.\n");
|
||||
|
@ -543,3 +495,53 @@ ZTEST(drivers_i2s_speed, test_i2s_dir_both_transfer_long)
|
|||
}
|
||||
zassert_equal(num_verified, NUM_BLOCKS, "Invalid RX blocks received");
|
||||
}
|
||||
|
||||
void *test_i2s_speed_configure(void)
|
||||
{
|
||||
/* Configure I2S TX transfer. */
|
||||
int ret;
|
||||
|
||||
dev_i2s_tx = DEVICE_DT_GET_OR_NULL(I2S_DEV_NODE_TX);
|
||||
zassert_not_null(dev_i2s_tx, "transfer device not found");
|
||||
zassert(device_is_ready(dev_i2s_tx), "transfer device not ready");
|
||||
|
||||
ret = configure_stream(dev_i2s_tx, I2S_DIR_TX);
|
||||
zassert_equal(ret, TC_PASS);
|
||||
|
||||
/* Configure I2S RX transfer. */
|
||||
dev_i2s_rx = DEVICE_DT_GET_OR_NULL(I2S_DEV_NODE_RX);
|
||||
zassert_not_null(dev_i2s_rx, "receive device not found");
|
||||
zassert(device_is_ready(dev_i2s_rx), "receive device not ready");
|
||||
|
||||
ret = configure_stream(dev_i2s_rx, I2S_DIR_RX);
|
||||
zassert_equal(ret, TC_PASS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *test_i2s_speed_rxtx_configure(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Configure I2S Dir Both transfer. */
|
||||
dev_i2s_rxtx = DEVICE_DT_GET_OR_NULL(I2S_DEV_NODE_RX);
|
||||
zassert_not_null(dev_i2s_rxtx, "receive device not found");
|
||||
zassert(device_is_ready(dev_i2s_rxtx), "receive device not ready");
|
||||
|
||||
ret = configure_stream(dev_i2s_rxtx, I2S_DIR_BOTH);
|
||||
zassert_equal(ret, TC_PASS);
|
||||
|
||||
/* Check if the tested driver supports the I2S_DIR_BOTH value.
|
||||
* Use the DROP trigger for this, as in the current state of the driver
|
||||
* (READY, both TX and RX queues empty) it is actually a no-op.
|
||||
*/
|
||||
ret = i2s_trigger(dev_i2s_rxtx, I2S_DIR_BOTH, I2S_TRIGGER_DROP);
|
||||
dir_both_supported = (ret == 0);
|
||||
|
||||
if (IS_ENABLED(CONFIG_I2S_TEST_USE_I2S_DIR_BOTH)) {
|
||||
zassert_true(dir_both_supported,
|
||||
"I2S_DIR_BOTH value is supposed to be supported.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue