Lines Matching +full:data +full:- +full:timeout

4  * SPDX-License-Identifier: Apache-2.0
16 * @brief Test fifo APIs timeout
18 * This module tests following fifo timeout scenarios
20 * First, the thread waits with a timeout and times out. Then it wait with a
21 * timeout, but gets the data in time.
23 * Then, multiple timeout tests are done for the threads, to test the ordering
24 * of queueing/dequeueing when timeout occurs, first on one fifo, then on
28 * data in time, except the last one: this tests that the timeout is
45 uint32_t timeout; member
81 #define FIFO_THREAD_PRIO -5
101 static bool is_timeout_in_range(uint32_t start_time, uint32_t timeout) in is_timeout_in_range() argument
106 diff = (uint32_t)k_cyc_to_ns_floor64(stop_time - in is_timeout_in_range()
109 return timeout <= diff; in is_timeout_in_range()
112 /* a thread sleeps then puts data on the fifo */
115 uint32_t timeout = *((uint32_t *)p2); in test_thread_put_timeout() local
117 k_msleep(timeout); in test_thread_put_timeout()
131 packet = k_fifo_get(d->fifo, K_MSEC(d->timeout)); in test_thread_pend_and_timeout()
133 zassert_true(is_timeout_in_range(start_time, d->timeout)); in test_thread_pend_and_timeout()
137 /* Spins several threads that pend and timeout on fifos */
155 * estimation of a timeout occurring with the max deviation of an in test_multiple_threads_pending()
156 * additional tick. Hence the timeout order may slightly be different in test_multiple_threads_pending()
160 struct timeout_order_data *data = in test_multiple_threads_pending() local
163 zassert_not_null(data, NULL); in test_multiple_threads_pending()
164 if (data->timeout_order == ii) { in test_multiple_threads_pending()
166 data->q_order, data->timeout, data->fifo); in test_multiple_threads_pending()
177 if (data->timeout > test_data[j].timeout) { in test_multiple_threads_pending()
178 diff_ms = data->timeout - test_data[j].timeout; in test_multiple_threads_pending()
180 diff_ms = test_data[j].timeout - data->timeout; in test_multiple_threads_pending()
186 data->q_order, data->timeout, data->fifo); in test_multiple_threads_pending()
190 data->q_order, j); in test_multiple_threads_pending()
199 /* a thread pends on a fifo with a timeout and gets the data in time */
205 packet = k_fifo_get(d->fifo, K_MSEC(d->timeout)); in test_thread_pend_and_get_data()
212 /* Spins child threads that get fifo data in time, except the last one */
216 struct timeout_order_data *data; in test_multiple_threads_get_data() local
219 for (ii = 0; ii < test_data_size-1; ii++) { in test_multiple_threads_get_data()
231 for (ii = 0; ii < test_data_size-1; ii++) { in test_multiple_threads_get_data()
234 data = k_fifo_get(&timeout_order_fifo, K_FOREVER); in test_multiple_threads_get_data()
235 if (!data) { in test_multiple_threads_get_data()
240 if (data->q_order != ii) { in test_multiple_threads_get_data()
242 data->q_order, ii); in test_multiple_threads_get_data()
246 if (data->q_order == ii) { in test_multiple_threads_get_data()
248 data->q_order, data->timeout, data->fifo); in test_multiple_threads_get_data()
252 data = k_fifo_get(&timeout_order_fifo, K_FOREVER); in test_multiple_threads_get_data()
253 if (!data) { in test_multiple_threads_get_data()
258 if (data->q_order != ii) { in test_multiple_threads_get_data()
260 data->q_order, ii); in test_multiple_threads_get_data()
265 data->q_order, data->timeout, data->fifo); in test_multiple_threads_get_data()
270 /* try getting data on fifo with special timeout value, return result in fifo */
275 reply_packet->reply = in test_thread_timeout_reply_values()
285 reply_packet->reply = in test_thread_timeout_reply_values_wfe()
297 * @brief Test empty fifo with timeout and K_NO_WAIT
303 uint32_t start_time, timeout; in ZTEST() local
307 /* Test empty fifo with timeout */ in ZTEST()
308 timeout = 10U; in ZTEST()
310 packet = k_fifo_get(&fifo_timeout[0], K_MSEC(timeout)); in ZTEST()
312 zassert_true(is_timeout_in_range(start_time, timeout)); in ZTEST()
314 /* Test empty fifo with timeout of K_NO_WAIT */ in ZTEST()
320 * @brief Test non empty fifo with timeout and K_NO_WAIT
343 * @brief Test fifo with timeout and K_NO_WAIT
344 * @details In first scenario test fifo with some timeout where child thread
345 * puts data on the fifo on time. In second scenario test k_fifo_get with
346 * timeout of K_NO_WAIT and the fifo should be filled by the child thread
347 * based on the data availability on another fifo. In third scenario test
348 * k_fifo_get with timeout of K_FOREVER and the fifo should be filled by
349 * the child thread based on the data availability on another fifo.
356 uint32_t start_time, timeout; in ZTEST() local
361 * Test fifo with some timeout and child thread that puts in ZTEST()
362 * data on the fifo on time in ZTEST()
364 timeout = 10U; in ZTEST()
369 &timeout, NULL, in ZTEST()
372 packet = k_fifo_get(&fifo_timeout[0], K_MSEC(timeout + 10)); in ZTEST()
374 zassert_true(is_timeout_in_range(start_time, timeout)); in ZTEST()
378 * Test k_fifo_get with timeout of K_NO_WAIT and the fifo in ZTEST()
380 * the data availability on another fifo. In this test child in ZTEST()
381 * thread does not find data on fifo. in ZTEST()
394 * Test k_fifo_get with timeout of K_NO_WAIT and the fifo in ZTEST()
396 * the data availability on another fifo. In this test child in ZTEST()
397 * thread does find data on fifo. in ZTEST()
414 * Test k_fifo_get with timeout of K_FOREVER and the fifo in ZTEST()
416 * the data availability on another fifo. In this test child in ZTEST()
417 * thread does find data on fifo. in ZTEST()
476 * different timeouts but getting the data in time
486 * the data in time, except the last one. in ZTEST()