[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] tests/tcg/multiarch/testthread.c: Add pthread_cancel test
From: |
Taylor Simpson |
Subject: |
[PATCH v2] tests/tcg/multiarch/testthread.c: Add pthread_cancel test |
Date: |
Tue, 12 Jan 2021 15:25:30 -0600 |
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
---
tests/tcg/multiarch/testthread.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tests/tcg/multiarch/testthread.c b/tests/tcg/multiarch/testthread.c
index 810ba5d..0da1f61 100644
--- a/tests/tcg/multiarch/testthread.c
+++ b/tests/tcg/multiarch/testthread.c
@@ -50,8 +50,30 @@ void test_pthread(void)
printf("End of pthread test.\n");
}
+void *thread3_func(void *arg)
+{
+ usleep(3 * 1000);
+ return 0;
+}
+
+void test_cancel(void)
+{
+ pthread_t thread;
+ void *res;
+
+ pthread_create(&thread, 0, thread3_func, NULL);
+ pthread_cancel(thread);
+ pthread_join(thread, &res);
+ if (res != PTHREAD_CANCELED) {
+ puts("ERROR: thread not cancelled");
+ exit(EXIT_FAILURE);
+ }
+ printf("End of pthread_cancel test.\n");
+}
+
int main(int argc, char **argv)
{
test_pthread();
+ test_cancel();
return 0;
}
--
2.7.4
- [PATCH v2] tests/tcg/multiarch/testthread.c: Add pthread_cancel test,
Taylor Simpson <=