projects
/
libc-test
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4be93bb
)
fix pthread-robust-detach test
author
Szabolcs Nagy
<nsz@port70.net>
Thu, 18 Jun 2015 21:44:44 +0000
(21:44 +0000)
committer
Szabolcs Nagy
<nsz@port70.net>
Thu, 18 Jun 2015 21:44:44 +0000
(21:44 +0000)
src/regression/pthread-robust-detach.c
patch
|
blob
|
history
diff --git
a/src/regression/pthread-robust-detach.c
b/src/regression/pthread-robust-detach.c
index
dbf75a2
..
9c2c3bf
100644
(file)
--- a/
src/regression/pthread-robust-detach.c
+++ b/
src/regression/pthread-robust-detach.c
@@
-3,6
+3,7
@@
#include <pthread.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include <string.h>
#include <errno.h>
+#include <time.h>
#include "test.h"
#define TX(r,f,x) ( ((r)=(f))==x || (t_error(#f" failed: got %d \"%s\" want %d \"%s\"\n", r, strerror(r), x, strerror(x)), 0) )
#include "test.h"
#define TX(r,f,x) ( ((r)=(f))==x || (t_error(#f" failed: got %d \"%s\" want %d \"%s\"\n", r, strerror(r), x, strerror(x)), 0) )
@@
-23,6
+24,7
@@
int main(void)
int r;
pthread_mutexattr_t mtx_a;
pthread_mutex_t mtx;
int r;
pthread_mutexattr_t mtx_a;
pthread_mutex_t mtx;
+ struct timespec ts;
T(r, pthread_barrier_init(&barrier2, 0, 2));
T(r, pthread_mutexattr_init(&mtx_a));
T(r, pthread_barrier_init(&barrier2, 0, 2));
T(r, pthread_mutexattr_init(&mtx_a));
@@
-32,6
+34,15
@@
int main(void)
T(r, pthread_create(&td, 0, start_lock, &mtx));
T(r, pthread_detach(td));
pthread_barrier_wait(&barrier2);
T(r, pthread_create(&td, 0, start_lock, &mtx));
T(r, pthread_detach(td));
pthread_barrier_wait(&barrier2);
- TX(r, pthread_mutex_trylock(&mtx), EOWNERDEAD);
+
+ // enough time to ensure that the other thread is dead
+ clock_gettime(CLOCK_REALTIME, &ts);
+ ts.tv_nsec += 100*1000*1000;
+ if (ts.tv_nsec >= 1000*1000*1000) {
+ ts.tv_sec++;
+ ts.tv_nsec -= 1000*1000*1000;
+ }
+
+ TX(r, pthread_mutex_timedlock(&mtx, &ts), EOWNERDEAD);
return t_status;
}
return t_status;
}