Fix thread.name/prof_sys_thread_name interaction

When prof_sys_thread_name is true, we don't allow setting the thread name.
Teach the unit test this.
This commit is contained in:
David Goldblatt 2021-03-30 15:20:30 -07:00 committed by Qi Wang
parent 304cdbb132
commit 12cd13cd41

View File

@ -22,7 +22,7 @@ mallctl_thread_name_set_impl(const char *thread_name, const char *func,
int line) {
expect_d_eq(mallctl("thread.prof.name", NULL, NULL,
(void *)&thread_name, sizeof(thread_name)), 0,
"%s():%d: Unexpected mallctl failure reading thread.prof.name",
"%s():%d: Unexpected mallctl failure writing thread.prof.name",
func, line);
mallctl_thread_name_get_impl(thread_name, func, line);
}
@ -33,6 +33,7 @@ TEST_BEGIN(test_prof_thread_name_validation) {
const char *thread_name;
test_skip_if(!config_prof);
test_skip_if(opt_prof_sys_thread_name);
mallctl_thread_name_get("");
mallctl_thread_name_set("hi there");
@ -94,12 +95,13 @@ thd_start(void *varg) {
}
TEST_BEGIN(test_prof_thread_name_threaded) {
test_skip_if(!config_prof);
test_skip_if(opt_prof_sys_thread_name);
thd_t thds[NTHREADS];
unsigned thd_args[NTHREADS];
unsigned i;
test_skip_if(!config_prof);
for (i = 0; i < NTHREADS; i++) {
thd_args[i] = i;
thd_create(&thds[i], thd_start, (void *)&thd_args[i]);