Migrate WebRTC test infra to ABSL_FLAG.
This is the last CL required to migrate WebRTC to ABSL_FLAG, rtc::Flag
will be removed soon after this one lands.
Bug: webrtc:10616
Change-Id: I2807cec39e28a2737d2c49e2dc23f2a6f98d08f0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145727
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28606}
diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc
index 52939af..02e0703 100644
--- a/test/test_main_lib.cc
+++ b/test/test_main_lib.cc
@@ -13,9 +13,10 @@
#include <fstream>
#include <string>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/logging.h"
#include "rtc_base/ssl_adapter.h"
#include "rtc_base/ssl_stream_adapter.h"
@@ -35,13 +36,16 @@
#if defined(WEBRTC_IOS)
#include "test/ios/test_support.h"
-WEBRTC_DEFINE_string(NSTreatUnknownArgumentsAsOpen,
- "",
- "Intentionally ignored flag intended for iOS simulator.");
-WEBRTC_DEFINE_string(ApplePersistenceIgnoreState,
- "",
- "Intentionally ignored flag intended for iOS simulator.");
-WEBRTC_DEFINE_bool(
+ABSL_FLAG(std::string,
+ NSTreatUnknownArgumentsAsOpen,
+ "",
+ "Intentionally ignored flag intended for iOS simulator.");
+ABSL_FLAG(std::string,
+ ApplePersistenceIgnoreState,
+ "",
+ "Intentionally ignored flag intended for iOS simulator.");
+ABSL_FLAG(
+ bool,
save_chartjson_result,
false,
"Store the perf results in Documents/perf_result.json in the format "
@@ -51,12 +55,13 @@
#else
-WEBRTC_DEFINE_string(
- isolated_script_test_output,
- "",
- "Path to output an empty JSON file which Chromium infra requires.");
+ABSL_FLAG(std::string,
+ isolated_script_test_output,
+ "",
+ "Path to output an empty JSON file which Chromium infra requires.");
-WEBRTC_DEFINE_string(
+ABSL_FLAG(
+ std::string,
isolated_script_test_perf_output,
"",
"Path where the perf results should be stored in the JSON format described "
@@ -66,17 +71,15 @@
#endif
-WEBRTC_DEFINE_bool(logs, true, "print logs to stderr");
-WEBRTC_DEFINE_bool(verbose, false, "verbose logs to stderr");
+ABSL_FLAG(bool, logs, true, "print logs to stderr");
+ABSL_FLAG(bool, verbose, false, "verbose logs to stderr");
-WEBRTC_DEFINE_string(
- force_fieldtrials,
- "",
- "Field trials control experimental feature code which can be forced. "
- "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
- " will assign the group Enable to field trial WebRTC-FooFeature.");
-
-WEBRTC_DEFINE_bool(help, false, "Print this message.");
+ABSL_FLAG(std::string,
+ force_fieldtrials,
+ "",
+ "Field trials control experimental feature code which can be forced. "
+ "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
+ " will assign the group Enable to field trial WebRTC-FooFeature.");
namespace webrtc {
@@ -86,24 +89,18 @@
public:
int Init(int* argc, char* argv[]) override {
::testing::InitGoogleMock(argc, argv);
+ absl::ParseCommandLine(*argc, argv);
// Default to LS_INFO, even for release builds to provide better test
// logging.
if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO)
rtc::LogMessage::LogToDebug(rtc::LS_INFO);
- if (rtc::FlagList::SetFlagsFromCommandLine(argc, argv, false)) {
- return 1;
- }
- if (FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
-
- if (FLAG_verbose)
+ if (absl::GetFlag(FLAGS_verbose))
rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE);
- rtc::LogMessage::SetLogToStderr(FLAG_logs || FLAG_verbose);
+ rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs) ||
+ absl::GetFlag(FLAGS_verbose));
// TODO(bugs.webrtc.org/9792): we need to reference something from
// fileutils.h so that our downstream hack where we replace fileutils.cc
@@ -114,7 +111,8 @@
// InitFieldTrialsFromString stores the char*, so the char array must
// outlive the application.
- webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
+ field_trials_ = absl::GetFlag(FLAGS_force_fieldtrials);
+ webrtc::field_trial::InitFieldTrialsFromString(field_trials_.c_str());
webrtc::metrics::Enable();
#if defined(WEBRTC_WIN)
@@ -139,18 +137,20 @@
int Run(int argc, char* argv[]) override {
#if defined(WEBRTC_IOS)
rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv,
- FLAG_save_chartjson_result);
+ absl::GetFlag(FLAGS_save_chartjson_result));
rtc::test::RunTestsFromIOSApp();
return 0;
#else
int exit_code = RUN_ALL_TESTS();
- std::string chartjson_result_file = FLAG_isolated_script_test_perf_output;
+ std::string chartjson_result_file =
+ absl::GetFlag(FLAGS_isolated_script_test_perf_output);
if (!chartjson_result_file.empty()) {
webrtc::test::WritePerfResults(chartjson_result_file);
}
- std::string result_filename = FLAG_isolated_script_test_output;
+ std::string result_filename =
+ absl::GetFlag(FLAGS_isolated_script_test_output);
if (!result_filename.empty()) {
std::ofstream result_file(result_filename);
result_file << "{\"version\": 3}";