]> git.saurik.com Git - apple/xnu.git/blob - tools/tests/darwintests/stackshot.m
xnu-4570.61.1.tar.gz
[apple/xnu.git] / tools / tests / darwintests / stackshot.m
1 #include <darwintest.h>
2 #include <darwintest_utils.h>
3 #include <kern/debug.h>
4 #include <kern/kern_cdata.h>
5 #include <kdd.h>
6 #include <libproc.h>
7 #include <sys/syscall.h>
8 #include <sys/stackshot.h>
9
10 T_GLOBAL_META(
11 T_META_NAMESPACE("xnu.stackshot"),
12 T_META_CHECK_LEAKS(false),
13 T_META_ASROOT(true)
14 );
15
16 static const char *current_process_name(void);
17 static void parse_stackshot(bool delta, void *ssbuf, size_t sslen);
18 static void parse_thread_group_stackshot(void **sbuf, size_t sslen);
19 static uint64_t stackshot_timestamp(void *ssbuf, size_t sslen);
20 static void initialize_thread(void);
21
22 #define DEFAULT_STACKSHOT_BUFFER_SIZE (1024 * 1024)
23 #define MAX_STACKSHOT_BUFFER_SIZE (6 * 1024 * 1024)
24
25 T_DECL(microstackshots, "test the microstackshot syscall")
26 {
27 void *buf = NULL;
28 unsigned int size = DEFAULT_STACKSHOT_BUFFER_SIZE;
29
30 while (1) {
31 buf = malloc(size);
32 T_QUIET; T_ASSERT_NOTNULL(buf, "allocated stackshot buffer");
33
34 #pragma clang diagnostic push
35 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
36 int len = syscall(SYS_microstackshot, buf, size,
37 STACKSHOT_GET_MICROSTACKSHOT);
38 #pragma clang diagnostic pop
39 if (len == ENOSYS) {
40 T_SKIP("microstackshot syscall failed, likely not compiled with CONFIG_TELEMETRY");
41 }
42 if (len == -1 && errno == ENOSPC) {
43 /* syscall failed because buffer wasn't large enough, try again */
44 free(buf);
45 buf = NULL;
46 size *= 2;
47 T_ASSERT_LE(size, (unsigned int)MAX_STACKSHOT_BUFFER_SIZE,
48 "growing stackshot buffer to sane size");
49 continue;
50 }
51 T_ASSERT_POSIX_SUCCESS(len, "called microstackshot syscall");
52 break;
53 }
54
55 T_EXPECT_EQ(*(uint32_t *)buf,
56 (uint32_t)STACKSHOT_MICRO_SNAPSHOT_MAGIC,
57 "magic value for microstackshot matches");
58
59 free(buf);
60 }
61
62 struct scenario {
63 uint32_t flags;
64 bool should_fail;
65 pid_t target_pid;
66 uint64_t since_timestamp;
67 uint32_t size_hint;
68 dt_stat_time_t timer;
69 };
70
71 static void
72 quiet(struct scenario *scenario)
73 {
74 if (scenario->timer) {
75 T_QUIET;
76 }
77 }
78
79 static void
80 take_stackshot(struct scenario *scenario, void (^cb)(void *buf, size_t size))
81 {
82 void *config = stackshot_config_create();
83 quiet(scenario);
84 T_ASSERT_NOTNULL(config, "created stackshot config");
85
86 int ret = stackshot_config_set_flags(config, scenario->flags);
87 quiet(scenario);
88 T_ASSERT_POSIX_ZERO(ret, "set flags %#x on stackshot config", scenario->flags);
89
90 if (scenario->size_hint > 0) {
91 ret = stackshot_config_set_size_hint(config, scenario->size_hint);
92 quiet(scenario);
93 T_ASSERT_POSIX_ZERO(ret, "set size hint %" PRIu32 " on stackshot config",
94 scenario->size_hint);
95 }
96
97 if (scenario->target_pid > 0) {
98 ret = stackshot_config_set_pid(config, scenario->target_pid);
99 quiet(scenario);
100 T_ASSERT_POSIX_ZERO(ret, "set target pid %d on stackshot config",
101 scenario->target_pid);
102 }
103
104 if (scenario->since_timestamp > 0) {
105 ret = stackshot_config_set_delta_timestamp(config, scenario->since_timestamp);
106 quiet(scenario);
107 T_ASSERT_POSIX_ZERO(ret, "set since timestamp %" PRIu64 " on stackshot config",
108 scenario->since_timestamp);
109 }
110
111 int retries_remaining = 5;
112
113 retry: ;
114 uint64_t start_time = mach_absolute_time();
115 ret = stackshot_capture_with_config(config);
116 uint64_t end_time = mach_absolute_time();
117
118 if (scenario->should_fail) {
119 T_EXPECTFAIL;
120 T_ASSERT_POSIX_ZERO(ret, "called stackshot_capture_with_config");
121 return;
122 }
123
124 if (ret == EBUSY || ret == ETIMEDOUT) {
125 if (retries_remaining > 0) {
126 if (!scenario->timer) {
127 T_LOG("stackshot_capture_with_config failed with %s (%d), retrying",
128 strerror(ret), ret);
129 }
130
131 retries_remaining--;
132 goto retry;
133 } else {
134 T_ASSERT_POSIX_ZERO(ret,
135 "called stackshot_capture_with_config (no retries remaining)");
136 }
137 } else {
138 quiet(scenario);
139 T_ASSERT_POSIX_ZERO(ret, "called stackshot_capture_with_config");
140 }
141
142 if (scenario->timer) {
143 dt_stat_mach_time_add(scenario->timer, end_time - start_time);
144 }
145 cb(stackshot_config_get_stackshot_buffer(config), stackshot_config_get_stackshot_size(config));
146
147 ret = stackshot_config_dealloc(config);
148 T_QUIET; T_EXPECT_POSIX_ZERO(ret, "deallocated stackshot config");
149 }
150
151 T_DECL(kcdata, "test that kcdata stackshots can be taken and parsed")
152 {
153 struct scenario scenario = {
154 .flags = (STACKSHOT_SAVE_LOADINFO | STACKSHOT_GET_GLOBAL_MEM_STATS |
155 STACKSHOT_SAVE_IMP_DONATION_PIDS | STACKSHOT_KCDATA_FORMAT)
156 };
157
158 initialize_thread();
159 T_LOG("taking kcdata stackshot");
160 take_stackshot(&scenario, ^(void *ssbuf, size_t sslen) {
161 parse_stackshot(false, ssbuf, sslen);
162 });
163 }
164
165 T_DECL(kcdata_faulting, "test that kcdata stackshots while faulting can be taken and parsed")
166 {
167 struct scenario scenario = {
168 .flags = (STACKSHOT_SAVE_LOADINFO | STACKSHOT_GET_GLOBAL_MEM_STATS
169 | STACKSHOT_SAVE_IMP_DONATION_PIDS | STACKSHOT_KCDATA_FORMAT
170 | STACKSHOT_ENABLE_BT_FAULTING | STACKSHOT_ENABLE_UUID_FAULTING),
171 };
172
173 initialize_thread();
174 T_LOG("taking faulting stackshot");
175 take_stackshot(&scenario, ^(void *ssbuf, size_t sslen) {
176 parse_stackshot(false, ssbuf, sslen);
177 });
178 }
179
180 T_DECL(bad_flags, "test a poorly-formed stackshot syscall")
181 {
182 struct scenario scenario = {
183 .flags = STACKSHOT_SAVE_IN_KERNEL_BUFFER /* not allowed from user space */,
184 .should_fail = true
185 };
186
187 T_LOG("attempting to take stackshot with kernel-only flag");
188 take_stackshot(&scenario, ^(__unused void *ssbuf, __unused size_t sslen) {
189 T_ASSERT_FAIL("stackshot data callback called");
190 });
191 }
192
193 T_DECL(delta, "test delta stackshots")
194 {
195 struct scenario scenario = {
196 .flags = (STACKSHOT_SAVE_LOADINFO | STACKSHOT_GET_GLOBAL_MEM_STATS
197 | STACKSHOT_SAVE_IMP_DONATION_PIDS | STACKSHOT_KCDATA_FORMAT)
198 };
199
200 initialize_thread();
201 T_LOG("taking full stackshot");
202 take_stackshot(&scenario, ^(void *ssbuf, size_t sslen) {
203 uint64_t stackshot_time = stackshot_timestamp(ssbuf, sslen);
204
205 T_LOG("taking delta stackshot since time %" PRIu64, stackshot_time);
206
207 parse_stackshot(false, ssbuf, sslen);
208
209 struct scenario delta_scenario = {
210 .flags = (STACKSHOT_SAVE_LOADINFO | STACKSHOT_GET_GLOBAL_MEM_STATS
211 | STACKSHOT_SAVE_IMP_DONATION_PIDS | STACKSHOT_KCDATA_FORMAT
212 | STACKSHOT_COLLECT_DELTA_SNAPSHOT),
213 .since_timestamp = stackshot_time
214 };
215
216 take_stackshot(&delta_scenario, ^(void *dssbuf, size_t dsslen) {
217 parse_stackshot(true, dssbuf, dsslen);
218 });
219 });
220 }
221
222 static void
223 expect_instrs_cycles_in_stackshot(void *ssbuf, size_t sslen)
224 {
225 kcdata_iter_t iter = kcdata_iter(ssbuf, sslen);
226
227 bool in_task = false;
228 bool in_thread = false;
229 bool saw_instrs_cycles = false;
230 iter = kcdata_iter_next(iter);
231
232 KCDATA_ITER_FOREACH(iter) {
233 switch (kcdata_iter_type(iter)) {
234 case KCDATA_TYPE_CONTAINER_BEGIN:
235 switch (kcdata_iter_container_type(iter)) {
236 case STACKSHOT_KCCONTAINER_TASK:
237 in_task = true;
238 saw_instrs_cycles = false;
239 break;
240
241 case STACKSHOT_KCCONTAINER_THREAD:
242 in_thread = true;
243 saw_instrs_cycles = false;
244 break;
245
246 default:
247 break;
248 }
249 break;
250
251 case STACKSHOT_KCTYPE_INSTRS_CYCLES:
252 saw_instrs_cycles = true;
253 break;
254
255 case KCDATA_TYPE_CONTAINER_END:
256 if (in_thread) {
257 T_QUIET; T_EXPECT_TRUE(saw_instrs_cycles, "saw instructions and cycles in thread");
258 in_thread = false;
259 } else if (in_task) {
260 T_QUIET; T_EXPECT_TRUE(saw_instrs_cycles, "saw instructions and cycles in task");
261 in_task = false;
262 }
263
264 default:
265 break;
266 }
267 }
268 }
269
270 static void
271 skip_if_monotonic_unsupported(void)
272 {
273 int supported = 0;
274 size_t supported_size = sizeof(supported);
275 int ret = sysctlbyname("kern.monotonic.supported", &supported, &supported_size, 0, 0);
276 if (ret < 0 || !supported) {
277 T_SKIP("monotonic is unsupported");
278 }
279 }
280
281 T_DECL(instrs_cycles, "test a getting instructions and cycles in stackshot")
282 {
283 skip_if_monotonic_unsupported();
284
285 struct scenario scenario = {
286 .flags = (STACKSHOT_SAVE_LOADINFO | STACKSHOT_INSTRS_CYCLES
287 | STACKSHOT_KCDATA_FORMAT)
288 };
289
290 T_LOG("attempting to take stackshot with instructions and cycles");
291 take_stackshot(&scenario, ^(void *ssbuf, size_t sslen) {
292 parse_stackshot(false, ssbuf, sslen);
293 expect_instrs_cycles_in_stackshot(ssbuf, sslen);
294 });
295 }
296
297 T_DECL(delta_instrs_cycles, "test delta stackshots with instructions and cycles")
298 {
299 skip_if_monotonic_unsupported();
300
301 struct scenario scenario = {
302 .flags = (STACKSHOT_SAVE_LOADINFO | STACKSHOT_INSTRS_CYCLES
303 | STACKSHOT_KCDATA_FORMAT)
304 };
305
306 initialize_thread();
307 T_LOG("taking full stackshot");
308 take_stackshot(&scenario, ^(void *ssbuf, size_t sslen) {
309 uint64_t stackshot_time = stackshot_timestamp(ssbuf, sslen);
310
311 T_LOG("taking delta stackshot since time %" PRIu64, stackshot_time);
312
313 parse_stackshot(false, ssbuf, sslen);
314 expect_instrs_cycles_in_stackshot(ssbuf, sslen);
315
316 struct scenario delta_scenario = {
317 .flags = (STACKSHOT_SAVE_LOADINFO | STACKSHOT_INSTRS_CYCLES
318 | STACKSHOT_KCDATA_FORMAT
319 | STACKSHOT_COLLECT_DELTA_SNAPSHOT),
320 .since_timestamp = stackshot_time
321 };
322
323 take_stackshot(&delta_scenario, ^(void *dssbuf, size_t dsslen) {
324 parse_stackshot(true, dssbuf, dsslen);
325 expect_instrs_cycles_in_stackshot(dssbuf, dsslen);
326 });
327 });
328 }
329
330 static void
331 check_thread_groups_supported()
332 {
333 int err;
334 int supported = 0;
335 size_t supported_size = sizeof(supported);
336 err = sysctlbyname("kern.thread_groups_supported", &supported, &supported_size, NULL, 0);
337
338 if (err || !supported)
339 T_SKIP("thread groups not supported on this system");
340 }
341
342 T_DECL(thread_groups, "test getting thread groups in stackshot")
343 {
344 check_thread_groups_supported();
345
346 struct scenario scenario = {
347 .flags = (STACKSHOT_SAVE_LOADINFO | STACKSHOT_THREAD_GROUP
348 | STACKSHOT_KCDATA_FORMAT)
349 };
350
351 T_LOG("attempting to take stackshot with thread group flag");
352 take_stackshot(&scenario, ^(void *ssbuf, size_t sslen) {
353 parse_thread_group_stackshot(ssbuf, sslen);
354 });
355
356 }
357
358 #pragma mark performance tests
359
360 #define SHOULD_REUSE_SIZE_HINT 0x01
361 #define SHOULD_USE_DELTA 0x02
362 #define SHOULD_TARGET_SELF 0x04
363
364 static void
365 stackshot_perf(unsigned int options)
366 {
367 struct scenario scenario = {
368 .flags = (STACKSHOT_SAVE_LOADINFO | STACKSHOT_GET_GLOBAL_MEM_STATS
369 | STACKSHOT_SAVE_IMP_DONATION_PIDS | STACKSHOT_KCDATA_FORMAT),
370 };
371
372 dt_stat_t size = dt_stat_create("bytes", "size");
373 dt_stat_time_t duration = dt_stat_time_create("duration");
374 scenario.timer = duration;
375
376 if (options & SHOULD_TARGET_SELF) {
377 scenario.target_pid = getpid();
378 }
379
380 while (!dt_stat_stable(duration) || !dt_stat_stable(size)) {
381 __block uint64_t last_time = 0;
382 __block uint32_t size_hint = 0;
383 take_stackshot(&scenario, ^(void *ssbuf, size_t sslen) {
384 dt_stat_add(size, (double)sslen);
385 last_time = stackshot_timestamp(ssbuf, sslen);
386 size_hint = (uint32_t)sslen;
387 });
388 if (options & SHOULD_USE_DELTA) {
389 scenario.since_timestamp = last_time;
390 scenario.flags |= STACKSHOT_COLLECT_DELTA_SNAPSHOT;
391 }
392 if (options & SHOULD_REUSE_SIZE_HINT) {
393 scenario.size_hint = size_hint;
394 }
395 }
396
397 dt_stat_finalize(duration);
398 dt_stat_finalize(size);
399 }
400
401 T_DECL(perf_no_size_hint, "test stackshot performance with no size hint")
402 {
403 stackshot_perf(0);
404 }
405
406 T_DECL(perf_size_hint, "test stackshot performance with size hint")
407 {
408 stackshot_perf(SHOULD_REUSE_SIZE_HINT);
409 }
410
411 T_DECL(perf_process, "test stackshot performance targeted at process")
412 {
413 stackshot_perf(SHOULD_REUSE_SIZE_HINT | SHOULD_TARGET_SELF);
414 }
415
416 T_DECL(perf_delta, "test delta stackshot performance")
417 {
418 stackshot_perf(SHOULD_REUSE_SIZE_HINT | SHOULD_USE_DELTA);
419 }
420
421 T_DECL(perf_delta_process, "test delta stackshot performance targeted at a process")
422 {
423 stackshot_perf(SHOULD_REUSE_SIZE_HINT | SHOULD_USE_DELTA | SHOULD_TARGET_SELF);
424 }
425
426 static uint64_t
427 stackshot_timestamp(void *ssbuf, size_t sslen)
428 {
429 kcdata_iter_t iter = kcdata_iter(ssbuf, sslen);
430
431 uint32_t type = kcdata_iter_type(iter);
432 if (type != KCDATA_BUFFER_BEGIN_STACKSHOT && type != KCDATA_BUFFER_BEGIN_DELTA_STACKSHOT) {
433 T_ASSERT_FAIL("invalid kcdata type %u", kcdata_iter_type(iter));
434 }
435
436 iter = kcdata_iter_find_type(iter, KCDATA_TYPE_MACH_ABSOLUTE_TIME);
437 T_QUIET;
438 T_ASSERT_TRUE(kcdata_iter_valid(iter), "timestamp found in stackshot");
439
440 return *(uint64_t *)kcdata_iter_payload(iter);
441 }
442
443 #define TEST_THREAD_NAME "stackshot_test_thread"
444
445 static void
446 parse_thread_group_stackshot(void **ssbuf, size_t sslen)
447 {
448 bool seen_thread_group_snapshot = false;
449 kcdata_iter_t iter = kcdata_iter(ssbuf, sslen);
450 T_ASSERT_EQ(kcdata_iter_type(iter), KCDATA_BUFFER_BEGIN_STACKSHOT,
451 "buffer provided is a stackshot");
452
453 NSMutableSet *thread_groups = [[NSMutableSet alloc] init];
454
455 iter = kcdata_iter_next(iter);
456 KCDATA_ITER_FOREACH(iter) {
457 switch (kcdata_iter_type(iter)) {
458 case KCDATA_TYPE_ARRAY: {
459 T_QUIET;
460 T_ASSERT_TRUE(kcdata_iter_array_valid(iter),
461 "checked that array is valid");
462
463 if (kcdata_iter_array_elem_type(iter) != STACKSHOT_KCTYPE_THREAD_GROUP_SNAPSHOT) {
464 continue;
465 }
466
467 seen_thread_group_snapshot = true;
468
469 if (kcdata_iter_array_elem_size(iter) >= sizeof(struct thread_group_snapshot_v2)) {
470 struct thread_group_snapshot_v2 *tgs_array = kcdata_iter_payload(iter);
471 for (uint32_t j = 0; j < kcdata_iter_array_elem_count(iter); j++) {
472 struct thread_group_snapshot_v2 *tgs = tgs_array + j;
473 [thread_groups addObject:@(tgs->tgs_id)];
474 }
475
476 }
477 else {
478 struct thread_group_snapshot *tgs_array = kcdata_iter_payload(iter);
479 for (uint32_t j = 0; j < kcdata_iter_array_elem_count(iter); j++) {
480 struct thread_group_snapshot *tgs = tgs_array + j;
481 [thread_groups addObject:@(tgs->tgs_id)];
482 }
483 }
484 break;
485 }
486 }
487 }
488 KCDATA_ITER_FOREACH(iter) {
489 NSError *error = nil;
490
491 switch (kcdata_iter_type(iter)) {
492
493 case KCDATA_TYPE_CONTAINER_BEGIN: {
494 T_QUIET;
495 T_ASSERT_TRUE(kcdata_iter_container_valid(iter),
496 "checked that container is valid");
497
498 NSDictionary *container = parseKCDataContainer(&iter, &error);
499 T_QUIET; T_ASSERT_NOTNULL(container, "parsed container from stackshot");
500 T_QUIET; T_ASSERT_NULL(error, "error unset after parsing container");
501
502 if (kcdata_iter_container_type(iter) != STACKSHOT_KCCONTAINER_THREAD) {
503 break;
504 }
505
506 int tg = [container[@"thread_snapshots"][@"thread_group"] intValue];
507
508 T_ASSERT_TRUE([thread_groups containsObject:@(tg)], "check that the thread group the thread is in exists");
509
510 break;
511 };
512
513 }
514 }
515 T_ASSERT_TRUE(seen_thread_group_snapshot, "check that we have seen a thread group snapshot");
516 }
517
518 static void
519 parse_stackshot(bool delta, void *ssbuf, size_t sslen)
520 {
521 kcdata_iter_t iter = kcdata_iter(ssbuf, sslen);
522 if (delta) {
523 T_ASSERT_EQ(kcdata_iter_type(iter), KCDATA_BUFFER_BEGIN_DELTA_STACKSHOT,
524 "buffer provided is a delta stackshot");
525 } else {
526 T_ASSERT_EQ(kcdata_iter_type(iter), KCDATA_BUFFER_BEGIN_STACKSHOT,
527 "buffer provided is a stackshot");
528 }
529
530 iter = kcdata_iter_next(iter);
531 KCDATA_ITER_FOREACH(iter) {
532 NSError *error = nil;
533
534 switch (kcdata_iter_type(iter)) {
535 case KCDATA_TYPE_ARRAY: {
536 T_QUIET;
537 T_ASSERT_TRUE(kcdata_iter_array_valid(iter),
538 "checked that array is valid");
539
540 NSMutableDictionary *array = parseKCDataArray(iter, &error);
541 T_QUIET; T_ASSERT_NOTNULL(array, "parsed array from stackshot");
542 T_QUIET; T_ASSERT_NULL(error, "error unset after parsing array");
543 break;
544 }
545
546 case KCDATA_TYPE_CONTAINER_BEGIN: {
547 T_QUIET;
548 T_ASSERT_TRUE(kcdata_iter_container_valid(iter),
549 "checked that container is valid");
550
551 NSDictionary *container = parseKCDataContainer(&iter, &error);
552 T_QUIET; T_ASSERT_NOTNULL(container, "parsed container from stackshot");
553 T_QUIET; T_ASSERT_NULL(error, "error unset after parsing container");
554
555 if (kcdata_iter_container_type(iter) != STACKSHOT_KCCONTAINER_TASK) {
556 break;
557 }
558 int pid = [container[@"task_snapshots"][@"task_snapshot"][@"ts_pid"] intValue];
559 if (pid != getpid()) {
560 break;
561 }
562
563 T_EXPECT_EQ_STR(current_process_name(),
564 [container[@"task_snapshots"][@"task_snapshot"][@"ts_p_comm"] UTF8String],
565 "current process name matches in stackshot");
566
567 T_QUIET;
568 T_EXPECT_LE(pid, [container[@"task_snapshots"][@"task_snapshot"][@"ts_unique_pid"] intValue],
569 "unique pid is greater than pid");
570
571 bool found_main_thread = 0;
572 for (id thread_key in container[@"task_snapshots"][@"thread_snapshots"]) {
573 NSMutableDictionary *thread = container[@"task_snapshots"][@"thread_snapshots"][thread_key];
574 NSDictionary *thread_snap = thread[@"thread_snapshot"];
575
576 T_QUIET; T_EXPECT_GT([thread_snap[@"ths_thread_id"] intValue], 0,
577 "thread ID of thread in current task is valid");
578 T_QUIET; T_EXPECT_GT([thread_snap[@"ths_total_syscalls"] intValue], 0,
579 "total syscalls of thread in current task is valid");
580 T_QUIET; T_EXPECT_GT([thread_snap[@"ths_base_priority"] intValue], 0,
581 "base priority of thread in current task is valid");
582 T_QUIET; T_EXPECT_GT([thread_snap[@"ths_sched_priority"] intValue], 0,
583 "scheduling priority of thread in current task is valid");
584
585 NSString *pth_name = thread_snap[@"pth_name"];
586 if (pth_name != nil && [pth_name isEqualToString:@TEST_THREAD_NAME]) {
587 found_main_thread = true;
588 }
589 }
590 T_EXPECT_TRUE(found_main_thread, "found main thread for current task in stackshot");
591 break;
592 }
593 }
594 }
595
596 T_ASSERT_FALSE(KCDATA_ITER_FOREACH_FAILED(iter), "successfully iterated kcdata");
597 }
598
599 static const char *
600 current_process_name(void)
601 {
602 static char name[64];
603
604 if (!name[0]) {
605 int ret = proc_name(getpid(), name, sizeof(name));
606 T_QUIET;
607 T_ASSERT_POSIX_ZERO(ret, "proc_pidname failed for current process");
608 }
609
610 return name;
611 }
612
613 static void
614 initialize_thread(void)
615 {
616 int ret = pthread_setname_np(TEST_THREAD_NAME);
617 T_QUIET;
618 T_ASSERT_POSIX_ZERO(ret, "set thread name to %s", TEST_THREAD_NAME);
619 }