tests: posix: semaphores: reduce execution time by 5s
There is no reason to use a 5s wait time in tests. This can add up quite significantly across multiple platforms that execute in real-time under qemu (or even just on real hardware). Speedup observed with qemu_cortex_a53/qemu_cortex_a53/smp Before: ``` START - test_named_semaphore PASS - test_named_semaphore in 5.688 seconds ``` After: ``` START - test_named_semaphore PASS - test_named_semaphore in 0.783 seconds ``` Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
parent
0449324257
commit
c2609155b3
1 changed files with 6 additions and 4 deletions
|
@ -13,6 +13,9 @@
|
|||
#include <zephyr/sys/util.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
#define WAIT_TIME_MS 100
|
||||
BUILD_ASSERT(WAIT_TIME_MS > 0, "WAIT_TIME_MS must be posistive");
|
||||
|
||||
static void *child_func(void *p1)
|
||||
{
|
||||
sem_t *sem = (sem_t *)p1;
|
||||
|
@ -51,11 +54,10 @@ static void semaphore_test(sem_t *sem)
|
|||
|
||||
zassert_equal(clock_gettime(CLOCK_REALTIME, &abstime), 0, "clock_gettime failed");
|
||||
|
||||
abstime.tv_sec += 5;
|
||||
abstime.tv_sec += WAIT_TIME_MS / MSEC_PER_SEC;
|
||||
abstime.tv_nsec += (WAIT_TIME_MS % MSEC_PER_SEC) * NSEC_PER_MSEC;
|
||||
|
||||
/* TESPOINT: Wait for 5 seconds and acquire sema given
|
||||
* by thread1
|
||||
*/
|
||||
/* TESPOINT: Wait to acquire sem given by thread1 */
|
||||
zassert_equal(sem_timedwait(sem, &abstime), 0);
|
||||
|
||||
/* TESTPOINT: Semaphore is already acquired, check if
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue