@@ -47,7 +47,9 @@ - (void)testRetrievesThreadMetadata
4747 SENTRY_PROF_LOG_ERROR_RETURN (pthread_setschedparam (thread, policy, ¶m));
4848 }
4949
50- std::this_thread::sleep_for (std::chrono::seconds (1 ));
50+ // give the other thread a little time to spawn, otherwise its name comes back as an empty
51+ // string and the isSentryOwnedThreadName check will fail
52+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
5153
5254 const auto cache = std::make_shared<ThreadMetadataCache>();
5355 ThreadHandle handle (pthread_mach_thread_np (thread));
@@ -72,7 +74,9 @@ - (void)testReturnsCachedThreadMetadata
7274 SENTRY_PROF_LOG_ERROR_RETURN (pthread_setschedparam (thread, policy, ¶m));
7375 }
7476
75- std::this_thread::sleep_for (std::chrono::seconds (1 ));
77+ // give the other thread a little time to spawn, otherwise its metadata doesn't come back as
78+ // expected
79+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
7680
7781 const auto cache = std::make_shared<ThreadMetadataCache>();
7882 ThreadHandle handle (pthread_mach_thread_np (thread));
@@ -94,11 +98,13 @@ - (void)testIgnoresSentryOwnedThreads
9498 char name[] = " io.sentry.SentryThreadMetadataCacheTests" ;
9599 XCTAssertEqual (pthread_create (&thread, nullptr , threadSpin, reinterpret_cast <void *>(name)), 0 );
96100
97- std::this_thread::sleep_for (std::chrono::seconds (1 ));
101+ // give the other thread a little time to spawn, otherwise its name comes back as an empty
102+ // string and the isSentryOwnedThreadName check will fail
103+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
98104
99105 const auto cache = std::make_shared<ThreadMetadataCache>();
100106 ThreadHandle handle (pthread_mach_thread_np (thread));
101- XCTAssertEqual (cache->metadataForThread (handle).threadID , static_cast < unsigned long long >( 0 ) );
107+ XCTAssertEqual (cache->metadataForThread (handle).threadID , 0ULL );
102108
103109 XCTAssertEqual (pthread_cancel (thread), 0 );
104110 XCTAssertEqual (pthread_join (thread, nullptr ), 0 );
@@ -120,7 +126,7 @@ - (void)testNonexistentQueueAddressReturnsNoMetadata
120126 const auto cache = std::make_shared<ThreadMetadataCache>();
121127 const auto metadata = cache->metadataForQueue (0 );
122128
123- XCTAssertEqual (metadata.address , static_cast < unsigned long long >( 0 ) );
129+ XCTAssertEqual (metadata.address , 0ULL );
124130 XCTAssertEqual (metadata.label , nullptr );
125131}
126132
0 commit comments