OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/test/testsupport/isolated_output.h" | 11 #include "webrtc/test/testsupport/test_output.h" |
12 | 12 |
13 #include <string.h> | 13 #include <string.h> |
14 | 14 |
15 #include "gflags/gflags.h" | 15 #include "gflags/gflags.h" |
16 #include "webrtc/rtc_base/file.h" | 16 #include "webrtc/rtc_base/file.h" |
17 #include "webrtc/rtc_base/logging.h" | 17 #include "webrtc/rtc_base/logging.h" |
18 #include "webrtc/rtc_base/pathutils.h" | 18 #include "webrtc/rtc_base/pathutils.h" |
19 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
20 | 20 |
21 DEFINE_string(isolated_out_dir, webrtc::test::OutputPath(), | 21 DEFINE_string(test_output_dir, |
22 "The isolated output folder provided by swarming test framework."); | 22 webrtc::test::OutputPath(), |
| 23 "The output folder where test output should be saved."); |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 namespace test { | 26 namespace test { |
26 | 27 |
27 bool WriteIsolatedOutput(const char* filename, | 28 bool GetTestOutputDir(std::string* out_dir) { |
28 const uint8_t* buffer, | 29 if (FLAGS_test_output_dir.empty()) { |
29 size_t length) { | 30 LOG(LS_WARNING) << "No test_out_dir defined."; |
30 if (FLAGS_isolated_out_dir.empty()) { | 31 return false; |
31 LOG(LS_WARNING) << "No isolated_out_dir defined."; | 32 } |
| 33 *out_dir = FLAGS_test_output_dir; |
| 34 return true; |
| 35 } |
| 36 |
| 37 bool WriteToTestOutput(const char* filename, |
| 38 const uint8_t* buffer, |
| 39 size_t length) { |
| 40 if (FLAGS_test_output_dir.empty()) { |
| 41 LOG(LS_WARNING) << "No test_out_dir defined."; |
32 return false; | 42 return false; |
33 } | 43 } |
34 | 44 |
35 if (filename == nullptr || strlen(filename) == 0) { | 45 if (filename == nullptr || strlen(filename) == 0) { |
36 LOG(LS_WARNING) << "filename must be provided."; | 46 LOG(LS_WARNING) << "filename must be provided."; |
37 return false; | 47 return false; |
38 } | 48 } |
39 | 49 |
40 rtc::File output = | 50 rtc::File output = |
41 rtc::File::Create(rtc::Pathname(FLAGS_isolated_out_dir, filename)); | 51 rtc::File::Create(rtc::Pathname(FLAGS_test_output_dir, filename)); |
42 | 52 |
43 return output.IsOpen() && output.Write(buffer, length) == length; | 53 return output.IsOpen() && output.Write(buffer, length) == length; |
44 } | 54 } |
45 | 55 |
46 bool WriteIsolatedOutput(const char* filename, const std::string& content) { | 56 bool WriteToTestOutput(const char* filename, const std::string& content) { |
47 return WriteIsolatedOutput(filename, | 57 return WriteToTestOutput(filename, |
48 reinterpret_cast<const uint8_t*>(content.c_str()), | 58 reinterpret_cast<const uint8_t*>(content.c_str()), |
49 content.length()); | 59 content.length()); |
50 } | 60 } |
51 | 61 |
52 } // namespace test | 62 } // namespace test |
53 } // namespace webrtc | 63 } // namespace webrtc |
OLD | NEW |