about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2024-02-27 00:58:18 -0300
committerChris Denton <chris@chrisdenton.dev>2024-02-27 11:28:17 -0300
commitc84ba2306260dced7cb77f9a624b3e447c5d32d0 (patch)
treee55b1d18b9182c32c0f0346a9c0ce1f4c643be97
parent7c41af290f1ef909024304bdc0b73650b24a1b00 (diff)
downloadrust-c84ba2306260dced7cb77f9a624b3e447c5d32d0.tar.gz
rust-c84ba2306260dced7cb77f9a624b3e447c5d32d0.zip
Test getting the OS thread name
-rw-r--r--library/std/src/thread/tests.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs
index 5d6b9e94ee9..efd06c8df6e 100644
--- a/library/std/src/thread/tests.rs
+++ b/library/std/src/thread/tests.rs
@@ -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() {