PlatformThreadTest: fix flake.
This change aims to fix a flake that could have been caused by threads lingering past the main thread lifetime. Bug: webrtc:12913 Change-Id: I144078b41d59f46398212f48cdd4b0cf3f204bfe Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/224080 Reviewed-by: Markus Handell <handellm@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34371}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
2b3a10e62d
commit
74543b77c6
@ -29,10 +29,12 @@ TEST(PlatformThreadTest, StartFinalize) {
|
|||||||
EXPECT_FALSE(thread.empty());
|
EXPECT_FALSE(thread.empty());
|
||||||
thread.Finalize();
|
thread.Finalize();
|
||||||
EXPECT_TRUE(thread.empty());
|
EXPECT_TRUE(thread.empty());
|
||||||
thread = PlatformThread::SpawnDetached([] {}, "2");
|
rtc::Event done;
|
||||||
|
thread = PlatformThread::SpawnDetached([&] { done.Set(); }, "2");
|
||||||
EXPECT_FALSE(thread.empty());
|
EXPECT_FALSE(thread.empty());
|
||||||
thread.Finalize();
|
thread.Finalize();
|
||||||
EXPECT_TRUE(thread.empty());
|
EXPECT_TRUE(thread.empty());
|
||||||
|
done.Wait(30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PlatformThreadTest, MovesEmpty) {
|
TEST(PlatformThreadTest, MovesEmpty) {
|
||||||
@ -47,10 +49,12 @@ TEST(PlatformThreadTest, MovesHandles) {
|
|||||||
PlatformThread thread2 = std::move(thread1);
|
PlatformThread thread2 = std::move(thread1);
|
||||||
EXPECT_TRUE(thread1.empty());
|
EXPECT_TRUE(thread1.empty());
|
||||||
EXPECT_FALSE(thread2.empty());
|
EXPECT_FALSE(thread2.empty());
|
||||||
thread1 = PlatformThread::SpawnDetached([] {}, "2");
|
rtc::Event done;
|
||||||
|
thread1 = PlatformThread::SpawnDetached([&] { done.Set(); }, "2");
|
||||||
thread2 = std::move(thread1);
|
thread2 = std::move(thread1);
|
||||||
EXPECT_TRUE(thread1.empty());
|
EXPECT_TRUE(thread1.empty());
|
||||||
EXPECT_FALSE(thread2.empty());
|
EXPECT_FALSE(thread2.empty());
|
||||||
|
done.Wait(30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PlatformThreadTest,
|
TEST(PlatformThreadTest,
|
||||||
|
Reference in New Issue
Block a user