Also add dg-shouldfail to ignore failures due to ulimit. gcc/testsuite/ChangeLog:
PR testsuite/100655 * g++.dg/tsan/pthread_cond_clockwait.C: Use libstdc++ macro to check for availability of pthread_cond_clockwait. Add dg-shouldfail. Tested x86_64-linux (glibc 2.23) and powerpc64le-linux (glibc 2.17) OK for trunk?
commit 86f5ac3b64a98280df6f0ea407eea8cde7c2edbd Author: Jonathan Wakely <jwak...@redhat.com> Date: Thu May 20 12:40:07 2021 testsuite: Use libstdc++ macro to check for pthread_cond_clockwait [PR 100655] Also add dg-shouldfail to ignore failures due to ulimit. gcc/testsuite/ChangeLog: PR testsuite/100655 * g++.dg/tsan/pthread_cond_clockwait.C: Use libstdc++ macro to check for availability of pthread_cond_clockwait. Add dg-shouldfail. diff --git a/gcc/testsuite/g++.dg/tsan/pthread_cond_clockwait.C b/gcc/testsuite/g++.dg/tsan/pthread_cond_clockwait.C index 82d6a5c8329..c6c621bea51 100644 --- a/gcc/testsuite/g++.dg/tsan/pthread_cond_clockwait.C +++ b/gcc/testsuite/g++.dg/tsan/pthread_cond_clockwait.C @@ -1,9 +1,14 @@ // Test pthread_cond_clockwait not generating false positives with tsan +/* { dg-shouldfail "tsan" } */ // { dg-do run { target { { *-*-linux* *-*-gnu* *-*-uclinux* } && pthread } } } // { dg-options "-fsanitize=thread -lpthread" } #include <pthread.h> +// Include this to get the libstdc++ _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT +// macro that indicates pthread_cond_clockwait is available. +#include <type_traits> + pthread_cond_t cv; pthread_mutex_t mtx; @@ -23,7 +28,9 @@ int main() { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); ts.tv_sec += 10; +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT pthread_cond_clockwait(&cv, &mtx, CLOCK_MONOTONIC, &ts); +#endif pthread_mutex_unlock(&mtx); pthread_join(tid, NULL);