diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-09-25 04:26:40 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-09-25 04:26:40 +0000 |
commit | b9b7f896c0989ace786c4764b1af88925c7291ec (patch) | |
tree | 2bcadd6fe6334c8cc80e05117061eeaa08e57ff4 /tools/regression/pthread/unwind/sem_wait_cancel.cpp | |
parent | 2aedc66f1220dcc147eceb6cfe800aea0d722adf (diff) | |
download | FreeBSD-src-b9b7f896c0989ace786c4764b1af88925c7291ec.zip FreeBSD-src-b9b7f896c0989ace786c4764b1af88925c7291ec.tar.gz |
Add test cases for stack unwinding.
Diffstat (limited to 'tools/regression/pthread/unwind/sem_wait_cancel.cpp')
-rw-r--r-- | tools/regression/pthread/unwind/sem_wait_cancel.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/regression/pthread/unwind/sem_wait_cancel.cpp b/tools/regression/pthread/unwind/sem_wait_cancel.cpp new file mode 100644 index 0000000..019164c --- /dev/null +++ b/tools/regression/pthread/unwind/sem_wait_cancel.cpp @@ -0,0 +1,35 @@ +/* $FreeBSD$ */ +/* Test stack unwinding for libc's sem */ + +#include <pthread.h> +#include <stdio.h> +#include <semaphore.h> +#include <unistd.h> + +#include "Test.cpp" + +sem_t sem; + +void * +thr(void *arg) +{ + Test t; + + sem_wait(&sem); + printf("Bug, thread shouldn't be here.\n"); + return (0); +} + +int +main() +{ + pthread_t td; + + sem_init(&sem, 0, 0); + pthread_create(&td, NULL, thr, NULL); + sleep(1); + pthread_cancel(td); + pthread_join(td, NULL); + check_destruct(); + return (0); +} |