Home | History | Annotate | Download | only in tests
      1 #include "config.h"
      2 #include <time.h>
      3 #include <pthread.h>
      4 #include <assert.h>
      5 #include <errno.h>
      6 
      7 int main()
      8 {
      9    struct timespec abstime;
     10    pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
     11    pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
     12 
     13 #ifdef HAVE_CLOCK_GETTIME
     14    assert(clock_gettime(CLOCK_REALTIME, &abstime)==0);
     15 #else
     16    abstime.tv_sec = time(NULL) + 2;
     17    abstime.tv_nsec = 0;
     18 #endif
     19    abstime.tv_nsec += 1000000000;
     20 
     21    assert(pthread_mutex_lock(&mutex)==0);
     22    assert(pthread_cond_timedwait(&cond, &mutex, &abstime)==EINVAL);
     23    assert(pthread_mutex_unlock(&mutex)==0);
     24 
     25    return 0;
     26 }
     27