Skip to content

Commit

Permalink
Test getting the OS thread name
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Feb 27, 2024
1 parent 8c5e3d5 commit f3546a2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions library/std/src/thread/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ fn test_named_thread_truncation() {
result.unwrap().join().unwrap();
}

#[cfg(any(
target_os = "windows",
target_os = "linux",
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos"
))]
#[test]
fn test_get_os_named_thread() {
use crate::sys::thread::Thread;
let handler = thread::spawn(|| {
let name = c"test me please";
Thread::set_name(name);
assert_eq!(name, Thread::get_name().unwrap().as_c_str());
});
handler.join().unwrap();
}

#[test]
#[should_panic]
fn test_invalid_named_thread() {
Expand Down

0 comments on commit f3546a2

Please sign in to comment.