OLD | NEW |
---|---|
(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 | |
20 DEFINE_string(isolated_out_dir, "", | |
21 "The isolated output folder provided by swarming test framework."); | |
kjellander_webrtc
2016/12/08 11:51:28
Please make webrtc::test::OutputPath() the default
Hzj_jie
2016/12/08 23:01:09
Done.
| |
22 | |
23 namespace webrtc { | |
24 namespace test { | |
25 | |
26 bool WriteIsolatedOutput(const char* filename, | |
27 const uint8_t* buffer, | |
28 size_t length) { | |
29 if (FLAGS_isolated_out_dir.empty()) { | |
30 LOG(LS_WARNING) << "No isolated_out_dir defined."; | |
31 return false; | |
32 } | |
33 | |
34 if (filename == nullptr || strlen(filename) == 0) { | |
35 LOG(LS_WARNING) << "filename should not be an empty string."; | |
kjellander_webrtc
2016/12/08 11:51:28
Change to "filename must be provided." since it mi
Hzj_jie
2016/12/08 23:01:09
Done.
| |
36 return false; | |
37 } | |
38 | |
39 rtc::File output = | |
40 rtc::File::Create(rtc::Pathname(FLAGS_isolated_out_dir, filename)); | |
41 | |
42 return output.IsOpen() && output.Write(buffer, length) == length; | |
43 } | |
44 | |
45 bool WriteIsolatedOutput(const char* filename, const std::string& content) { | |
46 return WriteIsolatedOutput(filename, | |
47 reinterpret_cast<const uint8_t*>(content.c_str()), | |
48 content.length()); | |
49 } | |
50 | |
51 } // namespace test | |
52 } // namespace webrtc | |
OLD | NEW |