Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: webrtc/test/testsupport/isolated_output.cc

Issue 2558693002: Add WriteIsolatedOutput() functions (Closed)
Patch Set: Resolve review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 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
11 #include "webrtc/test/testsupport/isolated_output.h"
12
13 #include <string.h>
14
15 #include "gflags/gflags.h"
16 #include "webrtc/base/file.h"
17 #include "webrtc/base/logging.h"
18 #include "webrtc/base/pathutils.h"
19 #include "webrtc/test/testsupport/fileutils.h"
20
21 DEFINE_string(isolated_out_dir, webrtc::test::OutputPath(),
22 "The isolated output folder provided by swarming test framework.");
23
24 namespace webrtc {
25 namespace test {
26
27 bool WriteIsolatedOutput(const char* filename,
28 const uint8_t* buffer,
29 size_t length) {
30 if (FLAGS_isolated_out_dir.empty()) {
31 LOG(LS_WARNING) << "No isolated_out_dir defined.";
32 return false;
33 }
34
35 if (filename == nullptr || strlen(filename) == 0) {
36 LOG(LS_WARNING) << "filename must be provided.";
37 return false;
38 }
39
40 rtc::File output =
41 rtc::File::Create(rtc::Pathname(FLAGS_isolated_out_dir, filename));
42
43 return output.IsOpen() && output.Write(buffer, length) == length;
44 }
45
46 bool WriteIsolatedOutput(const char* filename, const std::string& content) {
47 return WriteIsolatedOutput(filename,
48 reinterpret_cast<const uint8_t*>(content.c_str()),
49 content.length());
50 }
51
52 } // namespace test
53 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/testsupport/isolated_output.h ('k') | webrtc/test/testsupport/isolated_output_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698