ftmemsim-valgrind/helgrind/tests/cond_timedwait_invalid.c
Florian Krohm b84e215343 Rewrite test to not use function clock_gettime. The purpose
of this is to not have to link against -lrt because that causes
a different back-trace on certain x86 and s390x environments.
See the thread with subject 
"helgrind/tests/cond_timedwait_invalid failing on x86"
on valgrind-developers for more details.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12246
2011-10-28 00:11:44 +00:00

27 lines
502 B
C

#include <time.h>
#include <pthread.h>
#include <assert.h>
#include <errno.h>
int main()
{
struct timespec abstime;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
abstime.tv_sec = time(NULL) + 2;
abstime.tv_nsec = 0;
abstime.tv_nsec += 1000000000;
assert(pthread_mutex_lock(&mutex)==0);
assert(pthread_cond_timedwait(&cond, &mutex, &abstime)==EINVAL);
assert(pthread_mutex_unlock(&mutex)==0);
return 0;
}