Skip to content

Commit c84ba23

Browse files
committed
Test getting the OS thread name
1 parent 7c41af2 commit c84ba23

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

library/std/src/thread/tests.rs

+19
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,25 @@ fn test_named_thread_truncation() {
6969
result.unwrap().join().unwrap();
7070
}
7171

72+
#[cfg(any(
73+
target_os = "windows",
74+
target_os = "linux",
75+
target_os = "macos",
76+
target_os = "ios",
77+
target_os = "tvos",
78+
target_os = "watchos"
79+
))]
80+
#[test]
81+
fn test_get_os_named_thread() {
82+
use crate::sys::thread::Thread;
83+
let handler = thread::spawn(|| {
84+
let name = c"test me please";
85+
Thread::set_name(name);
86+
assert_eq!(name, Thread::get_name().unwrap().as_c_str());
87+
});
88+
handler.join().unwrap();
89+
}
90+
7291
#[test]
7392
#[should_panic]
7493
fn test_invalid_named_thread() {

0 commit comments

Comments
 (0)