diff --git a/tests/z_api_matching_test.c b/tests/z_api_matching_test.c index f28a2d527..f77a726c8 100644 --- a/tests/z_api_matching_test.c +++ b/tests/z_api_matching_test.c @@ -47,14 +47,19 @@ static void _context_drop(context_t* c) { static void _context_wait(context_t* c, context_state_t state, int timeout_s) { z_mutex_lock(z_mutex_loan_mut(&c->m)); if (c->state != state) { + printf("Waiting for state %d...\n", state); +#ifdef ZENOH_MACOS + _ZP_UNUSED(timeout_s); + z_condvar_wait(z_condvar_loan_mut(&c->cv), z_mutex_loan_mut(&c->m)); +#else z_clock_t clock = z_clock_now(); z_clock_advance_s(&clock, timeout_s); - printf("Waiting for state %d...\n", state); z_result_t res = z_condvar_wait_until(z_condvar_loan_mut(&c->cv), z_mutex_loan_mut(&c->m), &clock); if (res == Z_ETIMEDOUT) { fprintf(stderr, "Timeout waiting for state %d\n", state); assert(false); } +#endif if (c->state != state) { fprintf(stderr, "Expected state %d, got %d\n", state, c->state); assert(false); @@ -142,15 +147,15 @@ void test_matching_sub(bool background) { assert_ok(z_declare_subscriber(z_session_loan(&s2), &sub, z_view_keyexpr_loan(&k_sub), z_closure_sample_move(&callback), NULL)); - _context_wait(&context, MATCH, 30); + _context_wait(&context, MATCH, 10); z_subscriber_drop(z_subscriber_move(&sub)); - _context_wait(&context, UNMATCH, 30); + _context_wait(&context, UNMATCH, 10); z_publisher_drop(z_publisher_move(&pub)); - _context_wait(&context, DROP, 30); + _context_wait(&context, DROP, 10); if (!background) { z_matching_listener_drop(z_matching_listener_move(&matching_listener));