tests/ztest: rename assert macros to be zephyr specific
ztest has a number of assert style macros and used a baseline assert() that varies from the system definition of assert() so lets rename everything as zassert to be clear. Change-Id: I7f176b3bae94d1045054d665be8b5bda947e5bb0 Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
a0fa4f3265
commit
c7bc909914
|
@ -21,7 +21,7 @@ static int returns_int(void)
|
|||
static void return_value_tests(void)
|
||||
{
|
||||
ztest_returns_value(returns_int, 5);
|
||||
assert_equal(returns_int(), 5, NULL);
|
||||
zassert_equal(returns_int(), 5, NULL);
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -115,7 +115,7 @@ option `CONFIG_ZTEST_ASSERT_VERBOSE=0`, the assertions will only print the
|
|||
file and line numbers, reducing the binary size of the test.
|
||||
|
||||
Example output for a failed macro from
|
||||
`assert_equal(buf->ref, 2, "Invalid refcount")`:
|
||||
`zassert_equal(buf->ref, 2, "Invalid refcount")`:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
static void assert_tests(void)
|
||||
{
|
||||
assert_true(1, "1 was false");
|
||||
assert_false(0, "0 was true");
|
||||
assert_is_null(NULL, "NULL was not NULL");
|
||||
assert_not_null("foo", "\"foo\" was NULL");
|
||||
assert_equal(1, 1, "1 was not equal to 1");
|
||||
assert_equal_ptr(NULL, NULL, "NULL was not equal to NULL");
|
||||
zassert_true(1, "1 was false");
|
||||
zassert_false(0, "0 was true");
|
||||
zassert_is_null(NULL, "NULL was not NULL");
|
||||
zassert_not_null("foo", "\"foo\" was NULL");
|
||||
zassert_equal(1, 1, "1 was not equal to 1");
|
||||
zassert_equal_ptr(NULL, NULL, "NULL was not equal to NULL");
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -50,10 +50,10 @@ static void test_get_single_buffer(void)
|
|||
|
||||
buf = net_buf_alloc(&bufs_pool, K_NO_WAIT);
|
||||
|
||||
assert_equal(buf->ref, 1, "Invalid refcount");
|
||||
assert_equal(buf->len, 0, "Invalid length");
|
||||
assert_equal(buf->flags, 0, "Invalid flags");
|
||||
assert_equal_ptr(buf->frags, NULL, "Frags not NULL");
|
||||
zassert_equal(buf->ref, 1, "Invalid refcount");
|
||||
zassert_equal(buf->len, 0, "Invalid length");
|
||||
zassert_equal(buf->flags, 0, "Invalid flags");
|
||||
zassert_equal_ptr(buf->frags, NULL, "Frags not NULL");
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -82,5 +82,5 @@ static int test_task(void)
|
|||
|
||||
void test_adc_sample(void)
|
||||
{
|
||||
assert_true(test_task() == TC_PASS, NULL);
|
||||
zassert_true(test_task() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ static void adc_test(void)
|
|||
unsigned int bufi0 = ~0, bufi;
|
||||
|
||||
adc = device_get_binding(ADC_DEVICE_NAME);
|
||||
assert_not_null(adc, "Cannot get adc controller\n");
|
||||
zassert_not_null(adc, "Cannot get adc controller\n");
|
||||
|
||||
adc_enable(adc);
|
||||
while (loops--) {
|
||||
|
@ -78,7 +78,7 @@ static void adc_test(void)
|
|||
/* .buffer should be void * ... */
|
||||
sample.buffer = (void *) seq_buffer[bufi];
|
||||
result = adc_read(adc, &table);
|
||||
assert_equal(result, 0, "Sampling could not proceed, "
|
||||
zassert_equal(result, 0, "Sampling could not proceed, "
|
||||
"an error occurred\n");
|
||||
printk("loop %u: sampling done to buffer #%u\n", loops, bufi);
|
||||
_print_sample_in_hex(seq_buffer[bufi], BUFFER_SIZE);
|
||||
|
|
|
@ -22,7 +22,7 @@ static void set_aio_callback(int polarity, int disable)
|
|||
gpio_pin_configure(gpio_dev, PIN_OUT, GPIO_DIR_OUT);
|
||||
|
||||
/* config AIN callback */
|
||||
assert_true(aio_cmp_configure(aio_dev, PIN_IN,
|
||||
zassert_true(aio_cmp_configure(aio_dev, PIN_IN,
|
||||
polarity, AIO_CMP_REF_A,
|
||||
callback, (void *)aio_dev) == 0,
|
||||
"ERROR registering callback");
|
||||
|
@ -46,11 +46,11 @@ static void set_aio_callback(int polarity, int disable)
|
|||
void test_aio_callback_rise(void)
|
||||
{
|
||||
set_aio_callback(AIO_CMP_POL_RISE, 0);
|
||||
assert_true(cb_cnt == 1, "callback is not invoked correctly");
|
||||
zassert_true(cb_cnt == 1, "callback is not invoked correctly");
|
||||
}
|
||||
|
||||
void test_aio_callback_rise_disable(void)
|
||||
{
|
||||
set_aio_callback(AIO_CMP_POL_RISE, 1);
|
||||
assert_true(cb_cnt == 0, "callback is not invoked correctly");
|
||||
zassert_true(cb_cnt == 0, "callback is not invoked correctly");
|
||||
}
|
||||
|
|
|
@ -74,5 +74,5 @@ static int test_counter(void)
|
|||
|
||||
void test_aon_counter(void)
|
||||
{
|
||||
assert_true(test_counter() == TC_PASS, NULL);
|
||||
zassert_true(test_counter() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -102,5 +102,5 @@ static int test_timer(void)
|
|||
|
||||
void test_aon_periodic_timer(void)
|
||||
{
|
||||
assert_true(test_timer() == TC_PASS, NULL);
|
||||
zassert_true(test_timer() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -87,20 +87,20 @@ static int test_task(uint32_t chan_id, uint32_t blen)
|
|||
/* export test cases */
|
||||
void test_dma_m2m_chan0_burst8(void)
|
||||
{
|
||||
assert_true((test_task(0, 8) == TC_PASS), NULL);
|
||||
zassert_true((test_task(0, 8) == TC_PASS), NULL);
|
||||
}
|
||||
|
||||
void test_dma_m2m_chan1_burst8(void)
|
||||
{
|
||||
assert_true((test_task(1, 8) == TC_PASS), NULL);
|
||||
zassert_true((test_task(1, 8) == TC_PASS), NULL);
|
||||
}
|
||||
|
||||
void test_dma_m2m_chan0_burst16(void)
|
||||
{
|
||||
assert_true((test_task(0, 16) == TC_PASS), NULL);
|
||||
zassert_true((test_task(0, 16) == TC_PASS), NULL);
|
||||
}
|
||||
|
||||
void test_dma_m2m_chan1_burst16(void)
|
||||
{
|
||||
assert_true((test_task(1, 16) == TC_PASS), NULL);
|
||||
zassert_true((test_task(1, 16) == TC_PASS), NULL);
|
||||
}
|
||||
|
|
|
@ -151,12 +151,12 @@ err_exit:
|
|||
|
||||
void test_gpio_callback_add_remove(void)
|
||||
{
|
||||
assert_true(
|
||||
zassert_true(
|
||||
test_callback_add_remove() == TC_PASS, NULL);
|
||||
}
|
||||
|
||||
void test_gpio_callback_enable_disable(void)
|
||||
{
|
||||
assert_true(
|
||||
zassert_true(
|
||||
test_callback_enable_disable() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ static void callback(struct device *dev,
|
|||
struct gpio_callback *gpio_cb, uint32_t pins)
|
||||
{
|
||||
/*= checkpoint: pins should be marked with correct pin number bit =*/
|
||||
assert_true(pin_num(pins) == PIN_IN, NULL);
|
||||
zassert_true(pin_num(pins) == PIN_IN, NULL);
|
||||
TC_PRINT("callback triggered: %d\n", ++cb_cnt);
|
||||
if (cb_cnt >= MAX_INT_CNT) {
|
||||
struct drv_data *drv_data = CONTAINER_OF(gpio_cb,
|
||||
|
@ -113,28 +113,28 @@ err_exit:
|
|||
/* export test cases */
|
||||
void test_gpio_callback_edge_high(void)
|
||||
{
|
||||
assert_true(
|
||||
zassert_true(
|
||||
test_callback(GPIO_INT_EDGE | GPIO_INT_ACTIVE_HIGH) == TC_PASS,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void test_gpio_callback_edge_low(void)
|
||||
{
|
||||
assert_true(
|
||||
zassert_true(
|
||||
test_callback(GPIO_INT_EDGE | GPIO_INT_ACTIVE_LOW) == TC_PASS,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void test_gpio_callback_level_high(void)
|
||||
{
|
||||
assert_true(
|
||||
zassert_true(
|
||||
test_callback(GPIO_INT_LEVEL | GPIO_INT_ACTIVE_HIGH) == TC_PASS,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void test_gpio_callback_level_low(void)
|
||||
{
|
||||
assert_true(
|
||||
zassert_true(
|
||||
test_callback(GPIO_INT_LEVEL | GPIO_INT_ACTIVE_LOW) == TC_PASS,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
@ -32,16 +32,16 @@ void test_gpio_pin_read_write(void)
|
|||
|
||||
while (i++ < 32) {
|
||||
val_write = sys_rand32_get() / 3 % 2;
|
||||
assert_true(gpio_pin_write(dev, PIN_OUT, val_write) == 0,
|
||||
zassert_true(gpio_pin_write(dev, PIN_OUT, val_write) == 0,
|
||||
"write data fail");
|
||||
TC_PRINT("write: %" PRIu32 "\n", val_write);
|
||||
k_sleep(100);
|
||||
assert_true(gpio_pin_read(dev, PIN_IN, &val_read) == 0,
|
||||
zassert_true(gpio_pin_read(dev, PIN_IN, &val_read) == 0,
|
||||
"read data fail");
|
||||
TC_PRINT("read: %" PRIu32 "\n", val_read);
|
||||
|
||||
/*= checkpoint: compare write and read value =*/
|
||||
assert_true(val_write == val_read,
|
||||
zassert_true(val_write == val_read,
|
||||
"Inconsistent GPIO read/write value");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,10 +133,10 @@ static int test_burst_gy271(void)
|
|||
|
||||
void test_i2c_gy271(void)
|
||||
{
|
||||
assert_true(test_gy271() == TC_PASS, NULL);
|
||||
zassert_true(test_gy271() == TC_PASS, NULL);
|
||||
}
|
||||
|
||||
void test_i2c_burst_gy271(void)
|
||||
{
|
||||
assert_true(test_burst_gy271() == TC_PASS, NULL);
|
||||
zassert_true(test_burst_gy271() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -158,6 +158,6 @@ static int test_gpio(uint32_t pin, uint32_t func)
|
|||
|
||||
void test_pinmux_gpio(void)
|
||||
{
|
||||
assert_true(test_gpio(PIN_IN, PINMUX_FUNC_A) == TC_PASS, NULL);
|
||||
assert_true(test_gpio(PIN_IN, PINMUX_FUNC_B) == TC_FAIL, NULL);
|
||||
zassert_true(test_gpio(PIN_IN, PINMUX_FUNC_A) == TC_PASS, NULL);
|
||||
zassert_true(test_gpio(PIN_IN, PINMUX_FUNC_B) == TC_FAIL, NULL);
|
||||
}
|
||||
|
|
|
@ -106,17 +106,17 @@ static int test_task(uint32_t port, uint32_t period, uint32_t pulse, bool cycle)
|
|||
void test_pwm_usec(void)
|
||||
{
|
||||
/* Period : Pulse (2000 : 1000), unit (usec). Voltage : 1.65V */
|
||||
assert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_USEC,
|
||||
zassert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_USEC,
|
||||
DEFAULT_PULSE_USEC, false) == TC_PASS, NULL);
|
||||
k_sleep(1000);
|
||||
|
||||
/* Period : Pulse (2000 : 2000), unit (usec). Voltage : 3.3V */
|
||||
assert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_USEC,
|
||||
zassert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_USEC,
|
||||
DEFAULT_PERIOD_USEC, false) == TC_PASS, NULL);
|
||||
k_sleep(1000);
|
||||
|
||||
/* Period : Pulse (2000 : 0), unit (usec). Voltage : 0V */
|
||||
assert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_USEC,
|
||||
zassert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_USEC,
|
||||
0, false) == TC_PASS, NULL);
|
||||
k_sleep(1000);
|
||||
}
|
||||
|
@ -124,16 +124,16 @@ void test_pwm_usec(void)
|
|||
void test_pwm_cycle(void)
|
||||
{
|
||||
/* Period : Pulse (64000 : 32000), unit (cycle). Voltage : 1.65V */
|
||||
assert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_CYCLE,
|
||||
zassert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_CYCLE,
|
||||
DEFAULT_PULSE_CYCLE, true) == TC_PASS, NULL);
|
||||
k_sleep(1000);
|
||||
|
||||
/* Period : Pulse (64000 : 64000), unit (cycle). Voltage : 3.3V */
|
||||
assert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_CYCLE,
|
||||
zassert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_CYCLE,
|
||||
DEFAULT_PERIOD_CYCLE, true) == TC_PASS, NULL);
|
||||
k_sleep(1000);
|
||||
|
||||
/* Period : Pulse (64000 : 0), unit (cycle). Voltage : 0V */
|
||||
assert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_CYCLE,
|
||||
zassert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_CYCLE,
|
||||
0, true) == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -112,5 +112,5 @@ static int test_alarm(void)
|
|||
|
||||
void test_rtc_alarm(void)
|
||||
{
|
||||
assert_true(test_alarm() == TC_PASS, NULL);
|
||||
zassert_true(test_alarm() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -69,5 +69,5 @@ static int test_task(void)
|
|||
|
||||
void test_rtc_calendar(void)
|
||||
{
|
||||
assert_true((test_task() == TC_PASS), NULL);
|
||||
zassert_true((test_task() == TC_PASS), NULL);
|
||||
}
|
||||
|
|
|
@ -85,18 +85,18 @@ static int test_spi(uint32_t mode)
|
|||
void test_spi_cpol(void)
|
||||
{
|
||||
TC_PRINT("Test SPI_MODE_CPOL\n");
|
||||
assert_true(test_spi(SPI_WORD(8) | SPI_MODE_CPOL) == TC_PASS, NULL);
|
||||
zassert_true(test_spi(SPI_WORD(8) | SPI_MODE_CPOL) == TC_PASS, NULL);
|
||||
}
|
||||
|
||||
void test_spi_cpha(void)
|
||||
{
|
||||
TC_PRINT("Test SPI_MODE_CPHA\n");
|
||||
assert_true(test_spi(SPI_WORD(8) | SPI_MODE_CPHA) == TC_PASS, NULL);
|
||||
zassert_true(test_spi(SPI_WORD(8) | SPI_MODE_CPHA) == TC_PASS, NULL);
|
||||
}
|
||||
|
||||
void test_spi_cpol_cpha(void)
|
||||
{
|
||||
TC_PRINT("Test SPI_MODE_CPOL | SPI_MODE_CPHA\n");
|
||||
assert_true(test_spi(SPI_WORD(8) | SPI_MODE_CPOL | SPI_MODE_CPHA)
|
||||
zassert_true(test_spi(SPI_WORD(8) | SPI_MODE_CPOL | SPI_MODE_CPHA)
|
||||
== TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -127,10 +127,10 @@ static int test_fifo_fill(void)
|
|||
|
||||
void test_uart_fifo_fill(void)
|
||||
{
|
||||
assert_true(test_fifo_fill() == TC_PASS, NULL);
|
||||
zassert_true(test_fifo_fill() == TC_PASS, NULL);
|
||||
}
|
||||
|
||||
void test_uart_fifo_read(void)
|
||||
{
|
||||
assert_true(test_fifo_read() == TC_PASS, NULL);
|
||||
zassert_true(test_fifo_read() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -84,10 +84,10 @@ static int test_poll_out(void)
|
|||
|
||||
void test_uart_poll_out(void)
|
||||
{
|
||||
assert_true(test_poll_out() == TC_PASS, NULL);
|
||||
zassert_true(test_poll_out() == TC_PASS, NULL);
|
||||
}
|
||||
|
||||
void test_uart_poll_in(void)
|
||||
{
|
||||
assert_true(test_poll_in() == TC_PASS, NULL);
|
||||
zassert_true(test_poll_in() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -145,14 +145,14 @@ static int test_wdt(uint32_t timeout, enum wdt_mode r_mode)
|
|||
*/
|
||||
void test_wdt_int_reset_26(void)
|
||||
{
|
||||
assert_true(test_wdt(WDT_2_26_CYCLES,
|
||||
zassert_true(test_wdt(WDT_2_26_CYCLES,
|
||||
WDT_MODE_INTERRUPT_RESET) == TC_PASS, NULL);
|
||||
QM_SCSS_GP->gps2 = 0;
|
||||
}
|
||||
|
||||
void test_wdt_reset_26(void)
|
||||
{
|
||||
assert_true(test_wdt(WDT_2_26_CYCLES,
|
||||
zassert_true(test_wdt(WDT_2_26_CYCLES,
|
||||
WDT_MODE_RESET) == TC_PASS, NULL);
|
||||
QM_SCSS_GP->gps2 = 0;
|
||||
}
|
||||
|
|
|
@ -56,26 +56,26 @@ static void alert_recv(void)
|
|||
if (palert->handler == K_ALERT_IGNORE ||
|
||||
palert->handler == alert_handler0){
|
||||
if (palert->handler == alert_handler0)
|
||||
assert_equal(handler_executed, PENDING_MAX, NULL);
|
||||
zassert_equal(handler_executed, PENDING_MAX, NULL);
|
||||
ret = k_alert_recv(palert, TIMEOUT);
|
||||
assert_equal(ret, -EAGAIN, NULL);
|
||||
zassert_equal(ret, -EAGAIN, NULL);
|
||||
}
|
||||
|
||||
if (palert->handler == K_ALERT_DEFAULT ||
|
||||
palert->handler == alert_handler1){
|
||||
if (palert->handler == alert_handler1)
|
||||
assert_equal(handler_executed, PENDING_MAX, NULL);
|
||||
zassert_equal(handler_executed, PENDING_MAX, NULL);
|
||||
for (int i = 0; i < PENDING_MAX; i++) {
|
||||
/**TESTPOINT: alert recv*/
|
||||
ret = k_alert_recv(palert, K_NO_WAIT);
|
||||
assert_false(ret, NULL);
|
||||
zassert_false(ret, NULL);
|
||||
}
|
||||
/**TESTPOINT: alert recv -EAGAIN*/
|
||||
ret = k_alert_recv(palert, TIMEOUT);
|
||||
assert_equal(ret, -EAGAIN, NULL);
|
||||
zassert_equal(ret, -EAGAIN, NULL);
|
||||
/**TESTPOINT: alert recv -EBUSY*/
|
||||
ret = k_alert_recv(palert, K_NO_WAIT);
|
||||
assert_equal(ret, -EBUSY, NULL);
|
||||
zassert_equal(ret, -EBUSY, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ void test_irq_vector_table(void)
|
|||
k_sem_init(&sem[ii], 0, UINT_MAX);
|
||||
}
|
||||
|
||||
assert_true((k_sem_take(&sem[0], K_NO_WAIT) ||
|
||||
zassert_true((k_sem_take(&sem[0], K_NO_WAIT) ||
|
||||
k_sem_take(&sem[1], K_NO_WAIT) ||
|
||||
k_sem_take(&sem[2], K_NO_WAIT)), NULL);
|
||||
|
||||
|
@ -90,7 +90,7 @@ void test_irq_vector_table(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
assert_false((k_sem_take(&sem[0], K_NO_WAIT) ||
|
||||
zassert_false((k_sem_take(&sem[0], K_NO_WAIT) ||
|
||||
k_sem_take(&sem[1], K_NO_WAIT) ||
|
||||
k_sem_take(&sem[2], K_NO_WAIT)), NULL);
|
||||
|
||||
|
|
|
@ -20,77 +20,77 @@ void atomic_test(void)
|
|||
oldvalue = 6;
|
||||
|
||||
/* atomic_cas() */
|
||||
assert_true((atomic_cas(&target, oldvalue, value) == 0), "atomic_cas");
|
||||
zassert_true((atomic_cas(&target, oldvalue, value) == 0), "atomic_cas");
|
||||
target = 6;
|
||||
assert_true((atomic_cas(&target, oldvalue, value) == 1), "atomic_cas");
|
||||
assert_true((target == value), "atomic_cas");
|
||||
zassert_true((atomic_cas(&target, oldvalue, value) == 1), "atomic_cas");
|
||||
zassert_true((target == value), "atomic_cas");
|
||||
|
||||
/* atomic_add() */
|
||||
target = 1;
|
||||
value = 2;
|
||||
assert_true((atomic_add(&target, value) == 1), "atomic_add");
|
||||
assert_true((target == 3), "atomic_add");
|
||||
zassert_true((atomic_add(&target, value) == 1), "atomic_add");
|
||||
zassert_true((target == 3), "atomic_add");
|
||||
|
||||
/* atomic_sub() */
|
||||
target = 10;
|
||||
value = 2;
|
||||
assert_true((atomic_sub(&target, value) == 10), "atomic_sub");
|
||||
assert_true((target == 8), "atomic_sub");
|
||||
zassert_true((atomic_sub(&target, value) == 10), "atomic_sub");
|
||||
zassert_true((target == 8), "atomic_sub");
|
||||
|
||||
/* atomic_inc() */
|
||||
target = 5;
|
||||
assert_true((atomic_inc(&target) == 5), "atomic_inc");
|
||||
assert_true((target == 6), "atomic_inc");
|
||||
zassert_true((atomic_inc(&target) == 5), "atomic_inc");
|
||||
zassert_true((target == 6), "atomic_inc");
|
||||
|
||||
/* atomic_dec() */
|
||||
target = 2;
|
||||
assert_true((atomic_dec(&target) == 2), "atomic_dec");
|
||||
assert_true((target == 1), "atomic_dec");
|
||||
zassert_true((atomic_dec(&target) == 2), "atomic_dec");
|
||||
zassert_true((target == 1), "atomic_dec");
|
||||
|
||||
/* atomic_get() */
|
||||
target = 50;
|
||||
assert_true((atomic_get(&target) == 50), "atomic_get");
|
||||
zassert_true((atomic_get(&target) == 50), "atomic_get");
|
||||
|
||||
/* atomic_set() */
|
||||
target = 42;
|
||||
value = 77;
|
||||
assert_true((atomic_set(&target, value) == 42), "atomic_set");
|
||||
assert_true((target == value), "atomic_set");
|
||||
zassert_true((atomic_set(&target, value) == 42), "atomic_set");
|
||||
zassert_true((target == value), "atomic_set");
|
||||
|
||||
/* atomic_clear() */
|
||||
target = 100;
|
||||
assert_true((atomic_clear(&target) == 100), "atomic_clear");
|
||||
assert_true((target == 0), "atomic_clear");
|
||||
zassert_true((atomic_clear(&target) == 100), "atomic_clear");
|
||||
zassert_true((target == 0), "atomic_clear");
|
||||
|
||||
/* atomic_or() */
|
||||
target = 0xFF00;
|
||||
value = 0x0F0F;
|
||||
assert_true((atomic_or(&target, value) == 0xFF00), "atomic_or");
|
||||
assert_true((target == 0xFF0F), "atomic_or");
|
||||
zassert_true((atomic_or(&target, value) == 0xFF00), "atomic_or");
|
||||
zassert_true((target == 0xFF0F), "atomic_or");
|
||||
|
||||
/* atomic_xor() */
|
||||
target = 0xFF00;
|
||||
value = 0x0F0F;
|
||||
assert_true((atomic_xor(&target, value) == 0xFF00), "atomic_xor");
|
||||
assert_true((target == 0xF00F), "atomic_xor");
|
||||
zassert_true((atomic_xor(&target, value) == 0xFF00), "atomic_xor");
|
||||
zassert_true((target == 0xF00F), "atomic_xor");
|
||||
|
||||
/* atomic_and() */
|
||||
target = 0xFF00;
|
||||
value = 0x0F0F;
|
||||
assert_true((atomic_and(&target, value) == 0xFF00), "atomic_and");
|
||||
assert_true((target == 0x0F00), "atomic_and");
|
||||
zassert_true((atomic_and(&target, value) == 0xFF00), "atomic_and");
|
||||
zassert_true((target == 0x0F00), "atomic_and");
|
||||
|
||||
|
||||
/* atomic_nand() */
|
||||
target = 0xFF00;
|
||||
value = 0x0F0F;
|
||||
assert_true((atomic_nand(&target, value) == 0xFF00), "atomic_nand");
|
||||
assert_true((target == 0xFFFFF0FF), "atomic_nand");
|
||||
zassert_true((atomic_nand(&target, value) == 0xFF00), "atomic_nand");
|
||||
zassert_true((target == 0xFFFFF0FF), "atomic_nand");
|
||||
|
||||
/* atomic_test_bit() */
|
||||
for (i = 0; i < 32; i++) {
|
||||
target = 0x0F0F0F0F;
|
||||
assert_true(!!(atomic_test_bit(&target, i) == !!(target & (1 << i))),
|
||||
zassert_true(!!(atomic_test_bit(&target, i) == !!(target & (1 << i))),
|
||||
"atomic_test_bit");
|
||||
}
|
||||
|
||||
|
@ -98,18 +98,18 @@ void atomic_test(void)
|
|||
for (i = 0; i < 32; i++) {
|
||||
orig = 0x0F0F0F0F;
|
||||
target = orig;
|
||||
assert_true(!!(atomic_test_and_clear_bit(&target, i)) == !!(orig & (1 << i)),
|
||||
zassert_true(!!(atomic_test_and_clear_bit(&target, i)) == !!(orig & (1 << i)),
|
||||
"atomic_test_and_clear_bit");
|
||||
assert_true(target == (orig & ~(1 << i)), "atomic_test_and_clear_bit");
|
||||
zassert_true(target == (orig & ~(1 << i)), "atomic_test_and_clear_bit");
|
||||
}
|
||||
|
||||
/* atomic_test_and_set_bit() */
|
||||
for (i = 0; i < 32; i++) {
|
||||
orig = 0x0F0F0F0F;
|
||||
target = orig;
|
||||
assert_true(!!(atomic_test_and_set_bit(&target, i)) == !!(orig & (1 << i)),
|
||||
zassert_true(!!(atomic_test_and_set_bit(&target, i)) == !!(orig & (1 << i)),
|
||||
"atomic_test_and_set_bit");
|
||||
assert_true(target == (orig | (1 << i)), "atomic_test_and_set_bit");
|
||||
zassert_true(target == (orig | (1 << i)), "atomic_test_and_set_bit");
|
||||
}
|
||||
|
||||
/* atomic_clear_bit() */
|
||||
|
@ -117,7 +117,7 @@ void atomic_test(void)
|
|||
orig = 0x0F0F0F0F;
|
||||
target = orig;
|
||||
atomic_clear_bit(&target, i);
|
||||
assert_true(target == (orig & ~(1 << i)), "atomic_clear_bit");
|
||||
zassert_true(target == (orig & ~(1 << i)), "atomic_clear_bit");
|
||||
}
|
||||
|
||||
/* atomic_set_bit() */
|
||||
|
@ -125,7 +125,7 @@ void atomic_test(void)
|
|||
orig = 0x0F0F0F0F;
|
||||
target = orig;
|
||||
atomic_set_bit(&target, i);
|
||||
assert_true(target == (orig | (1 << i)), "atomic_set_bit");
|
||||
zassert_true(target == (orig | (1 << i)), "atomic_set_bit");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,22 +22,22 @@ void bitfield_test(void)
|
|||
|
||||
sys_set_bit((mem_addr_t)&b1, bit);
|
||||
|
||||
assert_true(b1 == (1 << bit), "sys_set_bit failed on bit");
|
||||
zassert_true(b1 == (1 << bit), "sys_set_bit failed on bit");
|
||||
|
||||
assert_true((sys_test_bit((mem_addr_t)&b1, bit) == 0), "sys_test_bit did not detect bit");
|
||||
zassert_true((sys_test_bit((mem_addr_t)&b1, bit) == 0), "sys_test_bit did not detect bit");
|
||||
|
||||
sys_clear_bit((mem_addr_t)&b1, bit);
|
||||
|
||||
assert_true((b1 == 0), "sys_clear_bit failed for bit");
|
||||
zassert_true((b1 == 0), "sys_clear_bit failed for bit");
|
||||
|
||||
assert_true((sys_test_bit((mem_addr_t)&b1, bit) == 0), "sys_test_bit erroneously detected bit");
|
||||
zassert_true((sys_test_bit((mem_addr_t)&b1, bit) == 0), "sys_test_bit erroneously detected bit");
|
||||
|
||||
assert_true((sys_test_and_set_bit((mem_addr_t)&b1, bit) == 0), "sys_test_and_set_bit erroneously detected bit");
|
||||
zassert_true((sys_test_and_set_bit((mem_addr_t)&b1, bit) == 0), "sys_test_and_set_bit erroneously detected bit");
|
||||
|
||||
assert_true((b1 == (1 << bit)), "sys_test_and_set_bit");
|
||||
zassert_true((b1 == (1 << bit)), "sys_test_and_set_bit");
|
||||
|
||||
printk("%d\n", sys_test_and_set_bit((mem_addr_t)&b1, bit));
|
||||
assert_true((sys_test_and_set_bit((mem_addr_t)&b1, bit) == 0), "sys_test_and_set_bit");
|
||||
zassert_true((sys_test_and_set_bit((mem_addr_t)&b1, bit) == 0), "sys_test_and_set_bit");
|
||||
|
||||
}
|
||||
#if 0
|
||||
|
|
|
@ -18,11 +18,11 @@ void byteorder_test_memcpy_swap(void)
|
|||
uint8_t buf_dst[8] = { 0 };
|
||||
|
||||
sys_memcpy_swap(buf_dst, buf_orig, 8);
|
||||
assert_true((memcmp(buf_dst, buf_chk, 8) == 0),
|
||||
zassert_true((memcmp(buf_dst, buf_chk, 8) == 0),
|
||||
"Swap memcpy failed");
|
||||
|
||||
sys_memcpy_swap(buf_dst, buf_chk, 8);
|
||||
assert_true((memcmp(buf_dst, buf_orig, 8) == 0),
|
||||
zassert_true((memcmp(buf_dst, buf_orig, 8) == 0),
|
||||
"Swap memcpy failed");
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,11 @@ void byteorder_test_mem_swap(void)
|
|||
0x02, 0x01, 0x00 };
|
||||
|
||||
sys_mem_swap(buf_orig_1, 8);
|
||||
assert_true((memcmp(buf_orig_1, buf_chk_1, 8) == 0),
|
||||
zassert_true((memcmp(buf_orig_1, buf_chk_1, 8) == 0),
|
||||
"Swapping buffer failed");
|
||||
|
||||
sys_mem_swap(buf_orig_2, 11);
|
||||
assert_true((memcmp(buf_orig_2, buf_chk_2, 11) == 0),
|
||||
zassert_true((memcmp(buf_orig_2, buf_chk_2, 11) == 0),
|
||||
"Swapping buffer failed");
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ static void tclock_uptime(void)
|
|||
/**TESTPOINT: uptime straddled ms boundary*/
|
||||
t32 = k_uptime_get_32();
|
||||
ALIGN_MS_BOUNDARY;
|
||||
assert_true(k_uptime_get_32() > t32, NULL);
|
||||
zassert_true(k_uptime_get_32() > t32, NULL);
|
||||
|
||||
/**TESTPOINT: uptime delta*/
|
||||
d64 = k_uptime_delta(&d64);
|
||||
|
@ -46,7 +46,7 @@ static void tclock_uptime(void)
|
|||
/**TESTPOINT: uptime delta straddled ms boundary*/
|
||||
k_uptime_delta_32(&d64);
|
||||
ALIGN_MS_BOUNDARY;
|
||||
assert_true(k_uptime_delta_32(&d64) > 0, NULL);
|
||||
zassert_true(k_uptime_delta_32(&d64) > 0, NULL);
|
||||
}
|
||||
|
||||
static void tclock_cycle(void)
|
||||
|
@ -71,10 +71,10 @@ static void tclock_cycle(void)
|
|||
/*avoid cycle counter wrap around*/
|
||||
if (c1 > c0) {
|
||||
/* delta cycle should be greater than 1 milli-second*/
|
||||
assert_true((c1 - c0) >
|
||||
zassert_true((c1 - c0) >
|
||||
(sys_clock_hw_cycles_per_sec / MSEC_PER_SEC), NULL);
|
||||
/* delta NS should be greater than 1 milli-second */
|
||||
assert_true(SYS_CLOCK_HW_CYCLES_TO_NS(c1 - c0) >
|
||||
zassert_true(SYS_CLOCK_HW_CYCLES_TO_NS(c1 - c0) >
|
||||
(NSEC_PER_SEC / MSEC_PER_SEC), NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,34 +166,34 @@ void dlist_test(void)
|
|||
{
|
||||
sys_dlist_init(&test_list);
|
||||
|
||||
assert_true((verify_emptyness(&test_list)), "test_list should be empty");
|
||||
zassert_true((verify_emptyness(&test_list)), "test_list should be empty");
|
||||
|
||||
/* Appending node 1 */
|
||||
sys_dlist_append(&test_list, &test_node_1.node);
|
||||
assert_true((verify_content_amount(&test_list, 1)),
|
||||
zassert_true((verify_content_amount(&test_list, 1)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_1.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_1.node,
|
||||
&test_node_1.node, true)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Finding and removing node 1 */
|
||||
sys_dlist_remove(&test_node_1.node);
|
||||
assert_true((verify_emptyness(&test_list)),
|
||||
zassert_true((verify_emptyness(&test_list)),
|
||||
"test_list should be empty");
|
||||
|
||||
/* Prepending node 1 */
|
||||
sys_dlist_prepend(&test_list, &test_node_1.node);
|
||||
assert_true((verify_content_amount(&test_list, 1)),
|
||||
zassert_true((verify_content_amount(&test_list, 1)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_1.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_1.node,
|
||||
&test_node_1.node, true)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Removing node 1 */
|
||||
sys_dlist_remove(&test_node_1.node);
|
||||
assert_true((verify_emptyness(&test_list)),
|
||||
zassert_true((verify_emptyness(&test_list)),
|
||||
"test_list should be empty");
|
||||
|
||||
/* Appending node 1 */
|
||||
|
@ -201,24 +201,24 @@ void dlist_test(void)
|
|||
/* Prepending node 2 */
|
||||
sys_dlist_prepend(&test_list, &test_node_2.node);
|
||||
|
||||
assert_true((verify_content_amount(&test_list, 2)),
|
||||
zassert_true((verify_content_amount(&test_list, 2)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_1.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Appending node 3 */
|
||||
sys_dlist_append(&test_list, &test_node_3.node);
|
||||
|
||||
assert_true((verify_content_amount(&test_list, 3)),
|
||||
zassert_true((verify_content_amount(&test_list, 3)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_3.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
assert_true((sys_dlist_peek_next(&test_list, &test_node_2.node) ==
|
||||
zassert_true((sys_dlist_peek_next(&test_list, &test_node_2.node) ==
|
||||
&test_node_1.node),
|
||||
"test_list node links are wrong");
|
||||
|
||||
|
@ -226,44 +226,44 @@ void dlist_test(void)
|
|||
sys_dlist_insert_after(&test_list, &test_node_2.node,
|
||||
&test_node_4.node);
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_3.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
assert_true((sys_dlist_peek_next(&test_list, &test_node_2.node) ==
|
||||
zassert_true((sys_dlist_peek_next(&test_list, &test_node_2.node) ==
|
||||
&test_node_4.node),
|
||||
"test_list node links are wrong");
|
||||
|
||||
/* Finding and removing node 1 */
|
||||
sys_dlist_remove(&test_node_1.node);
|
||||
assert_true((verify_content_amount(&test_list, 3)),
|
||||
zassert_true((verify_content_amount(&test_list, 3)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_3.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Removing node 3 */
|
||||
sys_dlist_remove(&test_node_3.node);
|
||||
assert_true((verify_content_amount(&test_list, 2)),
|
||||
zassert_true((verify_content_amount(&test_list, 2)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_4.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Removing node 4 */
|
||||
sys_dlist_remove(&test_node_4.node);
|
||||
assert_true((verify_content_amount(&test_list, 1)),
|
||||
zassert_true((verify_content_amount(&test_list, 1)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_2.node, true)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Removing node 2 */
|
||||
sys_dlist_remove(&test_node_2.node);
|
||||
assert_true((verify_emptyness(&test_list)),
|
||||
zassert_true((verify_emptyness(&test_list)),
|
||||
"test_list should be empty");
|
||||
|
||||
/* test iterator from a node */
|
||||
|
@ -294,7 +294,7 @@ void dlist_test(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
assert_equal(ii, 3, "");
|
||||
zassert_equal(ii, 3, "");
|
||||
|
||||
ii = 0;
|
||||
SYS_DLIST_ITERATE_FROM_NODE(&test_list, node) {
|
||||
|
@ -303,11 +303,11 @@ void dlist_test(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
assert_equal(ii, 1, "");
|
||||
zassert_equal(ii, 1, "");
|
||||
|
||||
ii = 0;
|
||||
SYS_DLIST_ITERATE_FROM_NODE(&test_list, node) {
|
||||
ii++;
|
||||
}
|
||||
assert_equal(ii, 2, "");
|
||||
zassert_equal(ii, 2, "");
|
||||
}
|
||||
|
|
|
@ -18,15 +18,15 @@ void intmath_test(void)
|
|||
ba = 0x00000012ABCDEF12ULL;
|
||||
bb = 0x0000001000000111ULL;
|
||||
bignum = ba * bb;
|
||||
assert_true((bignum == 0xbcdf0509369bf232ULL), "64-bit multiplication failed");
|
||||
zassert_true((bignum == 0xbcdf0509369bf232ULL), "64-bit multiplication failed");
|
||||
|
||||
a = 30000;
|
||||
b = 5872;
|
||||
num = a * b;
|
||||
assert_true((num == 176160000), "32-bit multiplication failed");
|
||||
zassert_true((num == 176160000), "32-bit multiplication failed");
|
||||
|
||||
a = 234424432;
|
||||
b = 98982;
|
||||
num = a / b;
|
||||
assert_true((num == 2368), "32-bit division failed");
|
||||
zassert_true((num == 2368), "32-bit division failed");
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ void printk_test(void)
|
|||
printk("%u %02u %04u %08u\n", 42, 42, 42, 42);
|
||||
|
||||
ram_console[pos] = '\0';
|
||||
assert_true((strcmp(ram_console, expected) == 0), "printk failed");
|
||||
zassert_true((strcmp(ram_console, expected) == 0), "printk failed");
|
||||
|
||||
memset(ram_console, 0, sizeof(ram_console));
|
||||
count = 0;
|
||||
|
@ -99,5 +99,5 @@ void printk_test(void)
|
|||
"%u %02u %04u %08u\n", 42, 42, 42, 42);
|
||||
|
||||
ram_console[count] = '\0';
|
||||
assert_true((strcmp(ram_console, expected) == 0), "snprintk failed");
|
||||
zassert_true((strcmp(ram_console, expected) == 0), "snprintk failed");
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ void rand32_test(void)
|
|||
rnd_values[i] = sys_rand32_get();
|
||||
}
|
||||
for (i = 1; i < N_VALUES; i++) {
|
||||
assert_false((rnd_values[i - 1] == rnd_values[i]),
|
||||
zassert_false((rnd_values[i - 1] == rnd_values[i]),
|
||||
"random number subsequent calls return same value");
|
||||
}
|
||||
|
||||
|
|
|
@ -44,26 +44,26 @@ void ring_buffer_test(void)
|
|||
ret = sys_ring_buf_get(&ring_buf, &gettype, &getval, getdata, &getsize);
|
||||
if (ret != -EMSGSIZE) {
|
||||
SYS_LOG_DBG("Allowed retreival with insufficient destination buffer space");
|
||||
assert_true((getsize == INITIAL_SIZE), "Correct size wasn't reported back to the caller");
|
||||
zassert_true((getsize == INITIAL_SIZE), "Correct size wasn't reported back to the caller");
|
||||
}
|
||||
|
||||
for (i = 0; i < put_count; i++) {
|
||||
getsize = SIZE32_OF(getdata);
|
||||
ret = sys_ring_buf_get(&ring_buf, &gettype, &getval, getdata,
|
||||
&getsize);
|
||||
assert_true((ret == 0), "Couldn't retrieve a stored value");
|
||||
zassert_true((ret == 0), "Couldn't retrieve a stored value");
|
||||
SYS_LOG_DBG("got %u chunks of type %u and val %u, %u remaining",
|
||||
getsize, gettype, getval,
|
||||
sys_ring_buf_space_get(&ring_buf));
|
||||
|
||||
assert_true((memcmp((char *)getdata, data, getsize * sizeof(uint32_t)) == 0),
|
||||
zassert_true((memcmp((char *)getdata, data, getsize * sizeof(uint32_t)) == 0),
|
||||
"data corrupted");
|
||||
assert_true((gettype == TYPE), "type information corrupted");
|
||||
assert_true((getval == VALUE), "value information corrupted");
|
||||
zassert_true((gettype == TYPE), "type information corrupted");
|
||||
zassert_true((getval == VALUE), "value information corrupted");
|
||||
}
|
||||
|
||||
getsize = SIZE32_OF(getdata);
|
||||
ret = sys_ring_buf_get(&ring_buf, &gettype, &getval, getdata,
|
||||
&getsize);
|
||||
assert_true((ret == -EAGAIN), "Got data out of an empty buffer");
|
||||
zassert_true((ret == -EAGAIN), "Got data out of an empty buffer");
|
||||
}
|
||||
|
|
|
@ -166,34 +166,34 @@ void slist_test(void)
|
|||
{
|
||||
sys_slist_init(&test_list);
|
||||
|
||||
assert_true((verify_emptyness(&test_list)), "test_list should be empty");
|
||||
zassert_true((verify_emptyness(&test_list)), "test_list should be empty");
|
||||
|
||||
/* Appending node 1 */
|
||||
sys_slist_append(&test_list, &test_node_1.node);
|
||||
assert_true((verify_content_amount(&test_list, 1)),
|
||||
zassert_true((verify_content_amount(&test_list, 1)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_1.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_1.node,
|
||||
&test_node_1.node, true)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Finding and removing node 1 */
|
||||
sys_slist_find_and_remove(&test_list, &test_node_1.node);
|
||||
assert_true((verify_emptyness(&test_list)),
|
||||
zassert_true((verify_emptyness(&test_list)),
|
||||
"test_list should be empty");
|
||||
|
||||
/* Prepending node 1 */
|
||||
sys_slist_prepend(&test_list, &test_node_1.node);
|
||||
assert_true((verify_content_amount(&test_list, 1)),
|
||||
zassert_true((verify_content_amount(&test_list, 1)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_1.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_1.node,
|
||||
&test_node_1.node, true)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Removing node 1 */
|
||||
sys_slist_remove(&test_list, NULL, &test_node_1.node);
|
||||
assert_true((verify_emptyness(&test_list)),
|
||||
zassert_true((verify_emptyness(&test_list)),
|
||||
"test_list should be empty");
|
||||
|
||||
/* Appending node 1 */
|
||||
|
@ -201,68 +201,68 @@ void slist_test(void)
|
|||
/* Prepending node 2 */
|
||||
sys_slist_prepend(&test_list, &test_node_2.node);
|
||||
|
||||
assert_true((verify_content_amount(&test_list, 2)),
|
||||
zassert_true((verify_content_amount(&test_list, 2)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_1.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Appending node 3 */
|
||||
sys_slist_append(&test_list, &test_node_3.node);
|
||||
|
||||
assert_true((verify_content_amount(&test_list, 3)),
|
||||
zassert_true((verify_content_amount(&test_list, 3)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_3.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
assert_true((sys_slist_peek_next(&test_node_2.node) ==
|
||||
zassert_true((sys_slist_peek_next(&test_node_2.node) ==
|
||||
&test_node_1.node),
|
||||
"test_list node links are wrong");
|
||||
|
||||
/* Inserting node 4 after node 2 */
|
||||
sys_slist_insert(&test_list, &test_node_2.node, &test_node_4.node);
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_3.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
assert_true((sys_slist_peek_next(&test_node_2.node) ==
|
||||
zassert_true((sys_slist_peek_next(&test_node_2.node) ==
|
||||
&test_node_4.node),
|
||||
"test_list node links are wrong");
|
||||
|
||||
/* Finding and removing node 1 */
|
||||
sys_slist_find_and_remove(&test_list, &test_node_1.node);
|
||||
assert_true((verify_content_amount(&test_list, 3)),
|
||||
zassert_true((verify_content_amount(&test_list, 3)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_3.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Removing node 3 */
|
||||
sys_slist_remove(&test_list, &test_node_4.node, &test_node_3.node);
|
||||
assert_true((verify_content_amount(&test_list, 2)),
|
||||
zassert_true((verify_content_amount(&test_list, 2)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_4.node, false)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Removing node 4 */
|
||||
sys_slist_remove(&test_list, &test_node_2.node, &test_node_4.node);
|
||||
assert_true((verify_content_amount(&test_list, 1)),
|
||||
zassert_true((verify_content_amount(&test_list, 1)),
|
||||
"test_list has wrong content");
|
||||
|
||||
assert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
|
||||
&test_node_2.node, true)),
|
||||
"test_list head/tail are wrong");
|
||||
|
||||
/* Removing node 2 */
|
||||
sys_slist_remove(&test_list, NULL, &test_node_2.node);
|
||||
assert_true((verify_emptyness(&test_list)),
|
||||
zassert_true((verify_emptyness(&test_list)),
|
||||
"test_list should be empty");
|
||||
|
||||
/* test iterator from a node */
|
||||
|
@ -293,7 +293,7 @@ void slist_test(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
assert_equal(ii, 3, "");
|
||||
zassert_equal(ii, 3, "");
|
||||
|
||||
ii = 0;
|
||||
SYS_SLIST_ITERATE_FROM_NODE(&test_list, node) {
|
||||
|
@ -302,11 +302,11 @@ void slist_test(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
assert_equal(ii, 1, "");
|
||||
zassert_equal(ii, 1, "");
|
||||
|
||||
ii = 0;
|
||||
SYS_SLIST_ITERATE_FROM_NODE(&test_list, node) {
|
||||
ii++;
|
||||
}
|
||||
assert_equal(ii, 2, "");
|
||||
zassert_equal(ii, 2, "");
|
||||
}
|
||||
|
|
|
@ -66,15 +66,15 @@ void timeout_order_test(void)
|
|||
/* drop prio to get all poll events together */
|
||||
k_thread_priority_set(k_current_get(), prio + 1);
|
||||
|
||||
assert_equal(k_poll(poll_events, NUM_TIMEOUTS, 2000), 0, "");
|
||||
zassert_equal(k_poll(poll_events, NUM_TIMEOUTS, 2000), 0, "");
|
||||
|
||||
k_thread_priority_set(k_current_get(), prio - 1);
|
||||
|
||||
for (ii = 0; ii < NUM_TIMEOUTS; ii++) {
|
||||
assert_equal(poll_events[ii].state,
|
||||
zassert_equal(poll_events[ii].state,
|
||||
K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
}
|
||||
for (ii = 0; ii < NUM_TIMEOUTS; ii++) {
|
||||
assert_equal(results[ii], ii, "");
|
||||
zassert_equal(results[ii], ii, "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,10 +129,10 @@ void RegressionTask(void *arg1, void *arg2, void *arg3)
|
|||
nCalls = criticalLoop(nCalls);
|
||||
|
||||
/* Wait for AlternateTask() to complete */
|
||||
assert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0,
|
||||
zassert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0,
|
||||
"Timed out waiting for REGRESS_SEM");
|
||||
|
||||
assert_equal(criticalVar, nCalls + altTaskIterations,
|
||||
zassert_equal(criticalVar, nCalls + altTaskIterations,
|
||||
"Unexpected value for <criticalVar>");
|
||||
|
||||
k_sched_time_slice_set(10, 10);
|
||||
|
@ -142,10 +142,10 @@ void RegressionTask(void *arg1, void *arg2, void *arg3)
|
|||
nCalls = criticalLoop(nCalls);
|
||||
|
||||
/* Wait for AlternateTask() to finish */
|
||||
assert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0,
|
||||
zassert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0,
|
||||
"Timed out waiting for REGRESS_SEM");
|
||||
|
||||
assert_equal(criticalVar, nCalls + altTaskIterations,
|
||||
zassert_equal(criticalVar, nCalls + altTaskIterations,
|
||||
"Unexpected value for <criticalVar>");
|
||||
|
||||
k_sem_give(&TEST_SEM);
|
||||
|
@ -178,7 +178,7 @@ void test_critical(void)
|
|||
init_objects();
|
||||
start_threads();
|
||||
|
||||
assert_true(k_sem_take(&TEST_SEM, TEST_TIMEOUT * 2) == 0,
|
||||
zassert_true(k_sem_take(&TEST_SEM, TEST_TIMEOUT * 2) == 0,
|
||||
"Timed out waiting for TEST_SEM");
|
||||
}
|
||||
|
||||
|
|
|
@ -62,17 +62,17 @@ static void tfifo_get(struct k_fifo *pfifo)
|
|||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
/**TESTPOINT: fifo get*/
|
||||
rx_data = k_fifo_get(pfifo, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data[i], NULL);
|
||||
}
|
||||
/*get fifo data from "fifo_put_list"*/
|
||||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
rx_data = k_fifo_get(pfifo, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data_l[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data_l[i], NULL);
|
||||
}
|
||||
/*get fifo data from "fifo_put_slist"*/
|
||||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
rx_data = k_fifo_get(pfifo, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data_sl[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data_sl[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,13 +80,13 @@ static void tfifo_get(struct k_fifo *pfifo)
|
|||
static void tIsr_entry_put(void *p)
|
||||
{
|
||||
tfifo_put((struct k_fifo *)p);
|
||||
assert_false(k_fifo_is_empty((struct k_fifo *)p), NULL);
|
||||
zassert_false(k_fifo_is_empty((struct k_fifo *)p), NULL);
|
||||
}
|
||||
|
||||
static void tIsr_entry_get(void *p)
|
||||
{
|
||||
tfifo_get((struct k_fifo *)p);
|
||||
assert_true(k_fifo_is_empty((struct k_fifo *)p), NULL);
|
||||
zassert_true(k_fifo_is_empty((struct k_fifo *)p), NULL);
|
||||
}
|
||||
|
||||
static void tThread_entry(void *p1, void *p2, void *p3)
|
||||
|
@ -129,11 +129,11 @@ static void tfifo_is_empty(void *p)
|
|||
|
||||
tfifo_put(&fifo);
|
||||
/**TESTPOINT: return false when data available*/
|
||||
assert_false(k_fifo_is_empty(pfifo), NULL);
|
||||
zassert_false(k_fifo_is_empty(pfifo), NULL);
|
||||
|
||||
tfifo_get(&fifo);
|
||||
/**TESTPOINT: return true with data unavailable*/
|
||||
assert_true(k_fifo_is_empty(pfifo), NULL);
|
||||
zassert_true(k_fifo_is_empty(pfifo), NULL);
|
||||
}
|
||||
|
||||
/*test cases*/
|
||||
|
@ -171,7 +171,7 @@ void test_fifo_is_empty_thread(void)
|
|||
{
|
||||
k_fifo_init(&fifo);
|
||||
/**TESTPOINT: k_fifo_is_empty after init*/
|
||||
assert_true(k_fifo_is_empty(&fifo), NULL);
|
||||
zassert_true(k_fifo_is_empty(&fifo), NULL);
|
||||
|
||||
/**TESTPONT: check fifo is empty from thread*/
|
||||
tfifo_is_empty(&fifo);
|
||||
|
|
|
@ -26,7 +26,7 @@ void test_fifo_get_fail(void *p1, void *p2, void *p3)
|
|||
|
||||
k_fifo_init(&fifo);
|
||||
/**TESTPOINT: fifo get returns NULL*/
|
||||
assert_is_null(k_fifo_get(&fifo, K_NO_WAIT), NULL);
|
||||
assert_is_null(k_fifo_get(&fifo, TIMEOUT), NULL);
|
||||
zassert_is_null(k_fifo_get(&fifo, K_NO_WAIT), NULL);
|
||||
zassert_is_null(k_fifo_get(&fifo, TIMEOUT), NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static void tfifo_get(struct k_fifo *pfifo)
|
|||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
/**TESTPOINT: fifo get*/
|
||||
rx_data = k_fifo_get(pfifo, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ volatile long long_one = 1L;
|
|||
void limits_test(void)
|
||||
{
|
||||
|
||||
assert_true((long_max + long_one == LONG_MIN), NULL);
|
||||
zassert_true((long_max + long_one == LONG_MIN), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,8 +54,8 @@ void limits_test(void)
|
|||
void stdbool_test(void)
|
||||
{
|
||||
|
||||
assert_true((true == 1), "true value");
|
||||
assert_true((false == 0), "false value");
|
||||
zassert_true((true == 1), "true value");
|
||||
zassert_true((false == 0), "false value");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -75,7 +75,7 @@ volatile size_t size_of_long_variable = sizeof(long_variable);
|
|||
void stddef_test(void)
|
||||
{
|
||||
|
||||
assert_true((size_of_long_variable == 4), "sizeof");
|
||||
zassert_true((size_of_long_variable == 4), "sizeof");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -94,7 +94,7 @@ volatile uint32_t unsigned_int = 0xffffff00;
|
|||
|
||||
void stdint_test(void)
|
||||
{
|
||||
assert_true((unsigned_int + unsigned_byte + 1u == 0), NULL);
|
||||
zassert_true((unsigned_int + unsigned_byte + 1u == 0), NULL);
|
||||
|
||||
}
|
||||
|
||||
|
@ -115,8 +115,8 @@ char buffer[BUFSIZE];
|
|||
void memset_test(void)
|
||||
{
|
||||
memset(buffer, 'a', BUFSIZE);
|
||||
assert_true((buffer[0] == 'a'), "memset");
|
||||
assert_true((buffer[BUFSIZE - 1] == 'a'), "memset");
|
||||
zassert_true((buffer[0] == 'a'), "memset");
|
||||
zassert_true((buffer[BUFSIZE - 1] == 'a'), "memset");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +129,7 @@ void strlen_test(void)
|
|||
{
|
||||
memset(buffer, '\0', BUFSIZE);
|
||||
memset(buffer, 'b', 5); /* 5 is BUFSIZE / 2 */
|
||||
assert_equal(strlen(buffer), 5, "strlen");
|
||||
zassert_equal(strlen(buffer), 5, "strlen");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,9 +142,9 @@ void strcmp_test(void)
|
|||
{
|
||||
strcpy(buffer, "eeeee");
|
||||
|
||||
assert_true((strcmp(buffer, "fffff") < 0), "strcmp less ...");
|
||||
assert_true((strcmp(buffer, "eeeee") == 0), "strcmp equal ...");
|
||||
assert_true((strcmp(buffer, "ddddd") > 0), "strcmp greater ...");
|
||||
zassert_true((strcmp(buffer, "fffff") < 0), "strcmp less ...");
|
||||
zassert_true((strcmp(buffer, "eeeee") == 0), "strcmp equal ...");
|
||||
zassert_true((strcmp(buffer, "ddddd") > 0), "strcmp greater ...");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,9 +161,9 @@ void strncmp_test(void)
|
|||
__ASSERT_NO_MSG(sizeof(pattern) - 1 > BUFSIZE);
|
||||
memcpy(buffer, pattern, BUFSIZE);
|
||||
|
||||
assert_true((strncmp(buffer, "fffff", 0) == 0), "strncmp 0");
|
||||
assert_true((strncmp(buffer, "eeeff", 3) == 0), "strncmp 3");
|
||||
assert_true((strncmp(buffer, "eeeeeeeeeeeff", BUFSIZE) == 0),
|
||||
zassert_true((strncmp(buffer, "fffff", 0) == 0), "strncmp 0");
|
||||
zassert_true((strncmp(buffer, "eeeff", 3) == 0), "strncmp 3");
|
||||
zassert_true((strncmp(buffer, "eeeeeeeeeeeff", BUFSIZE) == 0),
|
||||
"strncmp 10");
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ void strcpy_test(void)
|
|||
memset(buffer, '\0', BUFSIZE);
|
||||
strcpy(buffer, "10 chars!\0");
|
||||
|
||||
assert_true((strcmp(buffer, "10 chars!\0") == 0), "strcpy");
|
||||
zassert_true((strcmp(buffer, "10 chars!\0") == 0), "strcpy");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,7 +197,7 @@ void strncpy_test(void)
|
|||
|
||||
/* Purposely different values */
|
||||
ret = strncmp(buffer, "This is over 20 characters", BUFSIZE);
|
||||
assert_true((ret == 0), "strncpy");
|
||||
zassert_true((ret == 0), "strncpy");
|
||||
|
||||
}
|
||||
|
||||
|
@ -217,11 +217,11 @@ void strchr_test(void)
|
|||
|
||||
rs = strchr(buffer, '1');
|
||||
|
||||
assert_not_null(rs, "strchr");
|
||||
zassert_not_null(rs, "strchr");
|
||||
|
||||
|
||||
ret = strncmp(rs, "10", 2);
|
||||
assert_true((ret == 0), "strchr");
|
||||
zassert_true((ret == 0), "strchr");
|
||||
|
||||
}
|
||||
|
||||
|
@ -239,10 +239,10 @@ void memcmp_test(void)
|
|||
|
||||
|
||||
ret = memcmp(m1, m2, 4);
|
||||
assert_true((ret == 0), "memcmp 4");
|
||||
zassert_true((ret == 0), "memcmp 4");
|
||||
|
||||
ret = memcmp(m1, m2, 5);
|
||||
assert_true((ret != 0), "memcmp 5");
|
||||
zassert_true((ret != 0), "memcmp 5");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ static void tlifo_get(struct k_lifo *plifo)
|
|||
for (int i = LIST_LEN-1; i >= 0; i--) {
|
||||
/**TESTPOINT: lifo get*/
|
||||
rx_data = k_lifo_get(plifo, K_FOREVER);
|
||||
assert_equal(rx_data, (void *)&data[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ void test_lifo_get_fail(void *p1, void *p2, void *p3)
|
|||
|
||||
k_lifo_init(&lifo);
|
||||
/**TESTPOINT: lifo get returns NULL*/
|
||||
assert_is_null(k_lifo_get(&lifo, K_NO_WAIT), NULL);
|
||||
assert_is_null(k_lifo_get(&lifo, TIMEOUT), NULL);
|
||||
zassert_is_null(k_lifo_get(&lifo, K_NO_WAIT), NULL);
|
||||
zassert_is_null(k_lifo_get(&lifo, TIMEOUT), NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static void tlifo_get(struct k_lifo *plifo)
|
|||
for (int i = LIST_LEN-1; i >= 0; i--) {
|
||||
/**TESTPOINT: lifo get*/
|
||||
rx_data = k_lifo_get(plifo, K_FOREVER);
|
||||
assert_equal(rx_data, (void *)&data[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ static void tmbox_put(struct k_mbox *pmbox)
|
|||
mmsg.info = ASYNC_PUT_GET_BLOCK;
|
||||
mmsg.size = MAIL_LEN;
|
||||
mmsg.tx_data = NULL;
|
||||
assert_equal(k_mem_pool_alloc(&mpooltx, &mmsg.tx_block,
|
||||
zassert_equal(k_mem_pool_alloc(&mpooltx, &mmsg.tx_block,
|
||||
MAIL_LEN, K_NO_WAIT), 0, NULL);
|
||||
memcpy(mmsg.tx_block.data, data[info_type], MAIL_LEN);
|
||||
if (info_type == TARGET_SOURCE_THREAD_BLOCK) {
|
||||
|
@ -136,12 +136,12 @@ static void tmbox_get(struct k_mbox *pmbox)
|
|||
mmsg.size = sizeof(rxdata);
|
||||
mmsg.rx_source_thread = K_ANY;
|
||||
/*verify return value*/
|
||||
assert_true(k_mbox_get(pmbox, &mmsg, rxdata, K_FOREVER) == 0,
|
||||
zassert_true(k_mbox_get(pmbox, &mmsg, rxdata, K_FOREVER) == 0,
|
||||
NULL);
|
||||
/*verify .info*/
|
||||
assert_equal(mmsg.info, PUT_GET_NULL, NULL);
|
||||
zassert_equal(mmsg.info, PUT_GET_NULL, NULL);
|
||||
/*verify .size*/
|
||||
assert_equal(mmsg.size, 0, NULL);
|
||||
zassert_equal(mmsg.size, 0, NULL);
|
||||
break;
|
||||
case PUT_GET_BUFFER:
|
||||
/*fall through*/
|
||||
|
@ -153,24 +153,24 @@ static void tmbox_get(struct k_mbox *pmbox)
|
|||
} else {
|
||||
mmsg.rx_source_thread = K_ANY;
|
||||
}
|
||||
assert_true(k_mbox_get(pmbox, &mmsg, rxdata, K_FOREVER) == 0,
|
||||
zassert_true(k_mbox_get(pmbox, &mmsg, rxdata, K_FOREVER) == 0,
|
||||
NULL);
|
||||
assert_equal(mmsg.info, PUT_GET_BUFFER, NULL);
|
||||
assert_equal(mmsg.size, sizeof(data[info_type]), NULL);
|
||||
zassert_equal(mmsg.info, PUT_GET_BUFFER, NULL);
|
||||
zassert_equal(mmsg.size, sizeof(data[info_type]), NULL);
|
||||
/*verify rxdata*/
|
||||
assert_true(memcmp(rxdata, data[info_type], MAIL_LEN) == 0,
|
||||
zassert_true(memcmp(rxdata, data[info_type], MAIL_LEN) == 0,
|
||||
NULL);
|
||||
break;
|
||||
case ASYNC_PUT_GET_BUFFER:
|
||||
/**TESTPOINT: mbox async get buffer*/
|
||||
mmsg.size = sizeof(rxdata);
|
||||
mmsg.rx_source_thread = K_ANY;
|
||||
assert_true(k_mbox_get(pmbox, &mmsg, NULL, K_FOREVER) == 0,
|
||||
zassert_true(k_mbox_get(pmbox, &mmsg, NULL, K_FOREVER) == 0,
|
||||
NULL);
|
||||
assert_equal(mmsg.info, ASYNC_PUT_GET_BUFFER, NULL);
|
||||
assert_equal(mmsg.size, sizeof(data[info_type]), NULL);
|
||||
zassert_equal(mmsg.info, ASYNC_PUT_GET_BUFFER, NULL);
|
||||
zassert_equal(mmsg.size, sizeof(data[info_type]), NULL);
|
||||
k_mbox_data_get(&mmsg, rxdata);
|
||||
assert_true(memcmp(rxdata, data[info_type], MAIL_LEN) == 0,
|
||||
zassert_true(memcmp(rxdata, data[info_type], MAIL_LEN) == 0,
|
||||
NULL);
|
||||
break;
|
||||
case ASYNC_PUT_GET_BLOCK:
|
||||
|
@ -183,14 +183,14 @@ static void tmbox_get(struct k_mbox *pmbox)
|
|||
} else {
|
||||
mmsg.rx_source_thread = K_ANY;
|
||||
}
|
||||
assert_true(k_mbox_get(pmbox, &mmsg, NULL, K_FOREVER) == 0,
|
||||
zassert_true(k_mbox_get(pmbox, &mmsg, NULL, K_FOREVER) == 0,
|
||||
NULL);
|
||||
assert_true(k_mbox_data_block_get
|
||||
zassert_true(k_mbox_data_block_get
|
||||
(&mmsg, &mpoolrx, &rxblock, K_FOREVER) == 0, NULL);
|
||||
assert_equal(mmsg.info, ASYNC_PUT_GET_BLOCK, NULL);
|
||||
assert_equal(mmsg.size, MAIL_LEN, NULL);
|
||||
zassert_equal(mmsg.info, ASYNC_PUT_GET_BLOCK, NULL);
|
||||
zassert_equal(mmsg.size, MAIL_LEN, NULL);
|
||||
/*verify rxblock*/
|
||||
assert_true(memcmp(rxblock.data, data[info_type], MAIL_LEN)
|
||||
zassert_true(memcmp(rxblock.data, data[info_type], MAIL_LEN)
|
||||
== 0, NULL);
|
||||
k_mem_pool_free(&rxblock);
|
||||
break;
|
||||
|
|
|
@ -32,12 +32,12 @@ void test_mheap_malloc_free(void)
|
|||
*/
|
||||
block[i] = k_malloc(i);
|
||||
/** TESTPOINT: Address of the allocated memory if successful;*/
|
||||
assert_not_null(block[i], NULL);
|
||||
zassert_not_null(block[i], NULL);
|
||||
}
|
||||
|
||||
block_fail = k_malloc(BLK_SIZE_MIN);
|
||||
/** TESTPOINT: Return NULL if fail.*/
|
||||
assert_is_null(block_fail, NULL);
|
||||
zassert_is_null(block_fail, NULL);
|
||||
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
/**
|
||||
|
|
|
@ -35,8 +35,8 @@ void test_mheap_malloc_align4(void)
|
|||
*/
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
block[i] = k_malloc(i);
|
||||
assert_not_null(block[i], NULL);
|
||||
assert_false((int)block[i]%4, NULL);
|
||||
zassert_not_null(block[i], NULL);
|
||||
zassert_false((int)block[i]%4, NULL);
|
||||
}
|
||||
|
||||
/* test case tear down*/
|
||||
|
@ -61,11 +61,11 @@ void test_mheap_min_block_size(void)
|
|||
*/
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
block[i] = k_malloc(TEST_SIZE_0);
|
||||
assert_not_null(block[i], NULL);
|
||||
zassert_not_null(block[i], NULL);
|
||||
}
|
||||
/* verify no more free blocks available*/
|
||||
block_fail = k_malloc(BLK_SIZE_MIN);
|
||||
assert_is_null(block_fail, NULL);
|
||||
zassert_is_null(block_fail, NULL);
|
||||
|
||||
/* test case tear down*/
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
|
@ -91,11 +91,11 @@ void test_mheap_block_desc(void)
|
|||
*/
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
block[i] = k_malloc(BLK_SIZE_EXCLUDE_DESC);
|
||||
assert_not_null(block[i], NULL);
|
||||
zassert_not_null(block[i], NULL);
|
||||
}
|
||||
/* verify no more free blocks available*/
|
||||
block_fail = k_malloc(BLK_SIZE_MIN);
|
||||
assert_is_null(block_fail, NULL);
|
||||
zassert_is_null(block_fail, NULL);
|
||||
|
||||
/* test case tear down*/
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
|
|
|
@ -39,9 +39,9 @@ void tmpool_alloc_free(void *data)
|
|||
* the block descriptor is set to the starting address of the
|
||||
* memory block.
|
||||
*/
|
||||
assert_true(k_mem_pool_alloc(&kmpool, &block[i], BLK_SIZE_MIN,
|
||||
zassert_true(k_mem_pool_alloc(&kmpool, &block[i], BLK_SIZE_MIN,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
assert_not_null(block[i].data, NULL);
|
||||
zassert_not_null(block[i].data, NULL);
|
||||
}
|
||||
|
||||
for (int i = 0; i < BLK_NUM_MIN; i++) {
|
||||
|
@ -58,9 +58,9 @@ void tmpool_alloc_free(void *data)
|
|||
* @a max_size bytes long.
|
||||
*/
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
assert_true(k_mem_pool_alloc(&kmpool, &block[i], BLK_SIZE_MAX,
|
||||
zassert_true(k_mem_pool_alloc(&kmpool, &block[i], BLK_SIZE_MAX,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
assert_not_null(block[i].data, NULL);
|
||||
zassert_not_null(block[i].data, NULL);
|
||||
}
|
||||
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
|
@ -85,10 +85,10 @@ void test_mpool_alloc_size(void)
|
|||
* into quarters, down to blocks of @a min_size bytes long.
|
||||
*/
|
||||
while (size >= BLK_SIZE_MIN) {
|
||||
assert_true(k_mem_pool_alloc(&kmpool, &block[i], size,
|
||||
zassert_true(k_mem_pool_alloc(&kmpool, &block[i], size,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
assert_not_null(block[i].data, NULL);
|
||||
assert_true((uint32_t)(block[i].data) % BLK_ALIGN == 0, NULL);
|
||||
zassert_not_null(block[i].data, NULL);
|
||||
zassert_true((uint32_t)(block[i].data) % BLK_ALIGN == 0, NULL);
|
||||
i++;
|
||||
size = size >> 2;
|
||||
}
|
||||
|
@ -103,10 +103,10 @@ void test_mpool_alloc_size(void)
|
|||
* aligned to this boundary, min_size must also be a multiple of align.
|
||||
*/
|
||||
while (size <= BLK_SIZE_MAX) {
|
||||
assert_true(k_mem_pool_alloc(&kmpool, &block[i], size,
|
||||
zassert_true(k_mem_pool_alloc(&kmpool, &block[i], size,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
assert_not_null(block[i].data, NULL);
|
||||
assert_true((uint32_t)(block[i].data) % BLK_ALIGN == 0, NULL);
|
||||
zassert_not_null(block[i].data, NULL);
|
||||
zassert_true((uint32_t)(block[i].data) % BLK_ALIGN == 0, NULL);
|
||||
i++;
|
||||
size = size << 2;
|
||||
}
|
||||
|
@ -122,23 +122,23 @@ void test_mpool_alloc_timeout(void)
|
|||
int64_t tms;
|
||||
|
||||
for (int i = 0; i < BLK_NUM_MIN; i++) {
|
||||
assert_equal(k_mem_pool_alloc(&kmpool, &block[i], BLK_SIZE_MIN,
|
||||
zassert_equal(k_mem_pool_alloc(&kmpool, &block[i], BLK_SIZE_MIN,
|
||||
K_NO_WAIT), 0, NULL);
|
||||
}
|
||||
|
||||
/** TESTPOINT: Use K_NO_WAIT to return without waiting*/
|
||||
/** TESTPOINT: @retval -ENOMEM Returned without waiting*/
|
||||
assert_equal(k_mem_pool_alloc(&kmpool, &fblock, BLK_SIZE_MIN,
|
||||
zassert_equal(k_mem_pool_alloc(&kmpool, &fblock, BLK_SIZE_MIN,
|
||||
K_NO_WAIT), -ENOMEM, NULL);
|
||||
/** TESTPOINT: @retval -EAGAIN Waiting period timed out*/
|
||||
tms = k_uptime_get();
|
||||
assert_equal(k_mem_pool_alloc(&kmpool, &fblock, BLK_SIZE_MIN, TIMEOUT),
|
||||
zassert_equal(k_mem_pool_alloc(&kmpool, &fblock, BLK_SIZE_MIN, TIMEOUT),
|
||||
-EAGAIN, NULL);
|
||||
/**
|
||||
* TESTPOINT: Maximum time to wait for operation to complete (in
|
||||
* milliseconds)
|
||||
*/
|
||||
assert_true(k_uptime_delta(&tms) >= TIMEOUT, NULL);
|
||||
zassert_true(k_uptime_delta(&tms) >= TIMEOUT, NULL);
|
||||
|
||||
for (int i = 0; i < BLK_NUM_MIN; i++) {
|
||||
k_mem_pool_free(&block[i]);
|
||||
|
@ -152,7 +152,7 @@ void test_mpool_defrag(void)
|
|||
|
||||
/*fragment the memory pool into small blocks*/
|
||||
for (int i = 0; i < BLK_NUM_MIN; i++) {
|
||||
assert_true(k_mem_pool_alloc(&kmpool, &block[i], BLK_SIZE_MIN,
|
||||
zassert_true(k_mem_pool_alloc(&kmpool, &block[i], BLK_SIZE_MIN,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
}
|
||||
/*free the small blocks in the 1st half of the pool*/
|
||||
|
@ -160,7 +160,7 @@ void test_mpool_defrag(void)
|
|||
k_mem_pool_free(&block[i]);
|
||||
}
|
||||
/*request a big block, the pool has "adjacent free blocks" to merge*/
|
||||
assert_true(k_mem_pool_alloc(&kmpool, &block[0], BLK_SIZE_MAX,
|
||||
zassert_true(k_mem_pool_alloc(&kmpool, &block[0], BLK_SIZE_MAX,
|
||||
K_FOREVER) == 0, NULL);
|
||||
/*free the small blocks in the 2nd half of the pool*/
|
||||
for (int i = (BLK_NUM_MIN >> 1); i < BLK_NUM_MIN; i++) {
|
||||
|
@ -173,7 +173,7 @@ void test_mpool_defrag(void)
|
|||
/*do manual de-fragment*/
|
||||
k_mem_pool_defrag(&kmpool);
|
||||
/*request a big block, the pool is de-fragmented*/
|
||||
assert_true(k_mem_pool_alloc(&kmpool, &block[1], BLK_SIZE_MAX,
|
||||
zassert_true(k_mem_pool_alloc(&kmpool, &block[1], BLK_SIZE_MAX,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
/*free the big blocks*/
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
|
|
|
@ -23,11 +23,11 @@ void test_mpool_alloc_size_roundup(void)
|
|||
*/
|
||||
for (int i = 0; i < BLK_NUM_MAX; i++) {
|
||||
/*request a size for the mpool to round up to "BLK_SIZE_MAX"*/
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block[i], TEST_SIZE,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block[i], TEST_SIZE,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
}
|
||||
/*verify consequently no more blocks available*/
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block_fail, BLK_SIZE_MIN,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block_fail, BLK_SIZE_MIN,
|
||||
K_NO_WAIT) == -ENOMEM, NULL);
|
||||
|
||||
/*test case tear down*/
|
||||
|
|
|
@ -51,14 +51,14 @@ void tmpool_alloc_wait_timeout(void *p1, void *p2, void *p3)
|
|||
{
|
||||
struct k_mem_block block;
|
||||
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block, BLK_SIZE_MIN,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block, BLK_SIZE_MIN,
|
||||
TIMEOUT) == -EAGAIN, NULL);
|
||||
k_sem_give(&sync_sema);
|
||||
}
|
||||
|
||||
void tmpool_alloc_wait_ok(void *p1, void *p2, void *p3)
|
||||
{
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block_ok, BLK_SIZE_MIN,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block_ok, BLK_SIZE_MIN,
|
||||
TIMEOUT) == 0, NULL);
|
||||
k_sem_give(&sync_sema);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void test_mpool_alloc_wait_prio(void)
|
|||
k_sem_init(&sync_sema, 0, THREAD_NUM);
|
||||
/*allocated up all blocks*/
|
||||
for (int i = 0; i < BLK_NUM_MIN; i++) {
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block[i], BLK_SIZE_MIN,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block[i], BLK_SIZE_MIN,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ void test_mpool_alloc_merge_failed_diff_parent(void)
|
|||
*/
|
||||
for (int i = 0; i < BLK_NUM_MIN; i++) {
|
||||
/* 1. allocated up all blocks*/
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block[i], BLK_SIZE_MIN,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block[i], BLK_SIZE_MIN,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
}
|
||||
/* 2. free adjacent blocks belong to different parent quad-blocks*/
|
||||
|
@ -34,7 +34,7 @@ void test_mpool_alloc_merge_failed_diff_parent(void)
|
|||
}
|
||||
/* 3. request a big block, expected failed to merge*/
|
||||
k_mem_pool_defrag(&mpool1);
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block_fail, BLK_SIZE_MAX,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block_fail, BLK_SIZE_MAX,
|
||||
TIMEOUT) == -EAGAIN, NULL);
|
||||
|
||||
/* 4. test case tear down*/
|
||||
|
|
|
@ -37,7 +37,7 @@ void test_mpool_alloc_merge_failed_diff_size(void)
|
|||
*/
|
||||
for (int i = 0; i < block_count; i++) {
|
||||
/* 1. allocate blocks in different sizes*/
|
||||
assert_true(k_mem_pool_alloc(&mpool3, &block[i], block_size[i],
|
||||
zassert_true(k_mem_pool_alloc(&mpool3, &block[i], block_size[i],
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
}
|
||||
/* 2. free block [2~8], in different sizes*/
|
||||
|
@ -46,7 +46,7 @@ void test_mpool_alloc_merge_failed_diff_size(void)
|
|||
}
|
||||
/* 3. request a big block, expected failed to merge*/
|
||||
k_mem_pool_defrag(&mpool3);
|
||||
assert_true(k_mem_pool_alloc(&mpool3, &block_fail, BLK_SIZE_MAX,
|
||||
zassert_true(k_mem_pool_alloc(&mpool3, &block_fail, BLK_SIZE_MAX,
|
||||
TIMEOUT) == -EAGAIN, NULL);
|
||||
|
||||
/* 4. test case tear down*/
|
||||
|
|
|
@ -51,10 +51,10 @@ static void tmpool_split_before_defrag(void)
|
|||
*/
|
||||
TC_PRINT("CONFIG_MEM_POOL_SPLIT_BEFORE_DEFRAG\n");
|
||||
/* 1. request a mid-size block*/
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block_split, BLK_SIZE_MID,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block_split, BLK_SIZE_MID,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
/* 2. verify the previous block was split from the 2nd max block*/
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block_max, BLK_SIZE_MAX,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block_max, BLK_SIZE_MAX,
|
||||
TIMEOUT) == -EAGAIN, NULL);
|
||||
k_mem_pool_free(&block_split);
|
||||
}
|
||||
|
@ -77,10 +77,10 @@ static void tmpool_defrag_before_split(void)
|
|||
*/
|
||||
TC_PRINT("CONFIG_MEM_POOL_DEFRAG_BEFORE_SPLIT\n");
|
||||
/* 1. request a mid-size block*/
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block_defrag, BLK_SIZE_MID,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block_defrag, BLK_SIZE_MID,
|
||||
TIMEOUT) == 0, NULL);
|
||||
/* 2. verify the previous block was defrag from block[0~3]*/
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block_max, BLK_SIZE_MAX,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block_max, BLK_SIZE_MAX,
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
k_mem_pool_free(&block_defrag);
|
||||
k_mem_pool_free(&block_max);
|
||||
|
@ -107,11 +107,11 @@ static void tmpool_split_only(void)
|
|||
TC_PRINT("CONFIG_MEM_POOL_SPLIT_ONLY\n");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
/* 1. verify allocation ok via spliting the max block*/
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block_mid[i],
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block_mid[i],
|
||||
BLK_SIZE_MID, K_NO_WAIT) == 0, NULL);
|
||||
}
|
||||
/* 2. verify allocation failed since no large blocks nor defrag*/
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block_fail, BLK_SIZE_MID,
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block_fail, BLK_SIZE_MID,
|
||||
TIMEOUT) == -EAGAIN, NULL);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
k_mem_pool_free(&block_mid[i]);
|
||||
|
@ -124,7 +124,7 @@ void test_mpool_alloc_options(void)
|
|||
{
|
||||
/* allocate 7 blocks, in size 4 4 4 4 16 16 16, respectively*/
|
||||
for (int i = 0; i < block_count; i++) {
|
||||
assert_true(k_mem_pool_alloc(&mpool1, &block[i], block_size[i],
|
||||
zassert_true(k_mem_pool_alloc(&mpool1, &block[i], block_size[i],
|
||||
K_NO_WAIT) == 0, NULL);
|
||||
}
|
||||
/* free block [0~3]*/
|
||||
|
|
|
@ -41,13 +41,13 @@ void tmslab_alloc_free(void *data)
|
|||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
/** TESTPOINT: Allocate memory from a memory slab.*/
|
||||
/** TESTPOINT: @retval 0 Memory allocated.*/
|
||||
assert_true(k_mem_slab_alloc(pslab, &block[i], K_NO_WAIT) == 0,
|
||||
zassert_true(k_mem_slab_alloc(pslab, &block[i], K_NO_WAIT) == 0,
|
||||
NULL);
|
||||
/**
|
||||
* TESTPOINT: The block address area pointed at by @a mem is set
|
||||
* to the starting address of the memory block.
|
||||
*/
|
||||
assert_not_null(block[i], NULL);
|
||||
zassert_not_null(block[i], NULL);
|
||||
}
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
/** TESTPOINT: Free memory allocated from a memory slab.*/
|
||||
|
@ -61,13 +61,13 @@ static void tmslab_alloc_align(void *data)
|
|||
void *block[BLK_NUM];
|
||||
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
assert_true(k_mem_slab_alloc(pslab, &block[i], K_NO_WAIT) == 0,
|
||||
zassert_true(k_mem_slab_alloc(pslab, &block[i], K_NO_WAIT) == 0,
|
||||
NULL);
|
||||
/**
|
||||
* TESTPOINT: To ensure that each memory block is similarly
|
||||
* aligned to this boundary
|
||||
*/
|
||||
assert_true((uint32_t)block[i] % BLK_ALIGN == 0, NULL);
|
||||
zassert_true((uint32_t)block[i] % BLK_ALIGN == 0, NULL);
|
||||
}
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
k_mem_slab_free(pslab, &block[i]);
|
||||
|
@ -81,23 +81,23 @@ static void tmslab_alloc_timeout(void *data)
|
|||
int64_t tms;
|
||||
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
assert_true(k_mem_slab_alloc(pslab, &block[i], K_NO_WAIT) == 0,
|
||||
zassert_true(k_mem_slab_alloc(pslab, &block[i], K_NO_WAIT) == 0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/** TESTPOINT: Use K_NO_WAIT to return without waiting*/
|
||||
/** TESTPOINT: @retval -ENOMEM Returned without waiting.*/
|
||||
assert_equal(k_mem_slab_alloc(pslab, &block_fail, K_NO_WAIT), -ENOMEM,
|
||||
zassert_equal(k_mem_slab_alloc(pslab, &block_fail, K_NO_WAIT), -ENOMEM,
|
||||
NULL);
|
||||
/** TESTPOINT: @retval -EAGAIN Waiting period timed out*/
|
||||
tms = k_uptime_get();
|
||||
assert_equal(k_mem_slab_alloc(pslab, &block_fail, TIMEOUT), -EAGAIN,
|
||||
zassert_equal(k_mem_slab_alloc(pslab, &block_fail, TIMEOUT), -EAGAIN,
|
||||
NULL);
|
||||
/**
|
||||
* TESTPOINT: @param timeout Maximum time to wait for operation to
|
||||
* complete (in milliseconds)
|
||||
*/
|
||||
assert_true(k_uptime_delta(&tms) >= TIMEOUT, NULL);
|
||||
zassert_true(k_uptime_delta(&tms) >= TIMEOUT, NULL);
|
||||
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
k_mem_slab_free(pslab, &block[i]);
|
||||
|
@ -110,32 +110,32 @@ static void tmslab_used_get(void *data)
|
|||
void *block[BLK_NUM], *block_fail;
|
||||
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
assert_true(k_mem_slab_alloc(pslab, &block[i], K_NO_WAIT) == 0,
|
||||
zassert_true(k_mem_slab_alloc(pslab, &block[i], K_NO_WAIT) == 0,
|
||||
NULL);
|
||||
/** TESTPOINT: Get the number of used blocks in a memory slab.*/
|
||||
assert_equal(k_mem_slab_num_used_get(pslab), i+1, NULL);
|
||||
zassert_equal(k_mem_slab_num_used_get(pslab), i+1, NULL);
|
||||
/**
|
||||
* TESTPOINT: Get the number of unused blocks in a memory slab.
|
||||
*/
|
||||
assert_equal(k_mem_slab_num_free_get(pslab), BLK_NUM-1-i, NULL);
|
||||
zassert_equal(k_mem_slab_num_free_get(pslab), BLK_NUM-1-i, NULL);
|
||||
}
|
||||
|
||||
assert_equal(k_mem_slab_alloc(pslab, &block_fail, K_NO_WAIT), -ENOMEM,
|
||||
zassert_equal(k_mem_slab_alloc(pslab, &block_fail, K_NO_WAIT), -ENOMEM,
|
||||
NULL);
|
||||
/* free get on allocation failure*/
|
||||
assert_equal(k_mem_slab_num_free_get(pslab), 0, NULL);
|
||||
zassert_equal(k_mem_slab_num_free_get(pslab), 0, NULL);
|
||||
/* used get on allocation failure*/
|
||||
assert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM, NULL);
|
||||
zassert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM, NULL);
|
||||
|
||||
assert_equal(k_mem_slab_alloc(pslab, &block_fail, TIMEOUT), -EAGAIN,
|
||||
zassert_equal(k_mem_slab_alloc(pslab, &block_fail, TIMEOUT), -EAGAIN,
|
||||
NULL);
|
||||
assert_equal(k_mem_slab_num_free_get(pslab), 0, NULL);
|
||||
assert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM, NULL);
|
||||
zassert_equal(k_mem_slab_num_free_get(pslab), 0, NULL);
|
||||
zassert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM, NULL);
|
||||
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
k_mem_slab_free(pslab, &block[i]);
|
||||
assert_equal(k_mem_slab_num_free_get(pslab), i+1, NULL);
|
||||
assert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM-1-i, NULL);
|
||||
zassert_equal(k_mem_slab_num_free_get(pslab), i+1, NULL);
|
||||
zassert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM-1-i, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,14 +143,14 @@ static void tmslab_used_get(void *data)
|
|||
void test_mslab_kinit(void)
|
||||
{
|
||||
k_mem_slab_init(&mslab, tslab, BLK_SIZE, BLK_NUM);
|
||||
assert_equal(k_mem_slab_num_used_get(&mslab), 0, NULL);
|
||||
assert_equal(k_mem_slab_num_free_get(&mslab), BLK_NUM, NULL);
|
||||
zassert_equal(k_mem_slab_num_used_get(&mslab), 0, NULL);
|
||||
zassert_equal(k_mem_slab_num_free_get(&mslab), BLK_NUM, NULL);
|
||||
}
|
||||
|
||||
void test_mslab_kdefine(void)
|
||||
{
|
||||
assert_equal(k_mem_slab_num_used_get(&kmslab), 0, NULL);
|
||||
assert_equal(k_mem_slab_num_free_get(&kmslab), BLK_NUM, NULL);
|
||||
zassert_equal(k_mem_slab_num_used_get(&kmslab), 0, NULL);
|
||||
zassert_equal(k_mem_slab_num_free_get(&kmslab), BLK_NUM, NULL);
|
||||
}
|
||||
|
||||
void test_mslab_alloc_free_thread(void)
|
||||
|
|
|
@ -43,14 +43,14 @@ void tmslab_alloc_wait_timeout(void *p1, void *p2, void *p3)
|
|||
{
|
||||
void *block;
|
||||
|
||||
assert_true(k_mem_slab_alloc(&mslab1, &block, TIMEOUT) == -EAGAIN,
|
||||
zassert_true(k_mem_slab_alloc(&mslab1, &block, TIMEOUT) == -EAGAIN,
|
||||
NULL);
|
||||
k_sem_give(&sync_sema);
|
||||
}
|
||||
|
||||
void tmslab_alloc_wait_ok(void *p1, void *p2, void *p3)
|
||||
{
|
||||
assert_true(k_mem_slab_alloc(&mslab1, &block_ok, TIMEOUT) == 0, NULL);
|
||||
zassert_true(k_mem_slab_alloc(&mslab1, &block_ok, TIMEOUT) == 0, NULL);
|
||||
k_sem_give(&sync_sema);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ void test_mslab_alloc_wait_prio(void)
|
|||
k_sem_init(&sync_sema, 0, THREAD_NUM);
|
||||
/*allocated up all blocks*/
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
assert_equal(k_mem_slab_alloc(&mslab1, &block[i], K_NO_WAIT),
|
||||
zassert_equal(k_mem_slab_alloc(&mslab1, &block[i], K_NO_WAIT),
|
||||
0, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ static void put_msgq(struct k_msgq *pmsgq)
|
|||
|
||||
for (int i = 0; i < MSGQ_LEN; i++) {
|
||||
ret = k_msgq_put(pmsgq, (void *)&data[i], K_NO_WAIT);
|
||||
assert_false(ret, NULL);
|
||||
zassert_false(ret, NULL);
|
||||
/**TESTPOINT: msgq free get*/
|
||||
assert_equal(k_msgq_num_free_get(pmsgq), MSGQ_LEN - 1 - i, NULL);
|
||||
zassert_equal(k_msgq_num_free_get(pmsgq), MSGQ_LEN - 1 - i, NULL);
|
||||
/**TESTPOINT: msgq used get*/
|
||||
assert_equal(k_msgq_num_used_get(pmsgq), i + 1, NULL);
|
||||
zassert_equal(k_msgq_num_used_get(pmsgq), i + 1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,20 +43,20 @@ static void get_msgq(struct k_msgq *pmsgq)
|
|||
|
||||
for (int i = 0; i < MSGQ_LEN; i++) {
|
||||
ret = k_msgq_get(pmsgq, &rx_data, K_FOREVER);
|
||||
assert_false(ret, NULL);
|
||||
assert_equal(rx_data, data[i], NULL);
|
||||
zassert_false(ret, NULL);
|
||||
zassert_equal(rx_data, data[i], NULL);
|
||||
/**TESTPOINT: msgq free get*/
|
||||
assert_equal(k_msgq_num_free_get(pmsgq), i + 1, NULL);
|
||||
zassert_equal(k_msgq_num_free_get(pmsgq), i + 1, NULL);
|
||||
/**TESTPOINT: msgq used get*/
|
||||
assert_equal(k_msgq_num_used_get(pmsgq), MSGQ_LEN - 1 - i, NULL);
|
||||
zassert_equal(k_msgq_num_used_get(pmsgq), MSGQ_LEN - 1 - i, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void purge_msgq(struct k_msgq *pmsgq)
|
||||
{
|
||||
k_msgq_purge(pmsgq);
|
||||
assert_equal(k_msgq_num_free_get(pmsgq), MSGQ_LEN, NULL);
|
||||
assert_equal(k_msgq_num_used_get(pmsgq), 0, NULL);
|
||||
zassert_equal(k_msgq_num_free_get(pmsgq), MSGQ_LEN, NULL);
|
||||
zassert_equal(k_msgq_num_used_get(pmsgq), 0, NULL);
|
||||
}
|
||||
|
||||
static void tIsr_entry(void *p)
|
||||
|
|
|
@ -27,15 +27,15 @@ void test_msgq_put_fail(void *p1, void *p2, void *p3)
|
|||
|
||||
int ret = k_msgq_put(&msgq, (void *)&data[0], K_NO_WAIT);
|
||||
|
||||
assert_false(ret, NULL);
|
||||
zassert_false(ret, NULL);
|
||||
ret = k_msgq_put(&msgq, (void *)&data[0], K_NO_WAIT);
|
||||
assert_false(ret, NULL);
|
||||
zassert_false(ret, NULL);
|
||||
/**TESTPOINT: msgq put returns -ENOMSG*/
|
||||
ret = k_msgq_put(&msgq, (void *)&data[1], K_NO_WAIT);
|
||||
assert_equal(ret, -ENOMSG, NULL);
|
||||
zassert_equal(ret, -ENOMSG, NULL);
|
||||
/**TESTPOINT: msgq put returns -EAGAIN*/
|
||||
ret = k_msgq_put(&msgq, (void *)&data[0], TIMEOUT);
|
||||
assert_equal(ret, -EAGAIN, NULL);
|
||||
zassert_equal(ret, -EAGAIN, NULL);
|
||||
|
||||
k_msgq_purge(&msgq);
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ void test_msgq_get_fail(void *p1, void *p2, void *p3)
|
|||
/**TESTPOINT: msgq get returns -ENOMSG*/
|
||||
int ret = k_msgq_get(&msgq, &rx_data, K_NO_WAIT);
|
||||
|
||||
assert_equal(ret, -ENOMSG, NULL);
|
||||
zassert_equal(ret, -ENOMSG, NULL);
|
||||
/**TESTPOINT: msgq get returns -EAGAIN*/
|
||||
ret = k_msgq_get(&msgq, &rx_data, TIMEOUT);
|
||||
assert_equal(ret, -EAGAIN, NULL);
|
||||
zassert_equal(ret, -EAGAIN, NULL);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ static void tThread_entry(void *p1, void *p2, void *p3)
|
|||
{
|
||||
int ret = k_msgq_put((struct k_msgq *)p1, (void *)&data[0], TIMEOUT);
|
||||
|
||||
assert_equal(ret, -ENOMSG, NULL);
|
||||
zassert_equal(ret, -ENOMSG, NULL);
|
||||
}
|
||||
|
||||
/*test cases*/
|
||||
|
@ -37,7 +37,7 @@ void test_msgq_purge_when_put(void)
|
|||
/*fill the queue to full*/
|
||||
for (int i = 0; i < MSGQ_LEN; i++) {
|
||||
ret = k_msgq_put(&msgq, (void *)&data[i], K_NO_WAIT);
|
||||
assert_equal(ret, 0, NULL);
|
||||
zassert_equal(ret, 0, NULL);
|
||||
}
|
||||
/*create another thread waiting to put msg*/
|
||||
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
|
||||
|
@ -52,6 +52,6 @@ void test_msgq_purge_when_put(void)
|
|||
/*verify msg put after purge*/
|
||||
for (int i = 0; i < MSGQ_LEN; i++) {
|
||||
ret = k_msgq_put(&msgq, (void *)&data[i], K_NO_WAIT);
|
||||
assert_equal(ret, 0, NULL);
|
||||
zassert_equal(ret, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,26 +30,26 @@ static char __noinit __stack tstack[STACK_SIZE];
|
|||
|
||||
static void tThread_entry_lock_forever(void *p1, void *p2, void *p3)
|
||||
{
|
||||
assert_false(k_mutex_lock((struct k_mutex *)p1, K_FOREVER) == 0,
|
||||
zassert_false(k_mutex_lock((struct k_mutex *)p1, K_FOREVER) == 0,
|
||||
"access locked resource from spawn thread");
|
||||
/* should not hit here */
|
||||
}
|
||||
|
||||
static void tThread_entry_lock_no_wait(void *p1, void *p2, void *p3)
|
||||
{
|
||||
assert_true(k_mutex_lock((struct k_mutex *)p1, K_NO_WAIT) != 0, NULL);
|
||||
zassert_true(k_mutex_lock((struct k_mutex *)p1, K_NO_WAIT) != 0, NULL);
|
||||
TC_PRINT("bypass locked resource from spawn thread\n");
|
||||
}
|
||||
|
||||
static void tThread_entry_lock_timeout_fail(void *p1, void *p2, void *p3)
|
||||
{
|
||||
assert_true(k_mutex_lock((struct k_mutex *)p1, TIMEOUT - 100) != 0, NULL);
|
||||
zassert_true(k_mutex_lock((struct k_mutex *)p1, TIMEOUT - 100) != 0, NULL);
|
||||
TC_PRINT("bypass locked resource from spawn thread\n");
|
||||
}
|
||||
|
||||
static void tThread_entry_lock_timeout_pass(void *p1, void *p2, void *p3)
|
||||
{
|
||||
assert_true(k_mutex_lock((struct k_mutex *)p1, TIMEOUT + 100) == 0, NULL);
|
||||
zassert_true(k_mutex_lock((struct k_mutex *)p1, TIMEOUT + 100) == 0, NULL);
|
||||
TC_PRINT("access resource from spawn thread\n");
|
||||
k_mutex_unlock((struct k_mutex *)p1);
|
||||
}
|
||||
|
@ -94,13 +94,13 @@ static void tmutex_test_lock_timeout(struct k_mutex *pmutex,
|
|||
static void tmutex_test_lock_unlock(struct k_mutex *pmutex)
|
||||
{
|
||||
k_mutex_init(pmutex);
|
||||
assert_true(k_mutex_lock(pmutex, K_FOREVER) == 0,
|
||||
zassert_true(k_mutex_lock(pmutex, K_FOREVER) == 0,
|
||||
"fail to lock K_FOREVER");
|
||||
k_mutex_unlock(pmutex);
|
||||
assert_true(k_mutex_lock(pmutex, K_NO_WAIT) == 0,
|
||||
zassert_true(k_mutex_lock(pmutex, K_NO_WAIT) == 0,
|
||||
"fail to lock K_NO_WAIT");
|
||||
k_mutex_unlock(pmutex);
|
||||
assert_true(k_mutex_lock(pmutex, TIMEOUT) == 0,
|
||||
zassert_true(k_mutex_lock(pmutex, TIMEOUT) == 0,
|
||||
"fail to lock TIMEOUT");
|
||||
k_mutex_unlock(pmutex);
|
||||
}
|
||||
|
|
|
@ -40,9 +40,9 @@ static void tpipe_put(struct k_pipe *ppipe)
|
|||
/**TESTPOINT: pipe put*/
|
||||
to_wt = (PIPE_LEN - i) >= BYTES_TO_WRITE ?
|
||||
BYTES_TO_WRITE : (PIPE_LEN - i);
|
||||
assert_false(k_pipe_put(ppipe, &data[i], to_wt,
|
||||
zassert_false(k_pipe_put(ppipe, &data[i], to_wt,
|
||||
&wt_byte, 1, K_NO_WAIT), NULL);
|
||||
assert_true(wt_byte == to_wt || wt_byte == 1, NULL);
|
||||
zassert_true(wt_byte == to_wt || wt_byte == 1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ static void tpipe_block_put(struct k_pipe *ppipe, struct k_sem *sema)
|
|||
|
||||
for (int i = 0; i < PIPE_LEN; i += BYTES_TO_WRITE) {
|
||||
/**TESTPOINT: pipe block put*/
|
||||
assert_equal(k_mem_pool_alloc(&mpool, &block, BYTES_TO_WRITE,
|
||||
zassert_equal(k_mem_pool_alloc(&mpool, &block, BYTES_TO_WRITE,
|
||||
K_NO_WAIT), 0, NULL);
|
||||
memcpy(block.data, &data[i], BYTES_TO_WRITE);
|
||||
k_pipe_block_put(ppipe, &block, BYTES_TO_WRITE, sema);
|
||||
|
@ -73,12 +73,12 @@ static void tpipe_get(struct k_pipe *ppipe)
|
|||
/**TESTPOINT: pipe get*/
|
||||
to_rd = (PIPE_LEN - i) >= BYTES_TO_READ ?
|
||||
BYTES_TO_READ : (PIPE_LEN - i);
|
||||
assert_false(k_pipe_get(ppipe, &rx_data[i], to_rd,
|
||||
zassert_false(k_pipe_get(ppipe, &rx_data[i], to_rd,
|
||||
&rd_byte, 1, K_FOREVER), NULL);
|
||||
assert_true(rd_byte == to_rd || rd_byte == 1, NULL);
|
||||
zassert_true(rd_byte == to_rd || rd_byte == 1, NULL);
|
||||
}
|
||||
for (int i = 0; i < PIPE_LEN; i++) {
|
||||
assert_equal(rx_data[i], data[i], NULL);
|
||||
zassert_equal(rx_data[i], data[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,16 +29,16 @@ void test_pipe_put_fail(void *p1, void *p2, void *p3)
|
|||
size_t wt_byte = 0;
|
||||
|
||||
k_pipe_init(&pipe, data, PIPE_LEN);
|
||||
assert_false(k_pipe_put(&pipe, data, PIPE_LEN, &wt_byte,
|
||||
zassert_false(k_pipe_put(&pipe, data, PIPE_LEN, &wt_byte,
|
||||
1, K_FOREVER), NULL);
|
||||
/**TESTPOINT: pipe put returns -EIO*/
|
||||
assert_equal(k_pipe_put(&pipe, data, PIPE_LEN, &wt_byte,
|
||||
zassert_equal(k_pipe_put(&pipe, data, PIPE_LEN, &wt_byte,
|
||||
1, K_NO_WAIT), -EIO, NULL);
|
||||
assert_false(wt_byte, NULL);
|
||||
zassert_false(wt_byte, NULL);
|
||||
/**TESTPOINT: pipe put returns -EAGAIN*/
|
||||
assert_equal(k_pipe_put(&pipe, data, PIPE_LEN, &wt_byte,
|
||||
zassert_equal(k_pipe_put(&pipe, data, PIPE_LEN, &wt_byte,
|
||||
1, TIMEOUT), -EAGAIN, NULL);
|
||||
assert_true(wt_byte < 1, NULL);
|
||||
zassert_true(wt_byte < 1, NULL);
|
||||
}
|
||||
|
||||
void test_pipe_get_fail(void *p1, void *p2, void *p3)
|
||||
|
@ -49,11 +49,11 @@ void test_pipe_get_fail(void *p1, void *p2, void *p3)
|
|||
|
||||
k_pipe_init(&pipe, data, PIPE_LEN);
|
||||
/**TESTPOINT: pipe put returns -EIO*/
|
||||
assert_equal(k_pipe_get(&pipe, rx_data, PIPE_LEN, &rd_byte, 1,
|
||||
zassert_equal(k_pipe_get(&pipe, rx_data, PIPE_LEN, &rd_byte, 1,
|
||||
K_NO_WAIT), -EIO, NULL);
|
||||
assert_false(rd_byte, NULL);
|
||||
zassert_false(rd_byte, NULL);
|
||||
/**TESTPOINT: pipe put returns -EAGAIN*/
|
||||
assert_equal(k_pipe_get(&pipe, rx_data, PIPE_LEN, &rd_byte, 1,
|
||||
zassert_equal(k_pipe_get(&pipe, rx_data, PIPE_LEN, &rd_byte, 1,
|
||||
TIMEOUT), -EAGAIN, NULL);
|
||||
assert_true(rd_byte < 1, NULL);
|
||||
zassert_true(rd_byte < 1, NULL);
|
||||
}
|
||||
|
|
|
@ -57,20 +57,20 @@ void test_poll_no_wait(void)
|
|||
k_fifo_put(&no_wait_fifo, &msg);
|
||||
k_poll_signal(&no_wait_signal, SIGNAL_RESULT);
|
||||
|
||||
assert_equal(k_poll(events, ARRAY_SIZE(events), 0), 0, "");
|
||||
zassert_equal(k_poll(events, ARRAY_SIZE(events), 0), 0, "");
|
||||
|
||||
assert_equal(events[0].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
assert_equal(k_sem_take(&no_wait_sem, 0), 0, "");
|
||||
zassert_equal(events[0].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
zassert_equal(k_sem_take(&no_wait_sem, 0), 0, "");
|
||||
|
||||
assert_equal(events[1].state, K_POLL_STATE_FIFO_DATA_AVAILABLE, "");
|
||||
zassert_equal(events[1].state, K_POLL_STATE_FIFO_DATA_AVAILABLE, "");
|
||||
msg_ptr = k_fifo_get(&no_wait_fifo, 0);
|
||||
assert_not_null(msg_ptr, "");
|
||||
assert_equal(msg_ptr, &msg, "");
|
||||
assert_equal(msg_ptr->msg, FIFO_MSG_VALUE, "");
|
||||
zassert_not_null(msg_ptr, "");
|
||||
zassert_equal(msg_ptr, &msg, "");
|
||||
zassert_equal(msg_ptr->msg, FIFO_MSG_VALUE, "");
|
||||
|
||||
assert_equal(events[2].state, K_POLL_STATE_SIGNALED, "");
|
||||
assert_equal(no_wait_signal.signaled, 1, "");
|
||||
assert_equal(no_wait_signal.result, SIGNAL_RESULT, "");
|
||||
zassert_equal(events[2].state, K_POLL_STATE_SIGNALED, "");
|
||||
zassert_equal(no_wait_signal.signaled, 1, "");
|
||||
zassert_equal(no_wait_signal.result, SIGNAL_RESULT, "");
|
||||
|
||||
/* verify events are not ready anymore (user has to clear them first) */
|
||||
events[0].state = K_POLL_STATE_NOT_READY;
|
||||
|
@ -78,13 +78,13 @@ void test_poll_no_wait(void)
|
|||
events[2].state = K_POLL_STATE_NOT_READY;
|
||||
no_wait_signal.signaled = 0;
|
||||
|
||||
assert_equal(k_poll(events, ARRAY_SIZE(events), 0), -EAGAIN, "");
|
||||
assert_equal(events[0].state, K_POLL_STATE_NOT_READY, "");
|
||||
assert_equal(events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
assert_equal(events[2].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(k_poll(events, ARRAY_SIZE(events), 0), -EAGAIN, "");
|
||||
zassert_equal(events[0].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(events[2].state, K_POLL_STATE_NOT_READY, "");
|
||||
|
||||
assert_not_equal(k_sem_take(&no_wait_sem, 0), 0, "");
|
||||
assert_is_null(k_fifo_get(&no_wait_fifo, 0), "");
|
||||
zassert_not_equal(k_sem_take(&no_wait_sem, 0), 0, "");
|
||||
zassert_is_null(k_fifo_get(&no_wait_fifo, 0), "");
|
||||
}
|
||||
|
||||
/* verify k_poll() that has to wait */
|
||||
|
@ -150,24 +150,24 @@ void test_poll_wait(void)
|
|||
|
||||
k_thread_priority_set(k_current_get(), old_prio);
|
||||
|
||||
assert_equal(rc, 0, "");
|
||||
zassert_equal(rc, 0, "");
|
||||
|
||||
assert_equal(wait_events[0].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
assert_equal(k_sem_take(&wait_sem, 0), 0, "");
|
||||
assert_equal(wait_events[0].tag, TAG_0, "");
|
||||
zassert_equal(wait_events[0].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
zassert_equal(k_sem_take(&wait_sem, 0), 0, "");
|
||||
zassert_equal(wait_events[0].tag, TAG_0, "");
|
||||
|
||||
assert_equal(wait_events[1].state,
|
||||
zassert_equal(wait_events[1].state,
|
||||
K_POLL_STATE_FIFO_DATA_AVAILABLE, "");
|
||||
msg_ptr = k_fifo_get(&wait_fifo, 0);
|
||||
assert_not_null(msg_ptr, "");
|
||||
assert_equal(msg_ptr, &wait_msg, "");
|
||||
assert_equal(msg_ptr->msg, FIFO_MSG_VALUE, "");
|
||||
assert_equal(wait_events[1].tag, TAG_1, "");
|
||||
zassert_not_null(msg_ptr, "");
|
||||
zassert_equal(msg_ptr, &wait_msg, "");
|
||||
zassert_equal(msg_ptr->msg, FIFO_MSG_VALUE, "");
|
||||
zassert_equal(wait_events[1].tag, TAG_1, "");
|
||||
|
||||
assert_equal(wait_events[2].state, K_POLL_STATE_SIGNALED, "");
|
||||
assert_equal(wait_signal.signaled, 1, "");
|
||||
assert_equal(wait_signal.result, SIGNAL_RESULT, "");
|
||||
assert_equal(wait_events[2].tag, TAG_2, "");
|
||||
zassert_equal(wait_events[2].state, K_POLL_STATE_SIGNALED, "");
|
||||
zassert_equal(wait_signal.signaled, 1, "");
|
||||
zassert_equal(wait_signal.result, SIGNAL_RESULT, "");
|
||||
zassert_equal(wait_events[2].tag, TAG_2, "");
|
||||
|
||||
/* verify events are not ready anymore */
|
||||
wait_events[0].state = K_POLL_STATE_NOT_READY;
|
||||
|
@ -175,17 +175,17 @@ void test_poll_wait(void)
|
|||
wait_events[2].state = K_POLL_STATE_NOT_READY;
|
||||
wait_signal.signaled = 0;
|
||||
|
||||
assert_equal(k_poll(wait_events, ARRAY_SIZE(wait_events),
|
||||
zassert_equal(k_poll(wait_events, ARRAY_SIZE(wait_events),
|
||||
K_SECONDS(1)), -EAGAIN, "");
|
||||
|
||||
assert_equal(wait_events[0].state, K_POLL_STATE_NOT_READY, "");
|
||||
assert_equal(wait_events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
assert_equal(wait_events[2].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(wait_events[0].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(wait_events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(wait_events[2].state, K_POLL_STATE_NOT_READY, "");
|
||||
|
||||
/* tags should not have been touched */
|
||||
assert_equal(wait_events[0].tag, TAG_0, "");
|
||||
assert_equal(wait_events[1].tag, TAG_1, "");
|
||||
assert_equal(wait_events[2].tag, TAG_2, "");
|
||||
zassert_equal(wait_events[0].tag, TAG_0, "");
|
||||
zassert_equal(wait_events[1].tag, TAG_1, "");
|
||||
zassert_equal(wait_events[2].tag, TAG_2, "");
|
||||
|
||||
/*
|
||||
* Wait for 2 out of 3 non-ready events to become ready from a higher
|
||||
|
@ -200,21 +200,21 @@ void test_poll_wait(void)
|
|||
|
||||
k_thread_priority_set(k_current_get(), old_prio);
|
||||
|
||||
assert_equal(rc, 0, "");
|
||||
zassert_equal(rc, 0, "");
|
||||
|
||||
assert_equal(wait_events[0].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
assert_equal(k_sem_take(&wait_sem, 0), 0, "");
|
||||
assert_equal(wait_events[0].tag, TAG_0, "");
|
||||
zassert_equal(wait_events[0].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
zassert_equal(k_sem_take(&wait_sem, 0), 0, "");
|
||||
zassert_equal(wait_events[0].tag, TAG_0, "");
|
||||
|
||||
assert_equal(wait_events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(wait_events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
msg_ptr = k_fifo_get(&wait_fifo, K_NO_WAIT);
|
||||
assert_is_null(msg_ptr, "");
|
||||
assert_equal(wait_events[1].tag, TAG_1, "");
|
||||
zassert_is_null(msg_ptr, "");
|
||||
zassert_equal(wait_events[1].tag, TAG_1, "");
|
||||
|
||||
assert_equal(wait_events[2].state, K_POLL_STATE_SIGNALED, "");
|
||||
assert_equal(wait_signal.signaled, 1, "");
|
||||
assert_equal(wait_signal.result, SIGNAL_RESULT, "");
|
||||
assert_equal(wait_events[2].tag, TAG_2, "");
|
||||
zassert_equal(wait_events[2].state, K_POLL_STATE_SIGNALED, "");
|
||||
zassert_equal(wait_signal.signaled, 1, "");
|
||||
zassert_equal(wait_signal.result, SIGNAL_RESULT, "");
|
||||
zassert_equal(wait_events[2].tag, TAG_2, "");
|
||||
|
||||
/*
|
||||
* Wait for each event to be ready from a lower priority thread, one at
|
||||
|
@ -232,60 +232,60 @@ void test_poll_wait(void)
|
|||
/* semaphore */
|
||||
rc = k_poll(wait_events, ARRAY_SIZE(wait_events), K_SECONDS(1));
|
||||
|
||||
assert_equal(rc, 0, "");
|
||||
zassert_equal(rc, 0, "");
|
||||
|
||||
assert_equal(wait_events[0].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
assert_equal(k_sem_take(&wait_sem, 0), 0, "");
|
||||
assert_equal(wait_events[0].tag, TAG_0, "");
|
||||
zassert_equal(wait_events[0].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
zassert_equal(k_sem_take(&wait_sem, 0), 0, "");
|
||||
zassert_equal(wait_events[0].tag, TAG_0, "");
|
||||
|
||||
assert_equal(wait_events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(wait_events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
msg_ptr = k_fifo_get(&wait_fifo, K_NO_WAIT);
|
||||
assert_is_null(msg_ptr, "");
|
||||
assert_equal(wait_events[1].tag, TAG_1, "");
|
||||
zassert_is_null(msg_ptr, "");
|
||||
zassert_equal(wait_events[1].tag, TAG_1, "");
|
||||
|
||||
assert_equal(wait_events[2].state, K_POLL_STATE_NOT_READY, "");
|
||||
assert_equal(wait_events[2].tag, TAG_2, "");
|
||||
zassert_equal(wait_events[2].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(wait_events[2].tag, TAG_2, "");
|
||||
|
||||
wait_events[0].state = K_POLL_STATE_NOT_READY;
|
||||
|
||||
/* fifo */
|
||||
rc = k_poll(wait_events, ARRAY_SIZE(wait_events), K_SECONDS(1));
|
||||
|
||||
assert_equal(rc, 0, "");
|
||||
zassert_equal(rc, 0, "");
|
||||
|
||||
assert_equal(wait_events[0].state, K_POLL_STATE_NOT_READY, "");
|
||||
assert_equal(k_sem_take(&wait_sem, 0), -EBUSY, "");
|
||||
assert_equal(wait_events[0].tag, TAG_0, "");
|
||||
zassert_equal(wait_events[0].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(k_sem_take(&wait_sem, 0), -EBUSY, "");
|
||||
zassert_equal(wait_events[0].tag, TAG_0, "");
|
||||
|
||||
assert_equal(wait_events[1].state,
|
||||
zassert_equal(wait_events[1].state,
|
||||
K_POLL_STATE_FIFO_DATA_AVAILABLE, "");
|
||||
msg_ptr = k_fifo_get(&wait_fifo, K_NO_WAIT);
|
||||
assert_not_null(msg_ptr, "");
|
||||
assert_equal(wait_events[1].tag, TAG_1, "");
|
||||
zassert_not_null(msg_ptr, "");
|
||||
zassert_equal(wait_events[1].tag, TAG_1, "");
|
||||
|
||||
assert_equal(wait_events[2].state, K_POLL_STATE_NOT_READY, "");
|
||||
assert_equal(wait_events[2].tag, TAG_2, "");
|
||||
zassert_equal(wait_events[2].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(wait_events[2].tag, TAG_2, "");
|
||||
|
||||
wait_events[1].state = K_POLL_STATE_NOT_READY;
|
||||
|
||||
/* poll signal */
|
||||
rc = k_poll(wait_events, ARRAY_SIZE(wait_events), K_SECONDS(1));
|
||||
|
||||
assert_equal(rc, 0, "");
|
||||
zassert_equal(rc, 0, "");
|
||||
|
||||
assert_equal(wait_events[0].state, K_POLL_STATE_NOT_READY, "");
|
||||
assert_equal(k_sem_take(&wait_sem, 0), -EBUSY, "");
|
||||
assert_equal(wait_events[0].tag, TAG_0, "");
|
||||
zassert_equal(wait_events[0].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(k_sem_take(&wait_sem, 0), -EBUSY, "");
|
||||
zassert_equal(wait_events[0].tag, TAG_0, "");
|
||||
|
||||
assert_equal(wait_events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
zassert_equal(wait_events[1].state, K_POLL_STATE_NOT_READY, "");
|
||||
msg_ptr = k_fifo_get(&wait_fifo, K_NO_WAIT);
|
||||
assert_is_null(msg_ptr, "");
|
||||
assert_equal(wait_events[1].tag, TAG_1, "");
|
||||
zassert_is_null(msg_ptr, "");
|
||||
zassert_equal(wait_events[1].tag, TAG_1, "");
|
||||
|
||||
assert_equal(wait_events[2].state, K_POLL_STATE_SIGNALED, "");
|
||||
assert_equal(wait_signal.signaled, 1, "");
|
||||
assert_equal(wait_signal.result, SIGNAL_RESULT, "");
|
||||
assert_equal(wait_events[2].tag, TAG_2, "");
|
||||
zassert_equal(wait_events[2].state, K_POLL_STATE_SIGNALED, "");
|
||||
zassert_equal(wait_signal.signaled, 1, "");
|
||||
zassert_equal(wait_signal.result, SIGNAL_RESULT, "");
|
||||
zassert_equal(wait_events[2].tag, TAG_2, "");
|
||||
|
||||
wait_events[2].state = K_POLL_STATE_NOT_READY;
|
||||
wait_signal.signaled = 0;
|
||||
|
@ -339,13 +339,13 @@ void test_poll_eaddrinuse(void)
|
|||
|
||||
k_thread_priority_set(k_current_get(), old_prio);
|
||||
|
||||
assert_equal(rc, -EADDRINUSE, "");
|
||||
assert_equal(events[0].state, K_POLL_STATE_EADDRINUSE, "");
|
||||
assert_equal(events[1].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
zassert_equal(rc, -EADDRINUSE, "");
|
||||
zassert_equal(events[0].state, K_POLL_STATE_EADDRINUSE, "");
|
||||
zassert_equal(events[1].state, K_POLL_STATE_SEM_AVAILABLE, "");
|
||||
|
||||
/* free hogger, ensuring it awoken from k_poll() and got the sem */
|
||||
k_sem_give(&eaddrinuse_sem);
|
||||
rc = k_sem_take(&eaddrinuse_reply, K_SECONDS(1));
|
||||
|
||||
assert_equal(rc, 0, "");
|
||||
zassert_equal(rc, 0, "");
|
||||
}
|
||||
|
|
|
@ -68,23 +68,23 @@ static void tqueue_get(struct k_queue *pqueue)
|
|||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
/**TESTPOINT: queue get*/
|
||||
rx_data = k_queue_get(pqueue, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data_p[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data_p[i], NULL);
|
||||
}
|
||||
/*get queue data from "queue_append"*/
|
||||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
/**TESTPOINT: queue get*/
|
||||
rx_data = k_queue_get(pqueue, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data[i], NULL);
|
||||
}
|
||||
/*get queue data from "queue_append_list"*/
|
||||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
rx_data = k_queue_get(pqueue, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data_l[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data_l[i], NULL);
|
||||
}
|
||||
/*get queue data from "queue_merge_slist"*/
|
||||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
rx_data = k_queue_get(pqueue, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data_sl[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data_sl[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ void test_queue_get_fail(void *p1, void *p2, void *p3)
|
|||
|
||||
k_queue_init(&queue);
|
||||
/**TESTPOINT: queue get returns NULL*/
|
||||
assert_is_null(k_queue_get(&queue, K_NO_WAIT), NULL);
|
||||
assert_is_null(k_queue_get(&queue, TIMEOUT), NULL);
|
||||
zassert_is_null(k_queue_get(&queue, K_NO_WAIT), NULL);
|
||||
zassert_is_null(k_queue_get(&queue, TIMEOUT), NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,14 +60,14 @@ static void tqueue_get(struct k_queue *pqueue)
|
|||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
/**TESTPOINT: queue get*/
|
||||
rx_data = k_queue_get(pqueue, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data_p[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data_p[i], NULL);
|
||||
}
|
||||
|
||||
/*get queue data from "queue_append"*/
|
||||
for (int i = 0; i < LIST_LEN; i++) {
|
||||
/**TESTPOINT: queue get*/
|
||||
rx_data = k_queue_get(pqueue, K_NO_WAIT);
|
||||
assert_equal(rx_data, (void *)&data[i], NULL);
|
||||
zassert_equal(rx_data, (void *)&data[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ static void tsema_thread_thread(struct k_sem *psem)
|
|||
tThread_entry, psem, NULL, NULL,
|
||||
K_PRIO_PREEMPT(0), 0, 0);
|
||||
|
||||
assert_false(k_sem_take(psem, K_FOREVER), NULL);
|
||||
zassert_false(k_sem_take(psem, K_FOREVER), NULL);
|
||||
/*clean the spawn thread avoid side effect in next TC*/
|
||||
k_thread_abort(tid);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ static void tsema_thread_isr(struct k_sem *psem)
|
|||
{
|
||||
/**TESTPOINT: thread-isr sync via sema*/
|
||||
irq_offload(tIsr_entry, psem);
|
||||
assert_false(k_sem_take(psem, K_FOREVER), NULL);
|
||||
zassert_false(k_sem_take(psem, K_FOREVER), NULL);
|
||||
}
|
||||
|
||||
/*test cases*/
|
||||
|
@ -86,30 +86,30 @@ void test_sema_reset(void)
|
|||
k_sem_init(&sema, SEM_INITIAL, SEM_LIMIT);
|
||||
k_sem_give(&sema);
|
||||
k_sem_reset(&sema);
|
||||
assert_false(k_sem_count_get(&sema), NULL);
|
||||
zassert_false(k_sem_count_get(&sema), NULL);
|
||||
/**TESTPOINT: sem take return -EBUSY*/
|
||||
assert_equal(k_sem_take(&sema, K_NO_WAIT), -EBUSY, NULL);
|
||||
zassert_equal(k_sem_take(&sema, K_NO_WAIT), -EBUSY, NULL);
|
||||
/**TESTPOINT: sem take return -EAGAIN*/
|
||||
assert_equal(k_sem_take(&sema, TIMEOUT), -EAGAIN, NULL);
|
||||
zassert_equal(k_sem_take(&sema, TIMEOUT), -EAGAIN, NULL);
|
||||
k_sem_give(&sema);
|
||||
assert_false(k_sem_take(&sema, K_FOREVER), NULL);
|
||||
zassert_false(k_sem_take(&sema, K_FOREVER), NULL);
|
||||
}
|
||||
|
||||
void test_sema_count_get(void)
|
||||
{
|
||||
k_sem_init(&sema, SEM_INITIAL, SEM_LIMIT);
|
||||
/**TESTPOINT: sem count get upon init*/
|
||||
assert_equal(k_sem_count_get(&sema), SEM_INITIAL, NULL);
|
||||
zassert_equal(k_sem_count_get(&sema), SEM_INITIAL, NULL);
|
||||
k_sem_give(&sema);
|
||||
/**TESTPOINT: sem count get after give*/
|
||||
assert_equal(k_sem_count_get(&sema), SEM_INITIAL + 1, NULL);
|
||||
zassert_equal(k_sem_count_get(&sema), SEM_INITIAL + 1, NULL);
|
||||
k_sem_take(&sema, K_FOREVER);
|
||||
/**TESTPOINT: sem count get after take*/
|
||||
for (int i = 0; i < SEM_LIMIT; i++) {
|
||||
assert_equal(k_sem_count_get(&sema), SEM_INITIAL + i, NULL);
|
||||
zassert_equal(k_sem_count_get(&sema), SEM_INITIAL + i, NULL);
|
||||
k_sem_give(&sema);
|
||||
}
|
||||
/**TESTPOINT: sem give above limit*/
|
||||
k_sem_give(&sema);
|
||||
assert_equal(k_sem_count_get(&sema), SEM_LIMIT, NULL);
|
||||
zassert_equal(k_sem_count_get(&sema), SEM_LIMIT, NULL);
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ static void tstack_pop(struct k_stack *pstack)
|
|||
|
||||
for (int i = STACK_LEN - 1; i >= 0; i--) {
|
||||
/**TESTPOINT: stack pop*/
|
||||
assert_false(k_stack_pop(pstack, &rx_data, K_NO_WAIT), NULL);
|
||||
assert_equal(rx_data, data[i], NULL);
|
||||
zassert_false(k_stack_pop(pstack, &rx_data, K_NO_WAIT), NULL);
|
||||
zassert_equal(rx_data, data[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void test_stack_pop_fail(void *p1, void *p2, void *p3)
|
|||
|
||||
k_stack_init(&stack, data, STACK_LEN);
|
||||
/**TESTPOINT: stack pop returns -EBUSY*/
|
||||
assert_equal(k_stack_pop(&stack, &rx_data, K_NO_WAIT), -EBUSY, NULL);
|
||||
zassert_equal(k_stack_pop(&stack, &rx_data, K_NO_WAIT), -EBUSY, NULL);
|
||||
/**TESTPOINT: stack pop returns -EAGAIN*/
|
||||
assert_equal(k_stack_pop(&stack, &rx_data, TIMEOUT), -EAGAIN, NULL);
|
||||
zassert_equal(k_stack_pop(&stack, &rx_data, TIMEOUT), -EAGAIN, NULL);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ static int main_prio;
|
|||
int _sys_soc_suspend(int32_t ticks)
|
||||
{
|
||||
/** TESTPOINT: check idle thread priority */
|
||||
assert_true(k_thread_priority_get(k_current_get()) ==
|
||||
zassert_true(k_thread_priority_get(k_current_get()) ==
|
||||
K_IDLE_PRIO, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ void test_systhreads_setup(void)
|
|||
|
||||
void test_systhreads_main(void)
|
||||
{
|
||||
assert_true(main_prio == CONFIG_MAIN_THREAD_PRIORITY, NULL);
|
||||
zassert_true(main_prio == CONFIG_MAIN_THREAD_PRIORITY, NULL);
|
||||
}
|
||||
|
||||
void test_systhreads_idle(void)
|
||||
{
|
||||
k_sleep(100);
|
||||
/** TESTPOINT: check working thread priority should */
|
||||
assert_true(k_thread_priority_get(k_current_get()) <
|
||||
zassert_true(k_thread_priority_get(k_current_get()) <
|
||||
K_IDLE_PRIO, NULL);
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ static void customdata_entry(void *p1, void *p2, void *p3)
|
|||
{
|
||||
uint32_t data = 1;
|
||||
|
||||
assert_is_null(k_thread_custom_data_get(), NULL);
|
||||
zassert_is_null(k_thread_custom_data_get(), NULL);
|
||||
while (1) {
|
||||
k_thread_custom_data_set((void *)data);
|
||||
/* relinguish cpu for a while */
|
||||
k_sleep(50);
|
||||
/** TESTPOINT: custom data comparison */
|
||||
assert_equal(data, (uint32_t)k_thread_custom_data_get(), NULL);
|
||||
zassert_equal(data, (uint32_t)k_thread_custom_data_get(), NULL);
|
||||
data++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ static void thread_entry_abort(void *p1, void *p2, void *p3)
|
|||
k_thread_abort(k_current_get());
|
||||
/*unreachable*/
|
||||
execute_flag = 2;
|
||||
assert_true(1 == 0, NULL);
|
||||
zassert_true(1 == 0, NULL);
|
||||
}
|
||||
|
||||
/*test cases*/
|
||||
|
@ -48,7 +48,7 @@ void test_threads_cancel_undelayed(void)
|
|||
/**TESTPOINT: check cancel retcode when thread is not delayed*/
|
||||
int cancel_ret = k_thread_cancel(tid);
|
||||
|
||||
assert_equal(cancel_ret, -EINVAL, NULL);
|
||||
zassert_equal(cancel_ret, -EINVAL, NULL);
|
||||
k_thread_abort(tid);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ void test_threads_cancel_started(void)
|
|||
/**TESTPOINT: check cancel retcode when thread is started*/
|
||||
int cancel_ret = k_thread_cancel(tid);
|
||||
|
||||
assert_equal(cancel_ret, -EINVAL, NULL);
|
||||
zassert_equal(cancel_ret, -EINVAL, NULL);
|
||||
k_thread_abort(tid);
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ void test_threads_cancel_delayed(void)
|
|||
/**TESTPOINT: check cancel retcode when thread is started*/
|
||||
int cancel_ret = k_thread_cancel(tid);
|
||||
|
||||
assert_equal(cancel_ret, 0, NULL);
|
||||
zassert_equal(cancel_ret, 0, NULL);
|
||||
k_thread_abort(tid);
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ void test_threads_abort_self(void)
|
|||
0, 0, 0);
|
||||
k_sleep(100);
|
||||
/**TESTPOINT: spawned thread executed but abort itself*/
|
||||
assert_true(execute_flag == 1, NULL);
|
||||
zassert_true(execute_flag == 1, NULL);
|
||||
k_thread_abort(tid);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ void test_threads_abort_others(void)
|
|||
k_thread_abort(tid);
|
||||
k_sleep(100);
|
||||
/**TESTPOINT: check not-started thread is aborted*/
|
||||
assert_true(execute_flag == 0, NULL);
|
||||
zassert_true(execute_flag == 0, NULL);
|
||||
|
||||
tid = k_thread_spawn(tstack, STACK_SIZE,
|
||||
thread_entry, NULL, NULL, NULL,
|
||||
|
@ -120,7 +120,7 @@ void test_threads_abort_others(void)
|
|||
k_sleep(50);
|
||||
k_thread_abort(tid);
|
||||
/**TESTPOINT: check running thread is aborted*/
|
||||
assert_true(execute_flag == 1, NULL);
|
||||
zassert_true(execute_flag == 1, NULL);
|
||||
k_sleep(1000);
|
||||
assert_true(execute_flag == 1, NULL);
|
||||
zassert_true(execute_flag == 1, NULL);
|
||||
}
|
||||
|
|
|
@ -25,15 +25,15 @@ static int spawn_prio;
|
|||
static void thread_entry_params(void *p1, void *p2, void *p3)
|
||||
{
|
||||
/* checkpoint: check parameter 1, 2, 3 */
|
||||
assert_equal((char *)p1, tp1, NULL);
|
||||
assert_equal((int)p2, tp2, NULL);
|
||||
assert_equal((struct k_sema *)p3, tp3, NULL);
|
||||
zassert_equal((char *)p1, tp1, NULL);
|
||||
zassert_equal((int)p2, tp2, NULL);
|
||||
zassert_equal((struct k_sema *)p3, tp3, NULL);
|
||||
}
|
||||
|
||||
static void thread_entry_priority(void *p1, void *p2, void *p3)
|
||||
{
|
||||
/* checkpoint: check priority */
|
||||
assert_equal(k_thread_priority_get(k_current_get()), spawn_prio, NULL);
|
||||
zassert_equal(k_thread_priority_get(k_current_get()), spawn_prio, NULL);
|
||||
}
|
||||
|
||||
static void thread_entry_delay(void *p1, void *p2, void *p3)
|
||||
|
@ -73,9 +73,9 @@ void test_threads_spawn_delay(void)
|
|||
/* 100 < 120 ensure spawn thread not start */
|
||||
k_sleep(100);
|
||||
/* checkpoint: check spawn thread not execute */
|
||||
assert_true(tp2 == 10, NULL);
|
||||
zassert_true(tp2 == 10, NULL);
|
||||
/* checkpoint: check spawn thread executed */
|
||||
k_sleep(100);
|
||||
assert_true(tp2 == 100, NULL);
|
||||
zassert_true(tp2 == 100, NULL);
|
||||
k_thread_abort(tid);
|
||||
}
|
||||
|
|
|
@ -39,11 +39,11 @@ static void threads_suspend_resume(int prio)
|
|||
k_thread_suspend(tid);
|
||||
k_sleep(100);
|
||||
/* checkpoint: spawned thread shouldn't be executed after suspend */
|
||||
assert_false(last_prio == spawn_prio, NULL);
|
||||
zassert_false(last_prio == spawn_prio, NULL);
|
||||
k_thread_resume(tid);
|
||||
k_sleep(100);
|
||||
/* checkpoint: spawned thread should be executed after resume */
|
||||
assert_true(last_prio == spawn_prio, NULL);
|
||||
zassert_true(last_prio == spawn_prio, NULL);
|
||||
|
||||
k_thread_abort(tid);
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ static void thread_entry(void *p1, void *p2, void *p3)
|
|||
if (t_create) {
|
||||
uint64_t t_delay = k_uptime_get() - t_create;
|
||||
/**TESTPOINT: check delay start*/
|
||||
assert_true(t_delay >= expected.init_delay,
|
||||
zassert_true(t_delay >= expected.init_delay,
|
||||
"k_thread_spawn delay start failed\n");
|
||||
}
|
||||
|
||||
|
@ -79,10 +79,10 @@ static void thread_entry(void *p1, void *p2, void *p3)
|
|||
|
||||
k_tid_t tid = k_current_get();
|
||||
/**TESTPOINT: check priority and params*/
|
||||
assert_equal(k_thread_priority_get(tid), expected.init_prio, NULL);
|
||||
assert_equal(p1, expected.init_p1, NULL);
|
||||
assert_equal(p2, expected.init_p2, NULL);
|
||||
assert_equal(p3, expected.init_p3, NULL);
|
||||
zassert_equal(k_thread_priority_get(tid), expected.init_prio, NULL);
|
||||
zassert_equal(p1, expected.init_p1, NULL);
|
||||
zassert_equal(p2, expected.init_p2, NULL);
|
||||
zassert_equal(p3, expected.init_p3, NULL);
|
||||
/*option, stack size, not checked, no public API to get these values*/
|
||||
|
||||
k_sem_give(&end_sema);
|
||||
|
@ -145,7 +145,7 @@ void test_kinit_preempt_thread(void)
|
|||
INIT_PREEMPT_PRIO, INIT_PREEMPT_OPTION, INIT_PREEMPT_DELAY);
|
||||
/*record time stamp of thread creation*/
|
||||
t_create = k_uptime_get();
|
||||
assert_not_null(pthread, "thread spawn failed\n");
|
||||
zassert_not_null(pthread, "thread spawn failed\n");
|
||||
|
||||
expected.init_p1 = INIT_PREEMPT_P1;
|
||||
expected.init_p2 = INIT_PREEMPT_P2;
|
||||
|
@ -173,7 +173,7 @@ void test_kinit_coop_thread(void)
|
|||
INIT_COOP_PRIO, INIT_COOP_OPTION, INIT_COOP_DELAY);
|
||||
/*record time stamp of thread creation*/
|
||||
t_create = k_uptime_get();
|
||||
assert_not_null(pthread, "thread spawn failed\n");
|
||||
zassert_not_null(pthread, "thread spawn failed\n");
|
||||
|
||||
expected.init_p1 = INIT_COOP_P1;
|
||||
expected.init_p2 = INIT_COOP_P2;
|
||||
|
|
|
@ -27,38 +27,38 @@ static struct k_sem end_sema;
|
|||
static void tIsr(void *data)
|
||||
{
|
||||
/** TESTPOINT: The code is running at ISR.*/
|
||||
assert_false(k_is_preempt_thread(), NULL);
|
||||
zassert_false(k_is_preempt_thread(), NULL);
|
||||
}
|
||||
|
||||
static void tpreempt_ctx(void *p1, void *p2, void *p3)
|
||||
{
|
||||
/** TESTPOINT: The thread's priority is in the preemptible range.*/
|
||||
assert_true(k_is_preempt_thread(), NULL);
|
||||
zassert_true(k_is_preempt_thread(), NULL);
|
||||
k_sched_lock();
|
||||
/** TESTPOINT: The thread has locked the scheduler.*/
|
||||
assert_false(k_is_preempt_thread(), NULL);
|
||||
zassert_false(k_is_preempt_thread(), NULL);
|
||||
k_sched_unlock();
|
||||
/** TESTPOINT: The thread has not locked the scheduler.*/
|
||||
assert_true(k_is_preempt_thread(), NULL);
|
||||
zassert_true(k_is_preempt_thread(), NULL);
|
||||
k_thread_priority_set(k_current_get(), K_PRIO_COOP(1));
|
||||
/** TESTPOINT: The thread's priority is in the cooperative range.*/
|
||||
assert_false(k_is_preempt_thread(), NULL);
|
||||
zassert_false(k_is_preempt_thread(), NULL);
|
||||
k_sem_give(&end_sema);
|
||||
}
|
||||
|
||||
static void tcoop_ctx(void *p1, void *p2, void *p3)
|
||||
{
|
||||
/** TESTPOINT: The thread's priority is in the cooperative range.*/
|
||||
assert_false(k_is_preempt_thread(), NULL);
|
||||
zassert_false(k_is_preempt_thread(), NULL);
|
||||
k_thread_priority_set(k_current_get(), K_PRIO_PREEMPT(1));
|
||||
/** TESTPOINT: The thread's priority is in the preemptible range.*/
|
||||
assert_true(k_is_preempt_thread(), NULL);
|
||||
zassert_true(k_is_preempt_thread(), NULL);
|
||||
k_sched_lock();
|
||||
/** TESTPOINT: The thread has locked the scheduler.*/
|
||||
assert_false(k_is_preempt_thread(), NULL);
|
||||
zassert_false(k_is_preempt_thread(), NULL);
|
||||
k_sched_unlock();
|
||||
/** TESTPOINT: The thread has not locked the scheduler.*/
|
||||
assert_true(k_is_preempt_thread(), NULL);
|
||||
zassert_true(k_is_preempt_thread(), NULL);
|
||||
k_sem_give(&end_sema);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,10 +38,10 @@ void test_priority_cooperative(void)
|
|||
thread_entry, NULL, NULL, NULL,
|
||||
spawn_prio, 0, 0);
|
||||
/* checkpoint: current thread shouldn't preempted by higher thread */
|
||||
assert_true(last_prio == k_thread_priority_get(k_current_get()), NULL);
|
||||
zassert_true(last_prio == k_thread_priority_get(k_current_get()), NULL);
|
||||
k_sleep(100);
|
||||
/* checkpoint: spawned thread get executed */
|
||||
assert_true(last_prio == spawn_prio, NULL);
|
||||
zassert_true(last_prio == spawn_prio, NULL);
|
||||
k_thread_abort(tid);
|
||||
|
||||
/* restore environment */
|
||||
|
@ -62,7 +62,7 @@ void test_priority_preemptible(void)
|
|||
thread_entry, NULL, NULL, NULL,
|
||||
spawn_prio, 0, 0);
|
||||
/* checkpoint: thread is preempted by higher thread */
|
||||
assert_true(last_prio == spawn_prio, NULL);
|
||||
zassert_true(last_prio == spawn_prio, NULL);
|
||||
|
||||
k_sleep(100);
|
||||
k_thread_abort(tid);
|
||||
|
@ -72,7 +72,7 @@ void test_priority_preemptible(void)
|
|||
thread_entry, NULL, NULL, NULL,
|
||||
spawn_prio, 0, 0);
|
||||
/* checkpoint: thread is not preempted by lower thread */
|
||||
assert_false(last_prio == spawn_prio, NULL);
|
||||
zassert_false(last_prio == spawn_prio, NULL);
|
||||
k_thread_abort(tid);
|
||||
|
||||
/* restore environment */
|
||||
|
|
|
@ -79,10 +79,10 @@ void test_yield_cooperative(void)
|
|||
spawn_threads(0);
|
||||
/* checkpoint: only higher priority thread get executed when yield */
|
||||
k_yield();
|
||||
assert_true(tdata[0].executed == 1, NULL);
|
||||
assert_true(tdata[1].executed == 1, NULL);
|
||||
zassert_true(tdata[0].executed == 1, NULL);
|
||||
zassert_true(tdata[1].executed == 1, NULL);
|
||||
for (int i = 2; i < THREADS_NUM; i++) {
|
||||
assert_true(tdata[i].executed == 0, NULL);
|
||||
zassert_true(tdata[i].executed == 0, NULL);
|
||||
}
|
||||
/* restore environment */
|
||||
teardown_threads();
|
||||
|
@ -98,7 +98,7 @@ void test_sleep_cooperative(void)
|
|||
/* checkpoint: all ready threads get executed when k_sleep */
|
||||
k_sleep(100);
|
||||
for (int i = 0; i < THREADS_NUM; i++) {
|
||||
assert_true(tdata[i].executed == 1, NULL);
|
||||
zassert_true(tdata[i].executed == 1, NULL);
|
||||
}
|
||||
|
||||
/* restore environment */
|
||||
|
@ -115,7 +115,7 @@ void test_busy_wait_cooperative(void)
|
|||
k_busy_wait(100000); /* 100 ms */
|
||||
/* checkpoint: No other threads get executed */
|
||||
for (int i = 0; i < THREADS_NUM; i++) {
|
||||
assert_true(tdata[i].executed == 0, NULL);
|
||||
zassert_true(tdata[i].executed == 0, NULL);
|
||||
}
|
||||
/* restore environment */
|
||||
teardown_threads();
|
||||
|
@ -130,10 +130,10 @@ void test_sleep_wakeup_preemptible(void)
|
|||
spawn_threads(10 * 1000); /* 10 second */
|
||||
/* checkpoint: lower threads not executed, high threads are in sleep */
|
||||
for (int i = 0; i < THREADS_NUM; i++) {
|
||||
assert_true(tdata[i].executed == 0, NULL);
|
||||
zassert_true(tdata[i].executed == 0, NULL);
|
||||
}
|
||||
k_wakeup(tdata[0].tid);
|
||||
assert_true(tdata[0].executed == 1, NULL);
|
||||
zassert_true(tdata[0].executed == 1, NULL);
|
||||
/* restore environment */
|
||||
teardown_threads();
|
||||
}
|
||||
|
@ -147,12 +147,12 @@ void test_time_slicing_preemptible(void)
|
|||
k_sched_time_slice_set(200, 0); /* 200 ms */
|
||||
spawn_threads(0);
|
||||
/* checkpoint: higher priority threads get executed immediately */
|
||||
assert_true(tdata[0].executed == 1, NULL);
|
||||
zassert_true(tdata[0].executed == 1, NULL);
|
||||
k_busy_wait(500000); /* 500 ms */
|
||||
/* checkpoint: equal priority threads get executed every time slice */
|
||||
assert_true(tdata[1].executed == 1, NULL);
|
||||
zassert_true(tdata[1].executed == 1, NULL);
|
||||
for (int i = 2; i < THREADS_NUM; i++) {
|
||||
assert_true(tdata[i].executed == 0, NULL);
|
||||
zassert_true(tdata[i].executed == 0, NULL);
|
||||
}
|
||||
|
||||
/* restore environment */
|
||||
|
@ -168,12 +168,12 @@ void test_time_slicing_disable_preemptible(void)
|
|||
|
||||
spawn_threads(0);
|
||||
/* checkpoint: higher priority threads get executed immediately */
|
||||
assert_true(tdata[0].executed == 1, NULL);
|
||||
zassert_true(tdata[0].executed == 1, NULL);
|
||||
k_busy_wait(500000); /* 500 ms */
|
||||
/* checkpoint: equal priority threads get executed every time slice */
|
||||
assert_true(tdata[1].executed == 0, NULL);
|
||||
zassert_true(tdata[1].executed == 0, NULL);
|
||||
for (int i = 2; i < THREADS_NUM; i++) {
|
||||
assert_true(tdata[i].executed == 0, NULL);
|
||||
zassert_true(tdata[i].executed == 0, NULL);
|
||||
}
|
||||
/* restore environment */
|
||||
teardown_threads();
|
||||
|
@ -191,13 +191,13 @@ void test_lock_preemptible(void)
|
|||
k_busy_wait(100000);
|
||||
/* checkpoint: all other threads not been executed */
|
||||
for (int i = 0; i < THREADS_NUM; i++) {
|
||||
assert_true(tdata[i].executed == 0, NULL);
|
||||
zassert_true(tdata[i].executed == 0, NULL);
|
||||
}
|
||||
/* make current thread unready */
|
||||
k_sleep(100);
|
||||
/* checkpoint: all other threads get executed */
|
||||
for (int i = 0; i < THREADS_NUM; i++) {
|
||||
assert_true(tdata[i].executed == 1, NULL);
|
||||
zassert_true(tdata[i].executed == 1, NULL);
|
||||
}
|
||||
/* restore environment */
|
||||
teardown_threads();
|
||||
|
@ -216,9 +216,9 @@ void test_unlock_preemptible(void)
|
|||
|
||||
k_sched_unlock();
|
||||
/* checkpoint: higher threads get executed */
|
||||
assert_true(tdata[0].executed == 1, NULL);
|
||||
zassert_true(tdata[0].executed == 1, NULL);
|
||||
for (int i = 1; i < THREADS_NUM; i++) {
|
||||
assert_true(tdata[i].executed == 0, NULL);
|
||||
zassert_true(tdata[i].executed == 0, NULL);
|
||||
}
|
||||
/* restore environment */
|
||||
teardown_threads();
|
||||
|
|
|
@ -22,7 +22,7 @@ static struct timer_data tdata;
|
|||
do { \
|
||||
if (!(exp)) { \
|
||||
k_timer_stop(tmr); \
|
||||
assert_true(exp, NULL); \
|
||||
zassert_true(exp, NULL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -247,7 +247,7 @@ void test_timer_user_data(void)
|
|||
(void *)user_data[ii]);
|
||||
check = (intptr_t)k_timer_user_data_get(&user_data_timer[ii]);
|
||||
|
||||
assert_true(check == user_data[ii], NULL);
|
||||
zassert_true(check == user_data[ii], NULL);
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 5; ii++) {
|
||||
|
@ -261,6 +261,6 @@ void test_timer_user_data(void)
|
|||
}
|
||||
|
||||
for (ii = 0; ii < 5; ii++) {
|
||||
assert_true(user_data_correct[ii], NULL);
|
||||
zassert_true(user_data_correct[ii], NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ static void twork_submit(void *data)
|
|||
/**TESTPOINT: init via k_work_init*/
|
||||
k_work_init(&work[i], work_handler);
|
||||
/**TESTPOINT: check pending after work init*/
|
||||
assert_false(k_work_pending(&work[i]), NULL);
|
||||
zassert_false(k_work_pending(&work[i]), NULL);
|
||||
if (work_q) {
|
||||
/**TESTPOINT: work submit to queue*/
|
||||
k_work_submit_to_queue(work_q, &work[i]);
|
||||
|
@ -75,25 +75,25 @@ static void tdelayed_work_submit(void *data)
|
|||
/**TESTPOINT: init via k_delayed_work_init*/
|
||||
k_delayed_work_init(&delayed_work[i], work_handler);
|
||||
/**TESTPOINT: check pending after delayed work init*/
|
||||
assert_false(k_work_pending((struct k_work *)&delayed_work[i]),
|
||||
zassert_false(k_work_pending((struct k_work *)&delayed_work[i]),
|
||||
NULL);
|
||||
/**TESTPOINT: check remaining timeout before submit*/
|
||||
assert_equal(k_delayed_work_remaining_get(&delayed_work[i]), 0,
|
||||
zassert_equal(k_delayed_work_remaining_get(&delayed_work[i]), 0,
|
||||
NULL);
|
||||
if (work_q) {
|
||||
/**TESTPOINT: delayed work submit to queue*/
|
||||
assert_true(k_delayed_work_submit_to_queue(work_q,
|
||||
zassert_true(k_delayed_work_submit_to_queue(work_q,
|
||||
&delayed_work[i], TIMEOUT) == 0, NULL);
|
||||
} else {
|
||||
/**TESTPOINT: delayed work submit to system queue*/
|
||||
assert_true(k_delayed_work_submit(&delayed_work[i],
|
||||
zassert_true(k_delayed_work_submit(&delayed_work[i],
|
||||
TIMEOUT) == 0, NULL);
|
||||
}
|
||||
/**TESTPOINT: check remaining timeout after submit*/
|
||||
assert_true(k_delayed_work_remaining_get(&delayed_work[i]) >=
|
||||
zassert_true(k_delayed_work_remaining_get(&delayed_work[i]) >=
|
||||
TIMEOUT, NULL);
|
||||
/**TESTPOINT: check pending after delayed work submit*/
|
||||
assert_true(k_work_pending((struct k_work *)&delayed_work[i])
|
||||
zassert_true(k_work_pending((struct k_work *)&delayed_work[i])
|
||||
== 0, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -129,29 +129,29 @@ static void tdelayed_work_cancel(void *data)
|
|||
* delayed_work[1] completed
|
||||
* cancel delayed_work_sleepy, expected -EINVAL
|
||||
*/
|
||||
assert_true(ret == 0, NULL);
|
||||
zassert_true(ret == 0, NULL);
|
||||
/**TESTPOINT: delayed work cancel when countdown*/
|
||||
ret = k_delayed_work_cancel(&delayed_work[0]);
|
||||
assert_true(ret == 0, NULL);
|
||||
zassert_true(ret == 0, NULL);
|
||||
/**TESTPOINT: check pending after delayed work cancel*/
|
||||
assert_false(k_work_pending((struct k_work *)&delayed_work[0]), NULL);
|
||||
zassert_false(k_work_pending((struct k_work *)&delayed_work[0]), NULL);
|
||||
if (!k_is_in_isr()) {
|
||||
/*wait for handling work_sleepy*/
|
||||
k_sleep(TIMEOUT);
|
||||
/**TESTPOINT: check pending when work pending*/
|
||||
assert_true(k_work_pending((struct k_work *)&delayed_work[1]),
|
||||
zassert_true(k_work_pending((struct k_work *)&delayed_work[1]),
|
||||
NULL);
|
||||
/**TESTPOINT: delayed work cancel when pending*/
|
||||
ret = k_delayed_work_cancel(&delayed_work[1]);
|
||||
assert_equal(ret, -EINPROGRESS, NULL);
|
||||
zassert_equal(ret, -EINPROGRESS, NULL);
|
||||
/*wait for completed work_sleepy and delayed_work[1]*/
|
||||
k_sleep(TIMEOUT);
|
||||
/**TESTPOINT: check pending when work completed*/
|
||||
assert_false(k_work_pending(
|
||||
zassert_false(k_work_pending(
|
||||
(struct k_work *)&delayed_work_sleepy), NULL);
|
||||
/**TESTPOINT: delayed work cancel when completed*/
|
||||
ret = k_delayed_work_cancel(&delayed_work_sleepy);
|
||||
assert_equal(ret, -EINVAL, NULL);
|
||||
zassert_equal(ret, -EINVAL, NULL);
|
||||
}
|
||||
/*work items not cancelled: delayed_work[1], delayed_work_sleepy*/
|
||||
}
|
||||
|
|
|
@ -76,10 +76,10 @@ static void test_json_encoding(void)
|
|||
|
||||
ret = json_obj_encode_buf(test_descr, ARRAY_SIZE(test_descr),
|
||||
&ts, buffer, sizeof(buffer));
|
||||
assert_equal(ret, 0, "Encoding function returned no errors");
|
||||
zassert_equal(ret, 0, "Encoding function returned no errors");
|
||||
|
||||
ret = strncmp(buffer, encoded, sizeof(encoded) - 1);
|
||||
assert_equal(ret, 0, "Encoded contents consistent");
|
||||
zassert_equal(ret, 0, "Encoded contents consistent");
|
||||
}
|
||||
|
||||
static void test_json_decoding(void)
|
||||
|
@ -102,22 +102,22 @@ static void test_json_decoding(void)
|
|||
ret = json_obj_parse(encoded, sizeof(encoded) - 1, test_descr,
|
||||
ARRAY_SIZE(test_descr), &ts);
|
||||
|
||||
assert_equal(ret, (1 << ARRAY_SIZE(test_descr)) - 1,
|
||||
zassert_equal(ret, (1 << ARRAY_SIZE(test_descr)) - 1,
|
||||
"All fields decoded correctly");
|
||||
|
||||
assert_true(!strcmp(ts.some_string, "zephyr 123"),
|
||||
zassert_true(!strcmp(ts.some_string, "zephyr 123"),
|
||||
"String decoded correctly");
|
||||
assert_equal(ts.some_int, 42, "Positive integer decoded correctly");
|
||||
assert_equal(ts.some_bool, true, "Boolean decoded correctly");
|
||||
assert_equal(ts.some_nested_struct.nested_int, -1234,
|
||||
zassert_equal(ts.some_int, 42, "Positive integer decoded correctly");
|
||||
zassert_equal(ts.some_bool, true, "Boolean decoded correctly");
|
||||
zassert_equal(ts.some_nested_struct.nested_int, -1234,
|
||||
"Nested negative integer decoded correctly");
|
||||
assert_equal(ts.some_nested_struct.nested_bool, false,
|
||||
zassert_equal(ts.some_nested_struct.nested_bool, false,
|
||||
"Nested boolean value decoded correctly");
|
||||
assert_true(!strcmp(ts.some_nested_struct.nested_string,
|
||||
zassert_true(!strcmp(ts.some_nested_struct.nested_string,
|
||||
"this should be escaped: \\t"),
|
||||
"Nested string decoded correctly");
|
||||
assert_equal(ts.some_array_len, 5, "Array has correct number of items");
|
||||
assert_true(!memcmp(ts.some_array, expected_array,
|
||||
zassert_equal(ts.some_array_len, 5, "Array has correct number of items");
|
||||
zassert_true(!memcmp(ts.some_array, expected_array,
|
||||
sizeof(expected_array)),
|
||||
"Array decoded with unexpected values");
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ static void test_json_invalid_unicode(void)
|
|||
|
||||
ret = json_obj_parse(encoded, sizeof(encoded) - 1, test_descr,
|
||||
ARRAY_SIZE(test_descr), &ts);
|
||||
assert_equal(ret, -EINVAL, "Decoding has to fail");
|
||||
zassert_equal(ret, -EINVAL, "Decoding has to fail");
|
||||
}
|
||||
|
||||
static void test_json_missing_quote(void)
|
||||
|
@ -141,7 +141,7 @@ static void test_json_missing_quote(void)
|
|||
|
||||
ret = json_obj_parse(encoded, sizeof(encoded) - 1, test_descr,
|
||||
ARRAY_SIZE(test_descr), &ts);
|
||||
assert_equal(ret, -EINVAL, "Decoding has to fail");
|
||||
zassert_equal(ret, -EINVAL, "Decoding has to fail");
|
||||
}
|
||||
|
||||
static void test_json_wrong_token(void)
|
||||
|
@ -152,7 +152,7 @@ static void test_json_wrong_token(void)
|
|||
|
||||
ret = json_obj_parse(encoded, sizeof(encoded) - 1, test_descr,
|
||||
ARRAY_SIZE(test_descr), &ts);
|
||||
assert_equal(ret, -EINVAL, "Decoding has to fail");
|
||||
zassert_equal(ret, -EINVAL, "Decoding has to fail");
|
||||
}
|
||||
|
||||
static void test_json_item_wrong_type(void)
|
||||
|
@ -163,7 +163,7 @@ static void test_json_item_wrong_type(void)
|
|||
|
||||
ret = json_obj_parse(encoded, sizeof(encoded) - 1, test_descr,
|
||||
ARRAY_SIZE(test_descr), &ts);
|
||||
assert_equal(ret, -EINVAL, "Decoding has to fail");
|
||||
zassert_equal(ret, -EINVAL, "Decoding has to fail");
|
||||
}
|
||||
|
||||
static void test_json_key_not_in_descr(void)
|
||||
|
@ -174,7 +174,7 @@ static void test_json_key_not_in_descr(void)
|
|||
|
||||
ret = json_obj_parse(encoded, sizeof(encoded) - 1, test_descr,
|
||||
ARRAY_SIZE(test_descr), &ts);
|
||||
assert_equal(ret, 0, "No items should be decoded");
|
||||
zassert_equal(ret, 0, "No items should be decoded");
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -74,7 +74,7 @@ static void buf_destroy(struct net_buf *buf)
|
|||
struct net_buf_pool *pool = buf->pool;
|
||||
|
||||
destroy_called++;
|
||||
assert_equal(pool, &bufs_pool, "Invalid free pointer in buffer");
|
||||
zassert_equal(pool, &bufs_pool, "Invalid free pointer in buffer");
|
||||
net_buf_destroy(buf);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ static void frag_destroy(struct net_buf *buf)
|
|||
struct net_buf_pool *pool = buf->pool;
|
||||
|
||||
frag_destroy_called++;
|
||||
assert_equal(pool, &frags_pool,
|
||||
zassert_equal(pool, &frags_pool,
|
||||
"Invalid free frag pointer in buffer");
|
||||
net_buf_destroy(buf);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ static void frag_destroy_big(struct net_buf *buf)
|
|||
struct net_buf_pool *pool = buf->pool;
|
||||
|
||||
frag_destroy_called++;
|
||||
assert_equal(pool, &big_frags_pool,
|
||||
zassert_equal(pool, &big_frags_pool,
|
||||
"Invalid free big frag pointer in buffer");
|
||||
net_buf_destroy(buf);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ static void net_buf_test_1(void)
|
|||
|
||||
for (i = 0; i < bufs_pool.buf_count; i++) {
|
||||
buf = net_buf_alloc(&bufs_pool, K_NO_WAIT);
|
||||
assert_not_null(buf, "Failed to get buffer");
|
||||
zassert_not_null(buf, "Failed to get buffer");
|
||||
bufs[i] = buf;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ static void net_buf_test_1(void)
|
|||
net_buf_unref(bufs[i]);
|
||||
}
|
||||
|
||||
assert_equal(destroy_called, ARRAY_SIZE(bufs),
|
||||
zassert_equal(destroy_called, ARRAY_SIZE(bufs),
|
||||
"Incorrect destroy callback count");
|
||||
}
|
||||
|
||||
|
@ -129,12 +129,12 @@ static void net_buf_test_2(void)
|
|||
int i;
|
||||
|
||||
head = net_buf_alloc(&bufs_pool, K_NO_WAIT);
|
||||
assert_not_null(head, "Failed to get fragment list head");
|
||||
zassert_not_null(head, "Failed to get fragment list head");
|
||||
|
||||
frag = head;
|
||||
for (i = 0; i < bufs_pool.buf_count - 1; i++) {
|
||||
frag->frags = net_buf_alloc(&bufs_pool, K_NO_WAIT);
|
||||
assert_not_null(frag->frags, "Failed to get fragment");
|
||||
zassert_not_null(frag->frags, "Failed to get fragment");
|
||||
frag = frag->frags;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ static void net_buf_test_2(void)
|
|||
|
||||
destroy_called = 0;
|
||||
net_buf_unref(head);
|
||||
assert_equal(destroy_called, bufs_pool.buf_count,
|
||||
zassert_equal(destroy_called, bufs_pool.buf_count,
|
||||
"Incorrect fragment destroy callback count");
|
||||
}
|
||||
|
||||
|
@ -157,11 +157,11 @@ static void test_3_thread(void *arg1, void *arg2, void *arg3)
|
|||
k_sem_give(sema);
|
||||
|
||||
buf = net_buf_get(fifo, TEST_TIMEOUT);
|
||||
assert_not_null(buf, "Unable to get buffer");
|
||||
zassert_not_null(buf, "Unable to get buffer");
|
||||
|
||||
destroy_called = 0;
|
||||
net_buf_unref(buf);
|
||||
assert_equal(destroy_called, bufs_pool.buf_count,
|
||||
zassert_equal(destroy_called, bufs_pool.buf_count,
|
||||
"Incorrect destroy callback count");
|
||||
|
||||
k_sem_give(sema);
|
||||
|
@ -176,12 +176,12 @@ static void net_buf_test_3(void)
|
|||
int i;
|
||||
|
||||
head = net_buf_alloc(&bufs_pool, K_NO_WAIT);
|
||||
assert_not_null(head, "Failed to get fragment list head");
|
||||
zassert_not_null(head, "Failed to get fragment list head");
|
||||
|
||||
frag = head;
|
||||
for (i = 0; i < bufs_pool.buf_count - 1; i++) {
|
||||
frag->frags = net_buf_alloc(&bufs_pool, K_NO_WAIT);
|
||||
assert_not_null(frag->frags, "Failed to get fragment");
|
||||
zassert_not_null(frag->frags, "Failed to get fragment");
|
||||
frag = frag->frags;
|
||||
}
|
||||
|
||||
|
@ -192,12 +192,12 @@ static void net_buf_test_3(void)
|
|||
(k_thread_entry_t) test_3_thread, &fifo, &sema, NULL,
|
||||
K_PRIO_COOP(7), 0, 0);
|
||||
|
||||
assert_true(k_sem_take(&sema, TEST_TIMEOUT) == 0,
|
||||
zassert_true(k_sem_take(&sema, TEST_TIMEOUT) == 0,
|
||||
"Timeout while waiting for semaphore");
|
||||
|
||||
net_buf_put(&fifo, head);
|
||||
|
||||
assert_true(k_sem_take(&sema, TEST_TIMEOUT) == 0,
|
||||
zassert_true(k_sem_take(&sema, TEST_TIMEOUT) == 0,
|
||||
"Timeout while waiting for semaphore");
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ static void net_buf_test_4(void)
|
|||
*/
|
||||
buf = net_buf_alloc(&no_data_pool, K_FOREVER);
|
||||
|
||||
assert_equal(buf->size, 0, "Invalid buffer size");
|
||||
zassert_equal(buf->size, 0, "Invalid buffer size");
|
||||
|
||||
/* Test the fragments by appending after last fragment */
|
||||
for (i = 0; i < frags_pool.buf_count - 1; i++) {
|
||||
|
@ -228,7 +228,7 @@ static void net_buf_test_4(void)
|
|||
|
||||
frag = buf->frags;
|
||||
|
||||
assert_equal(frag->pool->user_data_size, 0, "Invalid user data size");
|
||||
zassert_equal(frag->pool->user_data_size, 0, "Invalid user data size");
|
||||
|
||||
i = 0;
|
||||
while (frag) {
|
||||
|
@ -236,7 +236,7 @@ static void net_buf_test_4(void)
|
|||
i++;
|
||||
}
|
||||
|
||||
assert_equal(i, frags_pool.buf_count, "Incorrect fragment count");
|
||||
zassert_equal(i, frags_pool.buf_count, "Incorrect fragment count");
|
||||
|
||||
/* Remove about half of the fragments and verify count */
|
||||
i = removed = 0;
|
||||
|
@ -261,7 +261,7 @@ static void net_buf_test_4(void)
|
|||
i++;
|
||||
}
|
||||
|
||||
assert_equal(i + removed, frags_pool.buf_count,
|
||||
zassert_equal(i + removed, frags_pool.buf_count,
|
||||
"Incorrect removed fragment count");
|
||||
|
||||
removed = 0;
|
||||
|
@ -274,8 +274,8 @@ static void net_buf_test_4(void)
|
|||
removed++;
|
||||
}
|
||||
|
||||
assert_equal(removed, i, "Incorrect removed fragment count");
|
||||
assert_equal(frag_destroy_called, frags_pool.buf_count,
|
||||
zassert_equal(removed, i, "Incorrect removed fragment count");
|
||||
zassert_equal(frag_destroy_called, frags_pool.buf_count,
|
||||
"Incorrect frag destroy callback count");
|
||||
|
||||
/* Add the fragments back and verify that they are properly unref
|
||||
|
@ -300,13 +300,13 @@ static void net_buf_test_4(void)
|
|||
i++;
|
||||
}
|
||||
|
||||
assert_equal(i, frags_pool.buf_count, "Incorrect fragment count");
|
||||
zassert_equal(i, frags_pool.buf_count, "Incorrect fragment count");
|
||||
|
||||
frag_destroy_called = 0;
|
||||
|
||||
net_buf_unref(buf);
|
||||
|
||||
assert_equal(frag_destroy_called, frags_pool.buf_count,
|
||||
zassert_equal(frag_destroy_called, frags_pool.buf_count,
|
||||
"Incorrect frag destroy callback count");
|
||||
}
|
||||
|
||||
|
@ -334,7 +334,7 @@ static void net_buf_test_big_buf(void)
|
|||
/* First add some application data */
|
||||
len = strlen(example_data);
|
||||
for (i = 0; i < 2; i++) {
|
||||
assert_true(net_buf_tailroom(frag) >= len,
|
||||
zassert_true(net_buf_tailroom(frag) >= len,
|
||||
"Allocated buffer is too small");
|
||||
memcpy(net_buf_add(frag, len), example_data, len);
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ static void net_buf_test_big_buf(void)
|
|||
net_buf_frag_add(buf, frag);
|
||||
net_buf_unref(buf);
|
||||
|
||||
assert_equal(frag_destroy_called, big_frags_pool.buf_count,
|
||||
zassert_equal(frag_destroy_called, big_frags_pool.buf_count,
|
||||
"Incorrect frag destroy callback count");
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ static void net_buf_test_multi_frags(void)
|
|||
/* First add some application data */
|
||||
len = strlen(example_data);
|
||||
for (i = 0; i < frags_pool.buf_count - 1; i++) {
|
||||
assert_true(net_buf_tailroom(frags[i]) >= len,
|
||||
zassert_true(net_buf_tailroom(frags[i]) >= len,
|
||||
"Allocated buffer is too small");
|
||||
memcpy(net_buf_add(frags[i], len), example_data, len);
|
||||
occupied += frags[i]->len;
|
||||
|
@ -398,7 +398,7 @@ static void net_buf_test_multi_frags(void)
|
|||
|
||||
net_buf_unref(buf);
|
||||
|
||||
assert_equal(frag_destroy_called, frags_pool.buf_count,
|
||||
zassert_equal(frag_destroy_called, frags_pool.buf_count,
|
||||
"Incorrect big frag destroy callback count");
|
||||
}
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ static void init_test(void)
|
|||
|
||||
ret = initialize_test_environment();
|
||||
|
||||
assert_true(ret, "Test initialization");
|
||||
zassert_true(ret, "Test initialization");
|
||||
}
|
||||
|
||||
|
||||
|
@ -301,7 +301,7 @@ static void parsing_ns_pkt(void)
|
|||
|
||||
ret = test_packet_parsing(&test_ns_pkt);
|
||||
|
||||
assert_true(ret, "NS parsed");
|
||||
zassert_true(ret, "NS parsed");
|
||||
}
|
||||
|
||||
static void sending_ns_pkt(void)
|
||||
|
@ -310,7 +310,7 @@ static void sending_ns_pkt(void)
|
|||
|
||||
ret = test_ns_sending(&test_ns_pkt);
|
||||
|
||||
assert_true(ret, "NS sent");
|
||||
zassert_true(ret, "NS sent");
|
||||
}
|
||||
|
||||
static void parsing_ack_pkt(void)
|
||||
|
@ -319,7 +319,7 @@ static void parsing_ack_pkt(void)
|
|||
|
||||
ret = test_packet_parsing(&test_ack_pkt);
|
||||
|
||||
assert_true(ret, "ACK parsed");
|
||||
zassert_true(ret, "ACK parsed");
|
||||
}
|
||||
|
||||
static void replying_ack_pkt(void)
|
||||
|
@ -328,7 +328,7 @@ static void replying_ack_pkt(void)
|
|||
|
||||
ret = test_ack_reply(&test_ack_pkt);
|
||||
|
||||
assert_true(ret, "ACK replied");
|
||||
zassert_true(ret, "ACK replied");
|
||||
}
|
||||
|
||||
static void parsing_beacon_pkt(void)
|
||||
|
@ -337,7 +337,7 @@ static void parsing_beacon_pkt(void)
|
|||
|
||||
ret = test_packet_parsing(&test_beacon_pkt);
|
||||
|
||||
assert_true(ret, "Beacon parsed");
|
||||
zassert_true(ret, "Beacon parsed");
|
||||
}
|
||||
|
||||
static void parsing_sec_data_pkt(void)
|
||||
|
@ -346,7 +346,7 @@ static void parsing_sec_data_pkt(void)
|
|||
|
||||
ret = test_packet_parsing(&test_sec_data_pkt);
|
||||
|
||||
assert_true(ret, "Secured data frame parsed");
|
||||
zassert_true(ret, "Secured data frame parsed");
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -198,29 +198,29 @@ static void iface_setup(void)
|
|||
((struct net_if_test *)iface3->dev->driver_data)->idx = 2;
|
||||
|
||||
idx = net_if_get_by_iface(iface1);
|
||||
assert_equal(idx, 0, "Invalid index iface1");
|
||||
zassert_equal(idx, 0, "Invalid index iface1");
|
||||
|
||||
idx = net_if_get_by_iface(iface2);
|
||||
assert_equal(idx, 1, "Invalid index iface2");
|
||||
zassert_equal(idx, 1, "Invalid index iface2");
|
||||
|
||||
idx = net_if_get_by_iface(iface3);
|
||||
assert_equal(idx, 2, "Invalid index iface3");
|
||||
zassert_equal(idx, 2, "Invalid index iface3");
|
||||
|
||||
DBG("Interfaces: [%d] iface1 %p, [%d] iface2 %p, [%d] iface3 %p\n",
|
||||
net_if_get_by_iface(iface1), iface1,
|
||||
net_if_get_by_iface(iface2), iface2,
|
||||
net_if_get_by_iface(iface3), iface3);
|
||||
|
||||
assert_not_null(iface1, "Interface 1");
|
||||
assert_not_null(iface2, "Interface 2");
|
||||
assert_not_null(iface3, "Interface 3");
|
||||
zassert_not_null(iface1, "Interface 1");
|
||||
zassert_not_null(iface2, "Interface 2");
|
||||
zassert_not_null(iface3, "Interface 3");
|
||||
|
||||
ifaddr = net_if_ipv6_addr_add(iface1, &my_addr1,
|
||||
NET_ADDR_MANUAL, 0);
|
||||
if (!ifaddr) {
|
||||
DBG("Cannot add IPv6 address %s\n",
|
||||
net_sprint_ipv6_addr(&my_addr1));
|
||||
assert_not_null(ifaddr, "addr1");
|
||||
zassert_not_null(ifaddr, "addr1");
|
||||
}
|
||||
|
||||
/* For testing purposes we need to set the adddresses preferred */
|
||||
|
@ -231,7 +231,7 @@ static void iface_setup(void)
|
|||
if (!ifaddr) {
|
||||
DBG("Cannot add IPv6 address %s\n",
|
||||
net_sprint_ipv6_addr(&ll_addr));
|
||||
assert_not_null(ifaddr, "ll_addr");
|
||||
zassert_not_null(ifaddr, "ll_addr");
|
||||
}
|
||||
|
||||
ifaddr->addr_state = NET_ADDR_PREFERRED;
|
||||
|
@ -241,7 +241,7 @@ static void iface_setup(void)
|
|||
if (!ifaddr) {
|
||||
DBG("Cannot add IPv6 address %s\n",
|
||||
net_sprint_ipv6_addr(&my_addr2));
|
||||
assert_not_null(ifaddr, "addr2");
|
||||
zassert_not_null(ifaddr, "addr2");
|
||||
}
|
||||
|
||||
ifaddr->addr_state = NET_ADDR_PREFERRED;
|
||||
|
@ -251,7 +251,7 @@ static void iface_setup(void)
|
|||
if (!ifaddr) {
|
||||
DBG("Cannot add IPv6 address %s\n",
|
||||
net_sprint_ipv6_addr(&my_addr3));
|
||||
assert_not_null(ifaddr, "addr3");
|
||||
zassert_not_null(ifaddr, "addr3");
|
||||
}
|
||||
|
||||
ifaddr->addr_state = NET_ADDR_PREFERRED;
|
||||
|
@ -262,7 +262,7 @@ static void iface_setup(void)
|
|||
if (!maddr) {
|
||||
DBG("Cannot add multicast IPv6 address %s\n",
|
||||
net_sprint_ipv6_addr(&in6addr_mcast));
|
||||
assert_not_null(maddr, "mcast");
|
||||
zassert_not_null(maddr, "mcast");
|
||||
}
|
||||
|
||||
net_if_up(iface1);
|
||||
|
@ -311,7 +311,7 @@ static void send_iface1(void)
|
|||
|
||||
ret = send_iface(iface1, 1, false);
|
||||
|
||||
assert_true(ret, "iface 1");
|
||||
zassert_true(ret, "iface 1");
|
||||
}
|
||||
|
||||
static void send_iface2(void)
|
||||
|
@ -322,7 +322,7 @@ static void send_iface2(void)
|
|||
|
||||
ret = send_iface(iface2, 2, false);
|
||||
|
||||
assert_true(ret, "iface 2");
|
||||
zassert_true(ret, "iface 2");
|
||||
}
|
||||
|
||||
static void send_iface3(void)
|
||||
|
@ -333,7 +333,7 @@ static void send_iface3(void)
|
|||
|
||||
ret = send_iface(iface3, 3, false);
|
||||
|
||||
assert_true(ret, "iface 3");
|
||||
zassert_true(ret, "iface 3");
|
||||
}
|
||||
|
||||
static void send_iface1_down(void)
|
||||
|
@ -346,7 +346,7 @@ static void send_iface1_down(void)
|
|||
|
||||
ret = send_iface(iface1, 1, true);
|
||||
|
||||
assert_true(ret, "iface 1 down");
|
||||
zassert_true(ret, "iface 1 down");
|
||||
}
|
||||
|
||||
static void send_iface1_up(void)
|
||||
|
@ -359,7 +359,7 @@ static void send_iface1_up(void)
|
|||
|
||||
ret = send_iface(iface1, 1, false);
|
||||
|
||||
assert_true(ret, "iface 1 up again");
|
||||
zassert_true(ret, "iface 1 up again");
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -381,19 +381,19 @@ void test_dns_query(void)
|
|||
|
||||
rc = eval_query(DNAME1, tid1, DNS_RR_TYPE_A,
|
||||
query_ipv4, sizeof(query_ipv4));
|
||||
assert_equal(rc, 0, "Query test failed for domain: "DNAME1);
|
||||
zassert_equal(rc, 0, "Query test failed for domain: "DNAME1);
|
||||
|
||||
rc = eval_query(NULL, tid1, DNS_RR_TYPE_A,
|
||||
query_ipv4, sizeof(query_ipv4));
|
||||
assert_not_equal(rc, 0, "Query test with invalid domain name failed");
|
||||
zassert_not_equal(rc, 0, "Query test with invalid domain name failed");
|
||||
|
||||
rc = eval_query(DNAME1, tid1, DNS_RR_TYPE_AAAA,
|
||||
query_ipv4, sizeof(query_ipv4));
|
||||
assert_not_equal(rc, 0, "Query test for IPv4 with RR type AAAA failed");
|
||||
zassert_not_equal(rc, 0, "Query test for IPv4 with RR type AAAA failed");
|
||||
|
||||
rc = eval_query(DNAME1, tid1 + 1, DNS_RR_TYPE_A,
|
||||
query_ipv4, sizeof(query_ipv4));
|
||||
assert_not_equal(rc, 0, "Query test with invalid ID failed");
|
||||
zassert_not_equal(rc, 0, "Query test with invalid ID failed");
|
||||
}
|
||||
|
||||
/* DNS response for www.zephyrproject.org with the following parameters:
|
||||
|
@ -430,7 +430,7 @@ void test_dns_response(void)
|
|||
int rc;
|
||||
|
||||
rc = eval_response1(&test1);
|
||||
assert_equal(rc, 0, "Response test failed for domain: "DNAME1);
|
||||
zassert_equal(rc, 0, "Response test failed for domain: "DNAME1);
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -215,7 +215,7 @@ static void test_init(void)
|
|||
if (!ifaddr) {
|
||||
DBG("Cannot add IPv6 address %s\n",
|
||||
net_sprint_ipv6_addr(&my_addr1));
|
||||
assert_not_null(ifaddr, "addr1");
|
||||
zassert_not_null(ifaddr, "addr1");
|
||||
}
|
||||
|
||||
/* For testing purposes we need to set the adddresses preferred */
|
||||
|
@ -226,7 +226,7 @@ static void test_init(void)
|
|||
if (!ifaddr) {
|
||||
DBG("Cannot add IPv6 address %s\n",
|
||||
net_sprint_ipv6_addr(&ll_addr));
|
||||
assert_not_null(ifaddr, "ll_addr");
|
||||
zassert_not_null(ifaddr, "ll_addr");
|
||||
}
|
||||
|
||||
ifaddr->addr_state = NET_ADDR_PREFERRED;
|
||||
|
@ -238,7 +238,7 @@ static void test_init(void)
|
|||
if (!ifaddr) {
|
||||
DBG("Cannot add IPv4 address %s\n",
|
||||
net_sprint_ipv4_addr(&my_addr2));
|
||||
assert_not_null(ifaddr, "addr2");
|
||||
zassert_not_null(ifaddr, "addr2");
|
||||
}
|
||||
|
||||
ifaddr->addr_state = NET_ADDR_PREFERRED;
|
||||
|
@ -272,7 +272,7 @@ static void dns_query_invalid_timeout(void)
|
|||
dns_result_cb_dummy,
|
||||
NULL,
|
||||
K_NO_WAIT);
|
||||
assert_equal(ret, -EINVAL, "Wrong return code for timeout");
|
||||
zassert_equal(ret, -EINVAL, "Wrong return code for timeout");
|
||||
}
|
||||
|
||||
static void dns_query_invalid_context(void)
|
||||
|
@ -286,7 +286,7 @@ static void dns_query_invalid_context(void)
|
|||
dns_result_cb_dummy,
|
||||
NULL,
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, -EINVAL, "Wrong return code for context");
|
||||
zassert_equal(ret, -EINVAL, "Wrong return code for context");
|
||||
}
|
||||
|
||||
static void dns_query_invalid_callback(void)
|
||||
|
@ -299,7 +299,7 @@ static void dns_query_invalid_callback(void)
|
|||
NULL,
|
||||
NULL,
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, -EINVAL, "Wrong return code for callback");
|
||||
zassert_equal(ret, -EINVAL, "Wrong return code for callback");
|
||||
}
|
||||
|
||||
static void dns_query_invalid_query(void)
|
||||
|
@ -312,7 +312,7 @@ static void dns_query_invalid_query(void)
|
|||
dns_result_cb_dummy,
|
||||
NULL,
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, -EINVAL, "Wrong return code for query");
|
||||
zassert_equal(ret, -EINVAL, "Wrong return code for query");
|
||||
}
|
||||
|
||||
void dns_result_cb_timeout(enum dns_resolve_status status,
|
||||
|
@ -325,7 +325,7 @@ void dns_result_cb_timeout(enum dns_resolve_status status,
|
|||
DBG("Result status %d\n", status);
|
||||
DBG("Expected status %d\n", expected_status);
|
||||
|
||||
assert_equal(expected_status, status, "Invalid status");
|
||||
zassert_equal(expected_status, status, "Invalid status");
|
||||
}
|
||||
|
||||
k_sem_give(&wait_data);
|
||||
|
@ -348,7 +348,7 @@ static void dns_query_server_count(void)
|
|||
count++;
|
||||
}
|
||||
|
||||
assert_equal(count, CONFIG_DNS_RESOLVER_MAX_SERVERS,
|
||||
zassert_equal(count, CONFIG_DNS_RESOLVER_MAX_SERVERS,
|
||||
"Invalid number of servers");
|
||||
}
|
||||
|
||||
|
@ -376,8 +376,8 @@ static void dns_query_ipv4_server_count(void)
|
|||
}
|
||||
}
|
||||
|
||||
assert_equal(count, 2, "Invalid number of IPv4 servers");
|
||||
assert_equal(port, 2, "Invalid number of IPv4 servers with port 53");
|
||||
zassert_equal(count, 2, "Invalid number of IPv4 servers");
|
||||
zassert_equal(port, 2, "Invalid number of IPv4 servers with port 53");
|
||||
}
|
||||
|
||||
static void dns_query_ipv6_server_count(void)
|
||||
|
@ -404,8 +404,8 @@ static void dns_query_ipv6_server_count(void)
|
|||
}
|
||||
}
|
||||
|
||||
assert_equal(count, 2, "Invalid number of IPv6 servers");
|
||||
assert_equal(port, 2, "Invalid number of IPv6 servers with port 53");
|
||||
zassert_equal(count, 2, "Invalid number of IPv6 servers");
|
||||
zassert_equal(port, 2, "Invalid number of IPv6 servers with port 53");
|
||||
}
|
||||
|
||||
static void dns_query_too_many(void)
|
||||
|
@ -421,7 +421,7 @@ static void dns_query_too_many(void)
|
|||
dns_result_cb_timeout,
|
||||
INT_TO_POINTER(expected_status),
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, 0, "Cannot create IPv4 query");
|
||||
zassert_equal(ret, 0, "Cannot create IPv4 query");
|
||||
|
||||
ret = dns_get_addr_info(NAME4,
|
||||
DNS_QUERY_TYPE_A,
|
||||
|
@ -429,10 +429,10 @@ static void dns_query_too_many(void)
|
|||
dns_result_cb_dummy,
|
||||
INT_TO_POINTER(expected_status),
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, -EAGAIN, "Should have run out of space");
|
||||
zassert_equal(ret, -EAGAIN, "Should have run out of space");
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(false, "Timeout while waiting data");
|
||||
zassert_true(false, "Timeout while waiting data");
|
||||
}
|
||||
|
||||
timeout_query = false;
|
||||
|
@ -451,10 +451,10 @@ static void dns_query_ipv4_timeout(void)
|
|||
dns_result_cb_timeout,
|
||||
INT_TO_POINTER(expected_status),
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, 0, "Cannot create IPv4 query");
|
||||
zassert_equal(ret, 0, "Cannot create IPv4 query");
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(false, "Timeout while waiting data");
|
||||
zassert_true(false, "Timeout while waiting data");
|
||||
}
|
||||
|
||||
timeout_query = false;
|
||||
|
@ -473,10 +473,10 @@ static void dns_query_ipv6_timeout(void)
|
|||
dns_result_cb_timeout,
|
||||
INT_TO_POINTER(expected_status),
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, 0, "Cannot create IPv6 query");
|
||||
zassert_equal(ret, 0, "Cannot create IPv6 query");
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(false, "Timeout while waiting data");
|
||||
zassert_true(false, "Timeout while waiting data");
|
||||
}
|
||||
|
||||
timeout_query = false;
|
||||
|
@ -497,8 +497,8 @@ static void verify_cancelled(void)
|
|||
}
|
||||
}
|
||||
|
||||
assert_equal(count, 0, "Not all pending queries vere cancelled");
|
||||
assert_equal(timer_not_stopped, 0, "Not all timers vere cancelled");
|
||||
zassert_equal(count, 0, "Not all pending queries vere cancelled");
|
||||
zassert_equal(timer_not_stopped, 0, "Not all timers vere cancelled");
|
||||
}
|
||||
|
||||
static void dns_query_ipv4_cancel(void)
|
||||
|
@ -515,13 +515,13 @@ static void dns_query_ipv4_cancel(void)
|
|||
dns_result_cb_timeout,
|
||||
INT_TO_POINTER(expected_status),
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, 0, "Cannot create IPv4 query");
|
||||
zassert_equal(ret, 0, "Cannot create IPv4 query");
|
||||
|
||||
ret = dns_cancel_addr_info(dns_id);
|
||||
assert_equal(ret, 0, "Cannot cancel IPv4 query");
|
||||
zassert_equal(ret, 0, "Cannot cancel IPv4 query");
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(false, "Timeout while waiting data");
|
||||
zassert_true(false, "Timeout while waiting data");
|
||||
}
|
||||
|
||||
verify_cancelled();
|
||||
|
@ -541,13 +541,13 @@ static void dns_query_ipv6_cancel(void)
|
|||
dns_result_cb_timeout,
|
||||
INT_TO_POINTER(expected_status),
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, 0, "Cannot create IPv6 query");
|
||||
zassert_equal(ret, 0, "Cannot create IPv6 query");
|
||||
|
||||
ret = dns_cancel_addr_info(dns_id);
|
||||
assert_equal(ret, 0, "Cannot cancel IPv6 query");
|
||||
zassert_equal(ret, 0, "Cannot cancel IPv6 query");
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(false, "Timeout while waiting data");
|
||||
zassert_true(false, "Timeout while waiting data");
|
||||
}
|
||||
|
||||
verify_cancelled();
|
||||
|
@ -571,7 +571,7 @@ void dns_result_cb(enum dns_resolve_status status,
|
|||
DBG("Expected status2 %d\n", expected->status2);
|
||||
DBG("Caller %s\n", expected->caller);
|
||||
|
||||
assert_true(false, "Invalid status");
|
||||
zassert_true(false, "Invalid status");
|
||||
}
|
||||
|
||||
k_sem_give(&wait_data2);
|
||||
|
@ -594,14 +594,14 @@ static void dns_query_ipv4(void)
|
|||
dns_result_cb,
|
||||
&status,
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, 0, "Cannot create IPv4 query");
|
||||
zassert_equal(ret, 0, "Cannot create IPv4 query");
|
||||
|
||||
DBG("Query id %u\n", current_dns_id);
|
||||
|
||||
k_yield(); /* mandatory so that net_if send func gets to run */
|
||||
|
||||
if (k_sem_take(&wait_data2, WAIT_TIME)) {
|
||||
assert_true(false, "Timeout while waiting data");
|
||||
zassert_true(false, "Timeout while waiting data");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -622,14 +622,14 @@ static void dns_query_ipv6(void)
|
|||
dns_result_cb,
|
||||
&status,
|
||||
DNS_TIMEOUT);
|
||||
assert_equal(ret, 0, "Cannot create IPv6 query");
|
||||
zassert_equal(ret, 0, "Cannot create IPv6 query");
|
||||
|
||||
DBG("Query id %u\n", current_dns_id);
|
||||
|
||||
k_yield(); /* mandatory so that net_if send func gets to run */
|
||||
|
||||
if (k_sem_take(&wait_data2, WAIT_TIME)) {
|
||||
assert_true(false, "Timeout while waiting data");
|
||||
zassert_true(false, "Timeout while waiting data");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -179,12 +179,12 @@ static void mld_setup(void)
|
|||
|
||||
iface = net_if_get_default();
|
||||
|
||||
assert_not_null(iface, "Interface is NULL");
|
||||
zassert_not_null(iface, "Interface is NULL");
|
||||
|
||||
ifaddr = net_if_ipv6_addr_add(iface, &my_addr,
|
||||
NET_ADDR_MANUAL, 0);
|
||||
|
||||
assert_not_null(ifaddr, "Cannot add IPv6 address");
|
||||
zassert_not_null(ifaddr, "Cannot add IPv6 address");
|
||||
|
||||
/* The semaphore is there to wait the data to be received. */
|
||||
k_sem_init(&wait_data, 0, UINT_MAX);
|
||||
|
@ -198,7 +198,7 @@ static void join_group(void)
|
|||
|
||||
ret = net_ipv6_mld_join(iface, &mcast_addr);
|
||||
|
||||
assert_equal(ret, 0, "Cannot join IPv6 multicast group");
|
||||
zassert_equal(ret, 0, "Cannot join IPv6 multicast group");
|
||||
|
||||
k_yield();
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ static void leave_group(void)
|
|||
|
||||
ret = net_ipv6_mld_leave(iface, &mcast_addr);
|
||||
|
||||
assert_equal(ret, 0, "Cannot leave IPv6 multicast group");
|
||||
zassert_equal(ret, 0, "Cannot leave IPv6 multicast group");
|
||||
|
||||
k_yield();
|
||||
}
|
||||
|
@ -223,11 +223,11 @@ static void catch_join_group(void)
|
|||
join_group();
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(0, "Timeout while waiting join event");
|
||||
zassert_true(0, "Timeout while waiting join event");
|
||||
}
|
||||
|
||||
if (!is_group_joined) {
|
||||
assert_true(0, "Did not catch join event");
|
||||
zassert_true(0, "Did not catch join event");
|
||||
}
|
||||
|
||||
is_group_joined = false;
|
||||
|
@ -240,11 +240,11 @@ static void catch_leave_group(void)
|
|||
leave_group();
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(0, "Timeout while waiting leave event");
|
||||
zassert_true(0, "Timeout while waiting leave event");
|
||||
}
|
||||
|
||||
if (!is_group_left) {
|
||||
assert_true(0, "Did not catch leave event");
|
||||
zassert_true(0, "Did not catch leave event");
|
||||
}
|
||||
|
||||
is_group_left = false;
|
||||
|
@ -257,11 +257,11 @@ static void verify_join_group(void)
|
|||
join_group();
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(0, "Timeout while waiting join event");
|
||||
zassert_true(0, "Timeout while waiting join event");
|
||||
}
|
||||
|
||||
if (!is_join_msg_ok) {
|
||||
assert_true(0, "Join msg invalid");
|
||||
zassert_true(0, "Join msg invalid");
|
||||
}
|
||||
|
||||
is_join_msg_ok = false;
|
||||
|
@ -274,11 +274,11 @@ static void verify_leave_group(void)
|
|||
leave_group();
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(0, "Timeout while waiting leave event");
|
||||
zassert_true(0, "Timeout while waiting leave event");
|
||||
}
|
||||
|
||||
if (!is_leave_msg_ok) {
|
||||
assert_true(0, "Leave msg invalid");
|
||||
zassert_true(0, "Leave msg invalid");
|
||||
}
|
||||
|
||||
is_leave_msg_ok = false;
|
||||
|
@ -368,11 +368,11 @@ static void catch_query(void)
|
|||
k_yield();
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(0, "Timeout while waiting query event");
|
||||
zassert_true(0, "Timeout while waiting query event");
|
||||
}
|
||||
|
||||
if (!is_query_received) {
|
||||
assert_true(0, "Query msg invalid");
|
||||
zassert_true(0, "Query msg invalid");
|
||||
}
|
||||
|
||||
is_query_received = false;
|
||||
|
@ -396,11 +396,11 @@ static void verify_send_report(void)
|
|||
|
||||
/* Did we send a report? */
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
assert_true(0, "Timeout while waiting report");
|
||||
zassert_true(0, "Timeout while waiting report");
|
||||
}
|
||||
|
||||
if (!is_report_sent) {
|
||||
assert_true(0, "Report not sent");
|
||||
zassert_true(0, "Report not sent");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -420,7 +420,7 @@ static void test_allnodes(void)
|
|||
|
||||
ifmaddr = net_if_ipv6_maddr_lookup(&addr, &iface);
|
||||
|
||||
assert_not_null(ifmaddr, "Interface does not contain "
|
||||
zassert_not_null(ifmaddr, "Interface does not contain "
|
||||
"allnodes multicast address");
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ static void test_solicit_node(void)
|
|||
|
||||
ifmaddr = net_if_ipv6_maddr_lookup(&addr, &iface);
|
||||
|
||||
assert_not_null(ifmaddr, "Interface does not contain "
|
||||
zassert_not_null(ifmaddr, "Interface does not contain "
|
||||
"solicit node multicast address");
|
||||
}
|
||||
|
||||
|
|
|
@ -158,9 +158,9 @@ static int test_rmdir(void)
|
|||
|
||||
void test_fat_dir(void)
|
||||
{
|
||||
assert_true(test_mkdir() == TC_PASS, NULL);
|
||||
assert_true(test_lsdir("/") == TC_PASS, NULL);
|
||||
assert_true(test_lsdir(TEST_DIR) == TC_PASS, NULL);
|
||||
assert_true(test_rmdir() == TC_PASS, NULL);
|
||||
assert_true(test_lsdir("/") == TC_PASS, NULL);
|
||||
zassert_true(test_mkdir() == TC_PASS, NULL);
|
||||
zassert_true(test_lsdir("/") == TC_PASS, NULL);
|
||||
zassert_true(test_lsdir(TEST_DIR) == TC_PASS, NULL);
|
||||
zassert_true(test_rmdir() == TC_PASS, NULL);
|
||||
zassert_true(test_lsdir("/") == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -272,11 +272,11 @@ static int test_file_delete(void)
|
|||
|
||||
void test_fat_file(void)
|
||||
{
|
||||
assert_true(test_file_open() == TC_PASS, NULL);
|
||||
assert_true(test_file_write() == TC_PASS, NULL);
|
||||
assert_true(test_file_sync() == TC_PASS, NULL);
|
||||
assert_true(test_file_read() == TC_PASS, NULL);
|
||||
assert_true(test_file_truncate() == TC_PASS, NULL);
|
||||
assert_true(test_file_close() == TC_PASS, NULL);
|
||||
assert_true(test_file_delete() == TC_PASS, NULL);
|
||||
zassert_true(test_file_open() == TC_PASS, NULL);
|
||||
zassert_true(test_file_write() == TC_PASS, NULL);
|
||||
zassert_true(test_file_sync() == TC_PASS, NULL);
|
||||
zassert_true(test_file_read() == TC_PASS, NULL);
|
||||
zassert_true(test_file_truncate() == TC_PASS, NULL);
|
||||
zassert_true(test_file_close() == TC_PASS, NULL);
|
||||
zassert_true(test_file_delete() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -35,5 +35,5 @@ static int test_statvfs(void)
|
|||
|
||||
void test_fat_fs(void)
|
||||
{
|
||||
assert_true(test_statvfs() == TC_PASS, NULL);
|
||||
zassert_true(test_statvfs() == TC_PASS, NULL);
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@ int at_handle(struct at_client *hf_at)
|
|||
{
|
||||
uint32_t val;
|
||||
|
||||
assert_equal(at_get_number(hf_at, &val), 0, "Error getting value");
|
||||
zassert_equal(at_get_number(hf_at, &val), 0, "Error getting value");
|
||||
|
||||
assert_equal(val, 999, "Invalid value parsed");
|
||||
zassert_equal(val, 999, "Invalid value parsed");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ int at_resp(struct at_client *hf_at, struct net_buf *buf)
|
|||
|
||||
err = at_parse_cmd_input(hf_at, buf, "ABCD", at_handle,
|
||||
AT_CMD_TYPE_NORMAL);
|
||||
assert_equal(err, 0, "Error parsing CMD input");
|
||||
zassert_equal(err, 0, "Error parsing CMD input");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -53,17 +53,17 @@ static void at_test1(void)
|
|||
at.buf = buffer;
|
||||
|
||||
buf = net_buf_alloc(&at_pool, K_FOREVER);
|
||||
assert_not_null(buf, "Failed to get buffer");
|
||||
zassert_not_null(buf, "Failed to get buffer");
|
||||
|
||||
at_register(&at, at_resp, NULL);
|
||||
len = strlen(example_data);
|
||||
|
||||
assert_true(net_buf_tailroom(buf) >= len,
|
||||
zassert_true(net_buf_tailroom(buf) >= len,
|
||||
"Allocated buffer is too small");
|
||||
strncpy((char *)buf->data, example_data, len);
|
||||
net_buf_add(buf, len);
|
||||
|
||||
assert_equal(at_parse_input(&at, buf), 0, "Parsing failed");
|
||||
zassert_equal(at_parse_input(&at, buf), 0, "Parsing failed");
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -50,10 +50,10 @@ static void test_get_single_buffer(void)
|
|||
|
||||
buf = net_buf_alloc(&bufs_pool, K_NO_WAIT);
|
||||
|
||||
assert_equal(buf->ref, 1, "Invalid refcount");
|
||||
assert_equal(buf->len, 0, "Invalid length");
|
||||
assert_equal(buf->flags, 0, "Invalid flags");
|
||||
assert_equal_ptr(buf->frags, NULL, "Frags not NULL");
|
||||
zassert_equal(buf->ref, 1, "Invalid refcount");
|
||||
zassert_equal(buf->len, 0, "Invalid length");
|
||||
zassert_equal(buf->flags, 0, "Invalid flags");
|
||||
zassert_equal_ptr(buf->frags, NULL, "Frags not NULL");
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -16,15 +16,11 @@
|
|||
|
||||
#include <ztest.h>
|
||||
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
|
||||
void ztest_test_fail(void);
|
||||
|
||||
#if CONFIG_ZTEST_ASSERT_VERBOSE == 0
|
||||
|
||||
static inline void _assert_(int cond, const char *file, int line)
|
||||
static inline void _zassert_(int cond, const char *file, int line)
|
||||
{
|
||||
if (!(cond)) {
|
||||
PRINT("\n Assertion failed at %s:%d\n",
|
||||
|
@ -33,12 +29,12 @@ static inline void _assert_(int cond, const char *file, int line)
|
|||
}
|
||||
}
|
||||
|
||||
#define _assert(cond, msg, default_msg, file, line, func) \
|
||||
_assert_(cond, file, line)
|
||||
#define _zassert(cond, msg, default_msg, file, line, func) \
|
||||
_zassert_(cond, file, line)
|
||||
|
||||
#else /* CONFIG_ZTEST_ASSERT_VERBOSE != 0 */
|
||||
|
||||
static inline void _assert(int cond, const char *msg, const char *default_msg,
|
||||
static inline void _zassert(int cond, const char *msg, const char *default_msg,
|
||||
const char *file, int line, const char *func)
|
||||
{
|
||||
if (!(cond)) {
|
||||
|
@ -69,50 +65,50 @@ static inline void _assert(int cond, const char *msg, const char *default_msg,
|
|||
* @brief Fail the test, if @a cond is false
|
||||
*
|
||||
* You probably don't need to call this macro directly. You should
|
||||
* instead use assert_{condition} macros below.
|
||||
* instead use zassert_{condition} macros below.
|
||||
*
|
||||
* @param cond Condition to check
|
||||
* @param msg Optional, can be NULL. Message to print if @a cond is false.
|
||||
* @param default_msg Message to print if @a cond is false
|
||||
*/
|
||||
|
||||
#define assert(cond, msg, default_msg) \
|
||||
_assert(cond, msg ? msg : "", msg ? ("(" default_msg ")") : (default_msg), \
|
||||
#define zassert(cond, msg, default_msg) \
|
||||
_zassert(cond, msg ? msg : "", msg ? ("(" default_msg ")") : (default_msg), \
|
||||
__FILE__, __LINE__, __func__)
|
||||
|
||||
/**
|
||||
* @brief Assert that this function call won't be reached
|
||||
* @param msg Optional message to print if the assertion fails
|
||||
*/
|
||||
#define assert_unreachable(msg) assert(0, msg, "Reached unreachable code")
|
||||
#define zassert_unreachable(msg) zassert(0, msg, "Reached unreachable code")
|
||||
|
||||
/**
|
||||
* @brief Assert that @a cond is true
|
||||
* @param cond Condition to check
|
||||
* @param msg Optional message to print if the assertion fails
|
||||
*/
|
||||
#define assert_true(cond, msg) assert(cond, msg, #cond " is false")
|
||||
#define zassert_true(cond, msg) zassert(cond, msg, #cond " is false")
|
||||
|
||||
/**
|
||||
* @brief Assert that @a cond is false
|
||||
* @param cond Condition to check
|
||||
* @param msg Optional message to print if the assertion fails
|
||||
*/
|
||||
#define assert_false(cond, msg) assert(!(cond), msg, #cond " is true")
|
||||
#define zassert_false(cond, msg) zassert(!(cond), msg, #cond " is true")
|
||||
|
||||
/**
|
||||
* @brief Assert that @a ptr is NULL
|
||||
* @param ptr Pointer to compare
|
||||
* @param msg Optional message to print if the assertion fails
|
||||
*/
|
||||
#define assert_is_null(ptr, msg) assert((ptr) == NULL, msg, #ptr " is not NULL")
|
||||
#define zassert_is_null(ptr, msg) zassert((ptr) == NULL, msg, #ptr " is not NULL")
|
||||
|
||||
/**
|
||||
* @brief Assert that @a ptr is not NULL
|
||||
* @param ptr Pointer to compare
|
||||
* @param msg Optional message to print if the assertion fails
|
||||
*/
|
||||
#define assert_not_null(ptr, msg) assert((ptr) != NULL, msg, #ptr " is NULL")
|
||||
#define zassert_not_null(ptr, msg) zassert((ptr) != NULL, msg, #ptr " is NULL")
|
||||
|
||||
/**
|
||||
* @brief Assert that @a a equals @a b
|
||||
|
@ -123,7 +119,7 @@ static inline void _assert(int cond, const char *msg, const char *default_msg,
|
|||
* @param b Value to compare
|
||||
* @param msg Optional message to print if the assertion fails
|
||||
*/
|
||||
#define assert_equal(a, b, msg) assert((a) == (b), msg, #a " not equal to " #b)
|
||||
#define zassert_equal(a, b, msg) zassert((a) == (b), msg, #a " not equal to " #b)
|
||||
|
||||
/**
|
||||
* @brief Assert that @a a does not equal @a b
|
||||
|
@ -134,7 +130,7 @@ static inline void _assert(int cond, const char *msg, const char *default_msg,
|
|||
* @param b Value to compare
|
||||
* @param msg Optional message to print if the assertion fails
|
||||
*/
|
||||
#define assert_not_equal(a, b, msg) assert((a) != (b), msg, #a " equal to " #b)
|
||||
#define zassert_not_equal(a, b, msg) zassert((a) != (b), msg, #a " equal to " #b)
|
||||
|
||||
/**
|
||||
* @brief Assert that @a a equals @a b
|
||||
|
@ -145,8 +141,8 @@ static inline void _assert(int cond, const char *msg, const char *default_msg,
|
|||
* @param b Value to compare
|
||||
* @param msg Optional message to print if the assertion fails
|
||||
*/
|
||||
#define assert_equal_ptr(a, b, msg) \
|
||||
assert((void *)(a) == (void *)(b), msg, #a " not equal to " #b)
|
||||
#define zassert_equal_ptr(a, b, msg) \
|
||||
zassert((void *)(a) == (void *)(b), msg, #a " not equal to " #b)
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -12,12 +12,12 @@ static void empty_test(void)
|
|||
|
||||
static void assert_tests(void)
|
||||
{
|
||||
assert_true(1, NULL);
|
||||
assert_false(0, NULL);
|
||||
assert_is_null(NULL, NULL);
|
||||
assert_not_null("foo", NULL);
|
||||
assert_equal(1, 1, NULL);
|
||||
assert_equal_ptr(NULL, NULL, NULL);
|
||||
zassert_true(1, NULL);
|
||||
zassert_false(0, NULL);
|
||||
zassert_is_null(NULL, NULL);
|
||||
zassert_not_null("foo", NULL);
|
||||
zassert_equal(1, 1, NULL);
|
||||
zassert_equal_ptr(NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
|
@ -35,7 +35,7 @@ static int returns_int(void)
|
|||
static void return_value_tests(void)
|
||||
{
|
||||
ztest_returns_value(returns_int, 5);
|
||||
assert_equal(returns_int(), 5, NULL);
|
||||
zassert_equal(returns_int(), 5, NULL);
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
|
|
Loading…
Reference in a new issue