From 9e6565b0087a026ba131a13a8d485b552d1a1242 Mon Sep 17 00:00:00 2001 From: Elad Alon Date: Wed, 11 Oct 2017 16:04:13 +0200 Subject: [PATCH] Fix PeerConnectionInterfaceTest_StartAndStopLoggingAfterPeerConnectionClosed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PeerConnectionInterfaceTest_StartAndStopLoggingAfterPeerConnectionClosed was using an invalid file, then checking that StartRtcEventLog returns false. Such a test might return a false positive, since StartRtcEventLog might fail because it was given an invalid file, rather than because the PC was already closed. Bug: webrtc:8111 Change-Id: I844eb3b948b1406bb6f5cc63928eb26f0fb7b694 Reviewed-on: https://webrtc-review.googlesource.com/8541 Reviewed-by: Taylor Brandstetter Reviewed-by: Björn Terelius Commit-Queue: Elad Alon Cr-Commit-Position: refs/heads/master@{#20253} --- pc/peerconnectioninterface_unittest.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pc/peerconnectioninterface_unittest.cc b/pc/peerconnectioninterface_unittest.cc index cc063b4f74..fb38d6541c 100644 --- a/pc/peerconnectioninterface_unittest.cc +++ b/pc/peerconnectioninterface_unittest.cc @@ -43,6 +43,7 @@ #include "rtc_base/stringutils.h" #include "rtc_base/virtualsocketserver.h" #include "test/gmock.h" +#include "test/testsupport/fileutils.h" #ifdef WEBRTC_ANDROID #include "pc/test/androidtestinitializer.h" @@ -3207,10 +3208,19 @@ TEST_F(PeerConnectionInterfaceTest, // The RtcEventLog will be reset when the PeerConnection is closed. pc_->Close(); - rtc::PlatformFile file = 0; - int64_t max_size_bytes = 1024; + auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); + std::string filename = webrtc::test::OutputPath() + + test_info->test_case_name() + test_info->name(); + rtc::PlatformFile file = rtc::CreatePlatformFile(filename); + + constexpr int64_t max_size_bytes = 1024; + EXPECT_FALSE(pc_->StartRtcEventLog(file, max_size_bytes)); pc_->StopRtcEventLog(); + + // Cleanup. + rtc::ClosePlatformFile(file); + rtc::RemoveFile(filename); } // Test that generated offers/answers include "ice-option:trickle".