Skip to contentSkip to conversation

tests/tcg/multiarch/testthread.c: Add pthread_cancel test

PATCH Superseded Taylor Simpson 3 participants 3 messages Jan 12, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/tcg/multiarch/testthread.c: Add pthread_cancel test

---
 tests/tcg/multiarch/testthread.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
tests/tcg/multiarch/testthread.c +21 -0
index 810ba5d..b30b4b5 100644
@@ -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;
 }
Signature · 1 line
2.7.4
#1 lore raw
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH] tests/tcg/multiarch/testthread.c: Add pthread_cancel test

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
d62cd1e tests/tcg/multiarch/testthread.c: Add pthread_cancel test

=== OUTPUT BEGIN ===
ERROR: Missing Signed-off-by: line(s)

total: 1 errors, 0 warnings, 29 lines checked

Commit d62cd1e79a06 (tests/tcg/multiarch/testthread.c: Add pthread_cancel test) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#2 lore raw
In reply to Taylor Simpson
Quoted 20 lines · Taylor Simpson
---
 tests/tcg/multiarch/testthread.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
tests/tcg/multiarch/testthread.c +8 -0
index 810ba5d..b30b4b5 100644
@@ -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)
+{

tests/tcg/multiarch/testthread.c void test_pthread(void) · line 70

Quoted 10 lines
tests/tcg/multiarch/testthread.c +10 -0
+    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);
+    }

Aside from the signoff line which I need could you add something like:

      printf("End of pthread cancel test.\n");

just to aid debugging.

Thanks,

Quoted 8 lines
tests/tcg/multiarch/testthread.c +3 -0
+}
+
 int main(int argc, char **argv)
 {
     test_pthread();
+    test_cancel();
     return 0;
 }
Signature · 1 line
Alex Bennée