Reduce flakiness of voe_auto_test MixingTest by checking dumped audio size
BUG=webrtc:2925
TEST=passed_all_trybots
R=andrew@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/18479005
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6193 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/voice_engine/test/auto_test/standard/mixing_test.cc b/webrtc/voice_engine/test/auto_test/standard/mixing_test.cc
index 499f561..eb520b8 100644
--- a/webrtc/voice_engine/test/auto_test/standard/mixing_test.cc
+++ b/webrtc/voice_engine/test/auto_test/standard/mixing_test.cc
@@ -87,6 +87,9 @@
EXPECT_EQ(0, voe_file_->StartRecordingPlayout(-1 /* record meeting */,
output_filename_.c_str()));
SleepMs(kTestDurationMs);
+ while (GetFileDurationMs(output_filename_.c_str()) < kTestDurationMs) {
+ SleepMs(200);
+ }
EXPECT_EQ(0, voe_file_->StopRecordingPlayout(-1));
StopLocalStreams(local_streams);
@@ -126,7 +129,7 @@
// Ensure we've at least recorded half as much file as the duration of the
// test. We have to use a relaxed tolerance here due to filesystem flakiness
// on the bots.
- ASSERT_GE((samples_read * 1000.0) / kSampleRateHz, 0.5 * kTestDurationMs);
+ ASSERT_GE((samples_read * 1000.0) / kSampleRateHz, kTestDurationMs);
// Ensure we read the entire file.
ASSERT_NE(0, feof(output_file));
ASSERT_EQ(0, fclose(output_file));
@@ -199,6 +202,17 @@
}
}
+ int GetFileDurationMs(const char* file_name) {
+ FILE* fid = fopen(file_name, "rb");
+ EXPECT_FALSE(fid == NULL);
+ fseek(fid, 0, SEEK_END);
+ int size = ftell(fid);
+ EXPECT_NE(-1, size);
+ fclose(fid);
+ // Divided by 2 due to 2 bytes/sample.
+ return size * 1000 / kSampleRateHz / 2;
+ }
+
std::string input_filename_;
const std::string output_filename_;
LoopBackTransport* transport_;