All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/tcg/multiarch/testthread.c: Add pthread_cancel test
@ 2021-01-12 18:33 Taylor Simpson
  2021-01-12 18:54 ` no-reply
  2021-01-12 20:22 ` Alex Bennée
  0 siblings, 2 replies; 3+ messages in thread
From: Taylor Simpson @ 2021-01-12 18:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: tsimpson, alex.bennee

---
 tests/tcg/multiarch/testthread.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/tcg/multiarch/testthread.c b/tests/tcg/multiarch/testthread.c
index 810ba5d..b30b4b5 100644
--- a/tests/tcg/multiarch/testthread.c
+++ b/tests/tcg/multiarch/testthread.c
@@ -50,8 +50,29 @@ 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);
+    }
+}
+
 int main(int argc, char **argv)
 {
     test_pthread();
+    test_cancel();
     return 0;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-12 20:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-12 18:33 [PATCH] tests/tcg/multiarch/testthread.c: Add pthread_cancel test Taylor Simpson
2021-01-12 18:54 ` no-reply
2021-01-12 20:22 ` Alex Bennée

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.