From 7791a5b5497b7dad6f500e2db2df4da1d35cacaf Mon Sep 17 00:00:00 2001 From: Ivan Zhakov Date: Mon, 27 Jun 2022 23:13:52 +0000 Subject: On 'thread-name' branch: Add apr_thread_name_get() and apr_thread_name_set() API to get/set thread name. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/thread-name@1902297 13f79535-47bb-0310-9956-ffa450edef68 --- test/testthread.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') diff --git a/test/testthread.c b/test/testthread.c index e64bdd4b7..2f8b1cb5a 100644 --- a/test/testthread.c +++ b/test/testthread.c @@ -107,6 +107,36 @@ static void check_thread_once(abts_case *tc, void *data) ABTS_INT_EQUAL(tc, 1, value); } +static void thread_name(abts_case *tc, void *data) +{ + apr_status_t rv; + char *name; + + rv = apr_thread_name_set("thread-1", NULL, p); + if (rv == APR_ENOTIMPL) { + ABTS_NOT_IMPL(tc, "apr_thread_name_set is not implemented.") + return ; + } + + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + + rv = apr_thread_name_get(&name, NULL, p); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + ABTS_STR_EQUAL(tc, "thread-1", name); + + rv = apr_thread_name_set("thread-1", NULL, p); + if (rv == APR_ENOTIMPL) { + ABTS_NOT_IMPL(tc, "apr_thread_name_set is not implemented.") + return ; + } + + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + + rv = apr_thread_name_get(&name, NULL, p); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + ABTS_STR_EQUAL(tc, "thread-1", name); +} + #else static void threads_not_impl(abts_case *tc, void *data) @@ -128,6 +158,7 @@ abts_suite *testthread(abts_suite *suite) abts_run_test(suite, join_threads, NULL); abts_run_test(suite, check_locks, NULL); abts_run_test(suite, check_thread_once, NULL); + abts_run_test(suite, thread_name, NULL); #endif return suite; -- cgit v1.2.1