[PATCH bpf-next 1/2] selftests/bpf: Add xpthread_cancel() to sockmap_helpers

Michal Luczaj posted 2 patches 2 weeks, 4 days ago
[PATCH bpf-next 1/2] selftests/bpf: Add xpthread_cancel() to sockmap_helpers
Posted by Michal Luczaj 2 weeks, 4 days ago
Thin wrapper reporting failure, in the spirit of xpthread_create() and
xpthread_join().

Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
 tools/testing/selftests/bpf/prog_tests/sockmap_helpers.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_helpers.h b/tools/testing/selftests/bpf/prog_tests/sockmap_helpers.h
index d815efac52fd..209f2e4fb627 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_helpers.h
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_helpers.h
@@ -60,6 +60,15 @@
 		__ret;                                                         \
 	})
 
+#define xpthread_cancel(thread)                                                \
+	({                                                                     \
+		int __ret = pthread_cancel((thread));                          \
+		errno = __ret;                                                 \
+		if (__ret)                                                     \
+			FAIL_ERRNO("pthread_cancel");                          \
+		__ret;                                                         \
+	})
+
 #define xpthread_join(thread, retval)                                          \
 	({                                                                     \
 		int __ret = pthread_join((thread), (retval));                  \

-- 
2.52.0