Fix race at destruction in StunServerTests and reenable them on tsan

Bug: webrtc:2517
Change-Id: I3d4c65f250fe5048def68cbae45b5637a9ce68a1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/275483
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38087}
This commit is contained in:
Danil Chapovalov 2022-09-14 17:26:58 +02:00 committed by WebRTC LUCI CQ
parent 664d8a76b4
commit a01e7275c2

View File

@ -33,8 +33,7 @@ const rtc::SocketAddress client_addr("1.2.3.4", 1234);
class StunServerTest : public ::testing::Test { class StunServerTest : public ::testing::Test {
public: public:
StunServerTest() : ss_(new rtc::VirtualSocketServer()), network_(ss_.get()) {} StunServerTest() : ss_(new rtc::VirtualSocketServer()), network_(ss_.get()) {
virtual void SetUp() {
server_.reset( server_.reset(
new StunServer(rtc::AsyncUDPSocket::Create(ss_.get(), server_addr))); new StunServer(rtc::AsyncUDPSocket::Create(ss_.get(), server_addr)));
client_.reset(new rtc::TestClient( client_.reset(new rtc::TestClient(
@ -42,6 +41,8 @@ class StunServerTest : public ::testing::Test {
network_.Start(); network_.Start();
} }
~StunServerTest() override { network_.Stop(); }
void Send(const StunMessage& msg) { void Send(const StunMessage& msg) {
rtc::ByteBufferWriter buf; rtc::ByteBufferWriter buf;
msg.Write(&buf); msg.Write(&buf);
@ -71,10 +72,6 @@ class StunServerTest : public ::testing::Test {
std::unique_ptr<rtc::TestClient> client_; std::unique_ptr<rtc::TestClient> client_;
}; };
// Disable for TSan v2, see
// https://code.google.com/p/webrtc/issues/detail?id=2517 for details.
#if !defined(THREAD_SANITIZER)
TEST_F(StunServerTest, TestGood) { TEST_F(StunServerTest, TestGood) {
// kStunLegacyTransactionIdLength = 16 for legacy RFC 3489 request // kStunLegacyTransactionIdLength = 16 for legacy RFC 3489 request
std::string transaction_id = "0123456789abcdef"; std::string transaction_id = "0123456789abcdef";
@ -135,8 +132,6 @@ TEST_F(StunServerTest, TestNoXorMappedAddr) {
delete msg; delete msg;
} }
#endif // if !defined(THREAD_SANITIZER)
TEST_F(StunServerTest, TestBad) { TEST_F(StunServerTest, TestBad) {
const char* bad = const char* bad =
"this is a completely nonsensical message whose only " "this is a completely nonsensical message whose only "