Skip to content

Commit 2231c7e

Browse files
committed
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>
1 parent a54e3b1 commit 2231c7e

File tree

1 file changed

+4
-4
lines changed
  • tests/posix/semaphores/src

1 file changed

+4
-4
lines changed

tests/posix/semaphores/src/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <zephyr/sys/util.h>
1414
#include <zephyr/ztest.h>
1515

16+
#define WAIT_TIME_MS 100
17+
1618
static void *child_func(void *p1)
1719
{
1820
sem_t *sem = (sem_t *)p1;
@@ -51,11 +53,9 @@ static void semaphore_test(sem_t *sem)
5153

5254
zassert_equal(clock_gettime(CLOCK_REALTIME, &abstime), 0, "clock_gettime failed");
5355

54-
abstime.tv_sec += 5;
56+
abstime.tv_nsec += WAIT_TIME_MS * NSEC_PER_MSEC;
5557

56-
/* TESPOINT: Wait for 5 seconds and acquire sema given
57-
* by thread1
58-
*/
58+
/* TESPOINT: Wait to acquire sem given by thread1 */
5959
zassert_equal(sem_timedwait(sem, &abstime), 0);
6060

6161
/* TESTPOINT: Semaphore is already acquired, check if

0 commit comments

Comments
 (0)