From: Paul Floyd Date: Mon, 22 Dec 2025 09:19:30 +0000 (+0100) Subject: Helgrind regtest: add asserts to cond_timedwait_test.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9575cb18430e9f8fc161e68d42680b611c7c673b;p=thirdparty%2Fvalgrind.git Helgrind regtest: add asserts to cond_timedwait_test.c This test fails on Darwin, It looks like Darwin uses another mutex and it's complaining that the condition mutex is not locked when the unlock call is made. I made these changes when checking that the testcase has the same behaviour on FreeBSD. --- diff --git a/helgrind/tests/cond_timedwait_test.c b/helgrind/tests/cond_timedwait_test.c index e9b9be8a2..3b755917b 100644 --- a/helgrind/tests/cond_timedwait_test.c +++ b/helgrind/tests/cond_timedwait_test.c @@ -1,20 +1,28 @@ #include #include +#include +#include -int main() { - pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - pthread_cond_t cond = PTHREAD_COND_INITIALIZER; +int main(void) +{ + pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + pthread_cond_t cond = PTHREAD_COND_INITIALIZER; + int res; - // This time has most definitely passed already. (Epoch) - struct timespec now; - memset(&now, 0, sizeof(now)); + // This time has most definitely passed already. (Epoch) + struct timespec now; + memset(&now, 0, sizeof(now)); - pthread_mutex_lock(&mutex); - pthread_cond_timedwait(&cond, &mutex, &now); - pthread_mutex_unlock(&mutex); + res = pthread_mutex_lock(&mutex); + assert(res == 0); + res = pthread_cond_timedwait(&cond, &mutex, &now); + assert(res == ETIMEDOUT); - pthread_mutex_destroy(&mutex); - pthread_cond_destroy(&cond); + res = pthread_mutex_unlock(&mutex); + assert(res == 0); - return 0; + res = pthread_mutex_destroy(&mutex); + assert(res == 0); + res = pthread_cond_destroy(&cond); + assert(res == 0); }