blob: ee03d3fb019e4ffb7a075175458e00d08da5aee8 [file] [log] [blame]
tkchin93411912015-07-22 12:12:17 -07001/*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Jonas Olssona4d87372019-07-05 19:08:33 +020011#include "rtc_base/file_rotating_stream.h"
12
Yves Gerey3e707812018-11-28 16:47:49 +010013#include <string.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020014
Yves Gerey3e707812018-11-28 16:47:49 +010015#include <cstdint>
jbauch555604a2016-04-26 03:13:22 -070016#include <memory>
17
Ali Tofigh7fa90572022-03-17 15:47:49 +010018#include "absl/strings/string_view.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "rtc_base/arraysize.h"
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "test/gtest.h"
Steve Anton10542f22019-01-11 09:11:00 -080021#include "test/testsupport/file_utils.h"
tkchin93411912015-07-22 12:12:17 -070022
23namespace rtc {
24
nisse57efb032017-05-18 03:55:59 -070025namespace {
26
27void CleanupLogDirectory(const FileRotatingStream& stream) {
28 for (size_t i = 0; i < stream.GetNumFiles(); ++i) {
29 // Ignore return value, not all files are expected to exist.
30 webrtc::test::RemoveFile(stream.GetFilePath(i));
31 }
32}
33
34} // namespace
35
Yves Gerey665174f2018-06-19 15:03:05 +020036#if defined(WEBRTC_ANDROID)
phoglundbb738732016-07-15 03:57:12 -070037// Fails on Android: https://bugs.chromium.org/p/webrtc/issues/detail?id=4364.
38#define MAYBE_FileRotatingStreamTest DISABLED_FileRotatingStreamTest
39#else
40#define MAYBE_FileRotatingStreamTest FileRotatingStreamTest
41#endif
42
43class MAYBE_FileRotatingStreamTest : public ::testing::Test {
tkchin93411912015-07-22 12:12:17 -070044 protected:
45 static const char* kFilePrefix;
46 static const size_t kMaxFileSize;
47
Ali Tofigh7fa90572022-03-17 15:47:49 +010048 void Init(absl::string_view dir_name,
49 absl::string_view file_prefix,
tkchin93411912015-07-22 12:12:17 -070050 size_t max_file_size,
Niels Möller7b3c76b2018-11-07 09:54:28 +010051 size_t num_log_files,
52 bool ensure_trailing_delimiter = true) {
nisse57efb032017-05-18 03:55:59 -070053 dir_path_ = webrtc::test::OutputPath();
54
tkchin93411912015-07-22 12:12:17 -070055 // Append per-test output path in order to run within gtest parallel.
Ali Tofigh7fa90572022-03-17 15:47:49 +010056 dir_path_.append(dir_name.begin(), dir_name.end());
Niels Möller7b3c76b2018-11-07 09:54:28 +010057 if (ensure_trailing_delimiter) {
Ali Tofigh1d6de142022-03-24 19:34:34 +010058 dir_path_.append(std::string(webrtc::test::kPathDelimiter));
Niels Möller7b3c76b2018-11-07 09:54:28 +010059 }
nisse57efb032017-05-18 03:55:59 -070060 ASSERT_TRUE(webrtc::test::CreateDir(dir_path_));
tkchin93411912015-07-22 12:12:17 -070061 stream_.reset(new FileRotatingStream(dir_path_, file_prefix, max_file_size,
62 num_log_files));
63 }
64
65 void TearDown() override {
nisse57efb032017-05-18 03:55:59 -070066 // On windows, open files can't be removed.
67 stream_->Close();
68 CleanupLogDirectory(*stream_);
69 EXPECT_TRUE(webrtc::test::RemoveDir(dir_path_));
70
tkchin93411912015-07-22 12:12:17 -070071 stream_.reset();
tkchin93411912015-07-22 12:12:17 -070072 }
73
74 // Writes the data to the stream and flushes it.
75 void WriteAndFlush(const void* data, const size_t data_len) {
Niels Möllerca81a3c2021-03-29 10:15:14 +020076 EXPECT_TRUE(stream_->Write(data, data_len));
tkchin93411912015-07-22 12:12:17 -070077 EXPECT_TRUE(stream_->Flush());
78 }
79
80 // Checks that the stream reads in the expected contents and then returns an
81 // end of stream result.
82 void VerifyStreamRead(const char* expected_contents,
83 const size_t expected_length,
Ali Tofigh7fa90572022-03-17 15:47:49 +010084 absl::string_view dir_path,
tkchin93411912015-07-22 12:12:17 -070085 const char* file_prefix) {
Niels Möllerd9ac0582019-01-03 14:21:38 +010086 FileRotatingStreamReader reader(dir_path, file_prefix);
87 EXPECT_EQ(reader.GetSize(), expected_length);
Niels Möller6ffe62a2019-01-08 13:22:57 +010088 std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length]);
Niels Möllerd9ac0582019-01-03 14:21:38 +010089 memset(buffer.get(), 0, expected_length);
90 EXPECT_EQ(expected_length, reader.ReadAll(buffer.get(), expected_length));
91 EXPECT_EQ(0, memcmp(expected_contents, buffer.get(), expected_length));
tkchin93411912015-07-22 12:12:17 -070092 }
93
94 void VerifyFileContents(const char* expected_contents,
95 const size_t expected_length,
Ali Tofigh7fa90572022-03-17 15:47:49 +010096 absl::string_view file_path) {
Niels Möller0a7d56e2019-01-10 11:24:07 +010097 std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length + 1]);
Ali Tofigh7fa90572022-03-17 15:47:49 +010098 webrtc::FileWrapper f =
99 webrtc::FileWrapper::OpenReadOnly(std::string(file_path));
Niels Möller23213d92019-01-22 11:01:24 +0100100 ASSERT_TRUE(f.is_open());
101 size_t size_read = f.Read(buffer.get(), expected_length + 1);
Niels Möller6ffe62a2019-01-08 13:22:57 +0100102 EXPECT_EQ(size_read, expected_length);
103 EXPECT_EQ(0, memcmp(expected_contents, buffer.get(),
104 std::min(expected_length, size_read)));
tkchin93411912015-07-22 12:12:17 -0700105 }
106
jbauch555604a2016-04-26 03:13:22 -0700107 std::unique_ptr<FileRotatingStream> stream_;
tkchin93411912015-07-22 12:12:17 -0700108 std::string dir_path_;
109};
110
phoglundbb738732016-07-15 03:57:12 -0700111const char* MAYBE_FileRotatingStreamTest::kFilePrefix =
112 "FileRotatingStreamTest";
113const size_t MAYBE_FileRotatingStreamTest::kMaxFileSize = 2;
tkchin93411912015-07-22 12:12:17 -0700114
115// Tests that stream state is correct before and after Open / Close.
phoglundbb738732016-07-15 03:57:12 -0700116TEST_F(MAYBE_FileRotatingStreamTest, State) {
tkchin93411912015-07-22 12:12:17 -0700117 Init("FileRotatingStreamTestState", kFilePrefix, kMaxFileSize, 3);
118
Niels Möllera9311b62021-03-25 15:29:02 +0100119 EXPECT_FALSE(stream_->IsOpen());
tkchin93411912015-07-22 12:12:17 -0700120 ASSERT_TRUE(stream_->Open());
Niels Möllera9311b62021-03-25 15:29:02 +0100121 EXPECT_TRUE(stream_->IsOpen());
tkchin93411912015-07-22 12:12:17 -0700122 stream_->Close();
Niels Möllera9311b62021-03-25 15:29:02 +0100123 EXPECT_FALSE(stream_->IsOpen());
tkchin93411912015-07-22 12:12:17 -0700124}
125
126// Tests that nothing is written to file when data of length zero is written.
phoglundbb738732016-07-15 03:57:12 -0700127TEST_F(MAYBE_FileRotatingStreamTest, EmptyWrite) {
tkchin93411912015-07-22 12:12:17 -0700128 Init("FileRotatingStreamTestEmptyWrite", kFilePrefix, kMaxFileSize, 3);
129
130 ASSERT_TRUE(stream_->Open());
131 WriteAndFlush("a", 0);
132
133 std::string logfile_path = stream_->GetFilePath(0);
Niels Möller23213d92019-01-22 11:01:24 +0100134 webrtc::FileWrapper f = webrtc::FileWrapper::OpenReadOnly(logfile_path);
135 ASSERT_TRUE(f.is_open());
Niels Möller0a7d56e2019-01-10 11:24:07 +0100136 char buf[1];
Niels Möller23213d92019-01-22 11:01:24 +0100137 EXPECT_EQ(0u, f.Read(buf, sizeof(buf)));
tkchin93411912015-07-22 12:12:17 -0700138}
139
140// Tests that a write operation followed by a read returns the expected data
141// and writes to the expected files.
phoglundbb738732016-07-15 03:57:12 -0700142TEST_F(MAYBE_FileRotatingStreamTest, WriteAndRead) {
tkchin93411912015-07-22 12:12:17 -0700143 Init("FileRotatingStreamTestWriteAndRead", kFilePrefix, kMaxFileSize, 3);
144
145 ASSERT_TRUE(stream_->Open());
146 // The test is set up to create three log files of length 2. Write and check
147 // contents.
148 std::string messages[3] = {"aa", "bb", "cc"};
149 for (size_t i = 0; i < arraysize(messages); ++i) {
150 const std::string& message = messages[i];
151 WriteAndFlush(message.c_str(), message.size());
152 // Since the max log size is 2, we will be causing rotation. Read from the
153 // next file.
154 VerifyFileContents(message.c_str(), message.size(),
155 stream_->GetFilePath(1));
156 }
157 // Check that exactly three files exist.
158 for (size_t i = 0; i < arraysize(messages); ++i) {
Niels Möller260770c2018-11-07 15:08:18 +0100159 EXPECT_TRUE(webrtc::test::FileExists(stream_->GetFilePath(i)));
tkchin93411912015-07-22 12:12:17 -0700160 }
161 std::string message("d");
162 WriteAndFlush(message.c_str(), message.size());
163 for (size_t i = 0; i < arraysize(messages); ++i) {
Niels Möller260770c2018-11-07 15:08:18 +0100164 EXPECT_TRUE(webrtc::test::FileExists(stream_->GetFilePath(i)));
tkchin93411912015-07-22 12:12:17 -0700165 }
166 // TODO(tkchin): Maybe check all the files in the dir.
167
168 // Reopen for read.
169 std::string expected_contents("bbccd");
170 VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
171 dir_path_, kFilePrefix);
172}
173
Niels Möller7b3c76b2018-11-07 09:54:28 +0100174// Tests that a write operation (with dir name without delimiter) followed by a
175// read returns the expected data and writes to the expected files.
176TEST_F(MAYBE_FileRotatingStreamTest, WriteWithoutDelimiterAndRead) {
177 Init("FileRotatingStreamTestWriteWithoutDelimiterAndRead", kFilePrefix,
178 kMaxFileSize, 3,
179 /* ensure_trailing_delimiter*/ false);
180
181 ASSERT_TRUE(stream_->Open());
182 // The test is set up to create three log files of length 2. Write and check
183 // contents.
184 std::string messages[3] = {"aa", "bb", "cc"};
185 for (size_t i = 0; i < arraysize(messages); ++i) {
186 const std::string& message = messages[i];
187 WriteAndFlush(message.c_str(), message.size());
188 }
189 std::string message("d");
190 WriteAndFlush(message.c_str(), message.size());
191
192 // Reopen for read.
193 std::string expected_contents("bbccd");
194 VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
Ali Tofigh1d6de142022-03-24 19:34:34 +0100195 dir_path_ + std::string(webrtc::test::kPathDelimiter),
196 kFilePrefix);
Niels Möller7b3c76b2018-11-07 09:54:28 +0100197}
198
199// Tests that a write operation followed by a read (without trailing delimiter)
200// returns the expected data and writes to the expected files.
201TEST_F(MAYBE_FileRotatingStreamTest, WriteAndReadWithoutDelimiter) {
202 Init("FileRotatingStreamTestWriteAndReadWithoutDelimiter", kFilePrefix,
203 kMaxFileSize, 3);
204
205 ASSERT_TRUE(stream_->Open());
206 // The test is set up to create three log files of length 2. Write and check
207 // contents.
208 std::string messages[3] = {"aa", "bb", "cc"};
209 for (size_t i = 0; i < arraysize(messages); ++i) {
210 const std::string& message = messages[i];
211 WriteAndFlush(message.c_str(), message.size());
212 }
213 std::string message("d");
214 WriteAndFlush(message.c_str(), message.size());
215
216 // Reopen for read.
217 std::string expected_contents("bbccd");
218 VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
219 dir_path_.substr(0, dir_path_.size() - 1), kFilePrefix);
220}
221
tkchin93411912015-07-22 12:12:17 -0700222// Tests that writing data greater than the total capacity of the files
223// overwrites the files correctly and is read correctly after.
phoglundbb738732016-07-15 03:57:12 -0700224TEST_F(MAYBE_FileRotatingStreamTest, WriteOverflowAndRead) {
tkchin93411912015-07-22 12:12:17 -0700225 Init("FileRotatingStreamTestWriteOverflowAndRead", kFilePrefix, kMaxFileSize,
226 3);
227 ASSERT_TRUE(stream_->Open());
228 // This should cause overflow across all three files, such that the first file
229 // we wrote to also gets overwritten.
230 std::string message("foobarbaz");
231 WriteAndFlush(message.c_str(), message.size());
232 std::string expected_file_contents("z");
233 VerifyFileContents(expected_file_contents.c_str(),
234 expected_file_contents.size(), stream_->GetFilePath(0));
235 std::string expected_stream_contents("arbaz");
236 VerifyStreamRead(expected_stream_contents.c_str(),
237 expected_stream_contents.size(), dir_path_, kFilePrefix);
238}
239
240// Tests that the returned file paths have the right folder and prefix.
phoglundbb738732016-07-15 03:57:12 -0700241TEST_F(MAYBE_FileRotatingStreamTest, GetFilePath) {
tkchin93411912015-07-22 12:12:17 -0700242 Init("FileRotatingStreamTestGetFilePath", kFilePrefix, kMaxFileSize, 20);
Niels Möller394b4eb2018-06-01 14:08:25 +0200243 // dir_path_ includes a trailing delimiter.
244 const std::string prefix = dir_path_ + kFilePrefix;
tkchin93411912015-07-22 12:12:17 -0700245 for (auto i = 0; i < 20; ++i) {
Niels Möller394b4eb2018-06-01 14:08:25 +0200246 EXPECT_EQ(0, stream_->GetFilePath(i).compare(0, prefix.size(), prefix));
tkchin93411912015-07-22 12:12:17 -0700247 }
248}
249
Yves Gerey665174f2018-06-19 15:03:05 +0200250#if defined(WEBRTC_ANDROID)
phoglundbb738732016-07-15 03:57:12 -0700251// Fails on Android: https://bugs.chromium.org/p/webrtc/issues/detail?id=4364.
252#define MAYBE_CallSessionFileRotatingStreamTest \
Yves Gerey665174f2018-06-19 15:03:05 +0200253 DISABLED_CallSessionFileRotatingStreamTest
phoglundbb738732016-07-15 03:57:12 -0700254#else
255#define MAYBE_CallSessionFileRotatingStreamTest \
Yves Gerey665174f2018-06-19 15:03:05 +0200256 CallSessionFileRotatingStreamTest
phoglundbb738732016-07-15 03:57:12 -0700257#endif
258
259class MAYBE_CallSessionFileRotatingStreamTest : public ::testing::Test {
tkchin93411912015-07-22 12:12:17 -0700260 protected:
Ali Tofigh7fa90572022-03-17 15:47:49 +0100261 void Init(absl::string_view dir_name, size_t max_total_log_size) {
nisse57efb032017-05-18 03:55:59 -0700262 dir_path_ = webrtc::test::OutputPath();
263
tkchin93411912015-07-22 12:12:17 -0700264 // Append per-test output path in order to run within gtest parallel.
Ali Tofigh7fa90572022-03-17 15:47:49 +0100265 dir_path_.append(dir_name.begin(), dir_name.end());
Ali Tofigh1d6de142022-03-24 19:34:34 +0100266 dir_path_.append(std::string(webrtc::test::kPathDelimiter));
nisse57efb032017-05-18 03:55:59 -0700267 ASSERT_TRUE(webrtc::test::CreateDir(dir_path_));
tkchin93411912015-07-22 12:12:17 -0700268 stream_.reset(
269 new CallSessionFileRotatingStream(dir_path_, max_total_log_size));
270 }
271
Steve Anton9de3aac2017-10-24 10:08:26 -0700272 void TearDown() override {
nisse57efb032017-05-18 03:55:59 -0700273 // On windows, open files can't be removed.
274 stream_->Close();
275 CleanupLogDirectory(*stream_);
276 EXPECT_TRUE(webrtc::test::RemoveDir(dir_path_));
277
tkchin93411912015-07-22 12:12:17 -0700278 stream_.reset();
tkchin93411912015-07-22 12:12:17 -0700279 }
280
281 // Writes the data to the stream and flushes it.
282 void WriteAndFlush(const void* data, const size_t data_len) {
Niels Möllera9311b62021-03-25 15:29:02 +0100283 EXPECT_TRUE(stream_->Write(data, data_len));
tkchin93411912015-07-22 12:12:17 -0700284 EXPECT_TRUE(stream_->Flush());
285 }
286
287 // Checks that the stream reads in the expected contents and then returns an
288 // end of stream result.
289 void VerifyStreamRead(const char* expected_contents,
290 const size_t expected_length,
Ali Tofigh7fa90572022-03-17 15:47:49 +0100291 absl::string_view dir_path) {
Niels Möllerd9ac0582019-01-03 14:21:38 +0100292 CallSessionFileRotatingStreamReader reader(dir_path);
293 EXPECT_EQ(reader.GetSize(), expected_length);
Niels Möller6ffe62a2019-01-08 13:22:57 +0100294 std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length]);
Niels Möllerd9ac0582019-01-03 14:21:38 +0100295 memset(buffer.get(), 0, expected_length);
296 EXPECT_EQ(expected_length, reader.ReadAll(buffer.get(), expected_length));
297 EXPECT_EQ(0, memcmp(expected_contents, buffer.get(), expected_length));
tkchin93411912015-07-22 12:12:17 -0700298 }
299
jbauch555604a2016-04-26 03:13:22 -0700300 std::unique_ptr<CallSessionFileRotatingStream> stream_;
tkchin93411912015-07-22 12:12:17 -0700301 std::string dir_path_;
302};
303
304// Tests that writing and reading to a stream with the smallest possible
305// capacity works.
phoglundbb738732016-07-15 03:57:12 -0700306TEST_F(MAYBE_CallSessionFileRotatingStreamTest, WriteAndReadSmallest) {
tkchin93411912015-07-22 12:12:17 -0700307 Init("CallSessionFileRotatingStreamTestWriteAndReadSmallest", 4);
308
309 ASSERT_TRUE(stream_->Open());
310 std::string message("abcde");
311 WriteAndFlush(message.c_str(), message.size());
312 std::string expected_contents("abe");
313 VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
314 dir_path_);
315}
316
317// Tests that writing and reading to a stream with capacity lesser than 4MB
318// behaves correctly.
phoglundbb738732016-07-15 03:57:12 -0700319TEST_F(MAYBE_CallSessionFileRotatingStreamTest, WriteAndReadSmall) {
tkchin93411912015-07-22 12:12:17 -0700320 Init("CallSessionFileRotatingStreamTestWriteAndReadSmall", 8);
321
322 ASSERT_TRUE(stream_->Open());
323 std::string message("123456789");
324 WriteAndFlush(message.c_str(), message.size());
325 std::string expected_contents("1234789");
326 VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
327 dir_path_);
328}
329
330// Tests that writing and reading to a stream with capacity greater than 4MB
331// behaves correctly.
phoglundbb738732016-07-15 03:57:12 -0700332TEST_F(MAYBE_CallSessionFileRotatingStreamTest, WriteAndReadLarge) {
tkchin93411912015-07-22 12:12:17 -0700333 Init("CallSessionFileRotatingStreamTestWriteAndReadLarge", 6 * 1024 * 1024);
334
335 ASSERT_TRUE(stream_->Open());
336 const size_t buffer_size = 1024 * 1024;
jbauch555604a2016-04-26 03:13:22 -0700337 std::unique_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
tkchin93411912015-07-22 12:12:17 -0700338 for (int i = 0; i < 8; i++) {
339 memset(buffer.get(), i, buffer_size);
Niels Möllerca81a3c2021-03-29 10:15:14 +0200340 EXPECT_TRUE(stream_->Write(buffer.get(), buffer_size));
tkchin93411912015-07-22 12:12:17 -0700341 }
342
Niels Möller6ffe62a2019-01-08 13:22:57 +0100343 const int expected_vals[] = {0, 1, 2, 6, 7};
344 const size_t expected_size = buffer_size * arraysize(expected_vals);
345
346 CallSessionFileRotatingStreamReader reader(dir_path_);
347 EXPECT_EQ(reader.GetSize(), expected_size);
348 std::unique_ptr<uint8_t[]> contents(new uint8_t[expected_size + 1]);
349 EXPECT_EQ(reader.ReadAll(contents.get(), expected_size + 1), expected_size);
tkchin93411912015-07-22 12:12:17 -0700350 for (size_t i = 0; i < arraysize(expected_vals); ++i) {
Niels Möller6ffe62a2019-01-08 13:22:57 +0100351 const uint8_t* block = contents.get() + i * buffer_size;
352 bool match = true;
353 for (size_t j = 0; j < buffer_size; j++) {
354 if (block[j] != expected_vals[i]) {
355 match = false;
356 break;
357 }
358 }
359 // EXPECT call at end of loop, to limit the number of messages on failure.
360 EXPECT_TRUE(match);
tkchin93411912015-07-22 12:12:17 -0700361 }
tkchin93411912015-07-22 12:12:17 -0700362}
363
364// Tests that writing and reading to a stream where only the first file is
365// written to behaves correctly.
phoglundbb738732016-07-15 03:57:12 -0700366TEST_F(MAYBE_CallSessionFileRotatingStreamTest, WriteAndReadFirstHalf) {
tkchin93411912015-07-22 12:12:17 -0700367 Init("CallSessionFileRotatingStreamTestWriteAndReadFirstHalf",
368 6 * 1024 * 1024);
369 ASSERT_TRUE(stream_->Open());
370 const size_t buffer_size = 1024 * 1024;
jbauch555604a2016-04-26 03:13:22 -0700371 std::unique_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
tkchin93411912015-07-22 12:12:17 -0700372 for (int i = 0; i < 2; i++) {
373 memset(buffer.get(), i, buffer_size);
Niels Möllerca81a3c2021-03-29 10:15:14 +0200374 EXPECT_TRUE(stream_->Write(buffer.get(), buffer_size));
tkchin93411912015-07-22 12:12:17 -0700375 }
376
Niels Möller6ffe62a2019-01-08 13:22:57 +0100377 const int expected_vals[] = {0, 1};
378 const size_t expected_size = buffer_size * arraysize(expected_vals);
379
380 CallSessionFileRotatingStreamReader reader(dir_path_);
381 EXPECT_EQ(reader.GetSize(), expected_size);
382 std::unique_ptr<uint8_t[]> contents(new uint8_t[expected_size + 1]);
383 EXPECT_EQ(reader.ReadAll(contents.get(), expected_size + 1), expected_size);
384
tkchin93411912015-07-22 12:12:17 -0700385 for (size_t i = 0; i < arraysize(expected_vals); ++i) {
Niels Möller6ffe62a2019-01-08 13:22:57 +0100386 const uint8_t* block = contents.get() + i * buffer_size;
387 bool match = true;
388 for (size_t j = 0; j < buffer_size; j++) {
389 if (block[j] != expected_vals[i]) {
390 match = false;
391 break;
392 }
393 }
394 // EXPECT call at end of loop, to limit the number of messages on failure.
395 EXPECT_TRUE(match);
tkchin93411912015-07-22 12:12:17 -0700396 }
tkchin93411912015-07-22 12:12:17 -0700397}
398
399} // namespace rtc