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

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

Issue 2995363002: Replace gflags usages with rtc_base/flags in all targets based on test_main (Closed)
Patch Set: Fix string use after free Created 3 years, 3 months 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
« no previous file with comments | « webrtc/test/test_main.cc ('k') | webrtc/test/testsupport/test_output_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test_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"
16 #include "webrtc/rtc_base/file.h" 15 #include "webrtc/rtc_base/file.h"
16 #include "webrtc/rtc_base/flags.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 namespace {
22 const std::string& DefaultOutputPath() {
23 static const std::string path = webrtc::test::OutputPath();
24 return path;
25 }
26 }
27
21 DEFINE_string(test_output_dir, 28 DEFINE_string(test_output_dir,
22 webrtc::test::OutputPath(), 29 DefaultOutputPath().c_str(),
23 "The output folder where test output should be saved."); 30 "The output folder where test output should be saved.");
24 31
25 namespace webrtc { 32 namespace webrtc {
26 namespace test { 33 namespace test {
27 34
28 bool GetTestOutputDir(std::string* out_dir) { 35 bool GetTestOutputDir(std::string* out_dir) {
29 if (FLAGS_test_output_dir.empty()) { 36 if (strlen(FLAG_test_output_dir) == 0) {
30 LOG(LS_WARNING) << "No test_out_dir defined."; 37 LOG(LS_WARNING) << "No test_out_dir defined.";
31 return false; 38 return false;
32 } 39 }
33 *out_dir = FLAGS_test_output_dir; 40 *out_dir = FLAG_test_output_dir;
34 return true; 41 return true;
35 } 42 }
36 43
37 bool WriteToTestOutput(const char* filename, 44 bool WriteToTestOutput(const char* filename,
38 const uint8_t* buffer, 45 const uint8_t* buffer,
39 size_t length) { 46 size_t length) {
40 if (FLAGS_test_output_dir.empty()) { 47 if (strlen(FLAG_test_output_dir) == 0) {
41 LOG(LS_WARNING) << "No test_out_dir defined."; 48 LOG(LS_WARNING) << "No test_out_dir defined.";
42 return false; 49 return false;
43 } 50 }
44 51
45 if (filename == nullptr || strlen(filename) == 0) { 52 if (filename == nullptr || strlen(filename) == 0) {
46 LOG(LS_WARNING) << "filename must be provided."; 53 LOG(LS_WARNING) << "filename must be provided.";
47 return false; 54 return false;
48 } 55 }
49 56
50 rtc::File output = 57 rtc::File output =
51 rtc::File::Create(rtc::Pathname(FLAGS_test_output_dir, filename)); 58 rtc::File::Create(rtc::Pathname(FLAG_test_output_dir, filename));
52 59
53 return output.IsOpen() && output.Write(buffer, length) == length; 60 return output.IsOpen() && output.Write(buffer, length) == length;
54 } 61 }
55 62
56 bool WriteToTestOutput(const char* filename, const std::string& content) { 63 bool WriteToTestOutput(const char* filename, const std::string& content) {
57 return WriteToTestOutput(filename, 64 return WriteToTestOutput(filename,
58 reinterpret_cast<const uint8_t*>(content.c_str()), 65 reinterpret_cast<const uint8_t*>(content.c_str()),
59 content.length()); 66 content.length());
60 } 67 }
61 68
62 } // namespace test 69 } // namespace test
63 } // namespace webrtc 70 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/test_main.cc ('k') | webrtc/test/testsupport/test_output_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698