2013-07-09 08:02:33 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-10-15 15:25:34 +02:00
|
|
|
#include <memory>
|
2022-11-22 11:06:47 +01:00
|
|
|
#include <regex>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2018-09-21 13:56:26 +02:00
|
|
|
|
2019-08-12 13:40:47 +02:00
|
|
|
#include "absl/debugging/failure_signal_handler.h"
|
|
|
|
|
#include "absl/debugging/symbolize.h"
|
2020-08-11 12:19:18 +02:00
|
|
|
#include "absl/flags/parse.h"
|
|
|
|
|
#include "test/gmock.h"
|
2018-10-15 15:25:34 +02:00
|
|
|
#include "test/test_main_lib.h"
|
2017-08-29 05:51:57 -07:00
|
|
|
|
2022-11-22 11:06:47 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> ReplaceDashesWithUnderscores(int argc, char* argv[]) {
|
|
|
|
|
std::vector<std::string> args(argv, argv + argc);
|
|
|
|
|
for (std::string& arg : args) {
|
|
|
|
|
// Only replace arguments that starts with a dash.
|
|
|
|
|
if (!arg.empty() && arg[0] == '-') {
|
|
|
|
|
// Don't replace the 2 first characters.
|
|
|
|
|
auto begin = arg.begin() + 2;
|
|
|
|
|
// Replace dashes on the left of '=' or on all the arg if no '=' is found.
|
|
|
|
|
auto end = std::find(arg.begin(), arg.end(), '=');
|
|
|
|
|
std::replace(begin, end, '-', '_');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<char*> VectorOfStringsToVectorOfPointers(
|
|
|
|
|
std::vector<std::string>& input) {
|
|
|
|
|
std::vector<char*> output(input.size());
|
|
|
|
|
for (size_t i = 0; i < input.size(); ++i) {
|
|
|
|
|
output[i] = &(input[i][0]);
|
|
|
|
|
}
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2013-07-09 08:02:33 +00:00
|
|
|
int main(int argc, char* argv[]) {
|
2019-08-12 13:40:47 +02:00
|
|
|
// Initialize the symbolizer to get a human-readable stack trace
|
2020-05-15 15:01:54 +02:00
|
|
|
absl::InitializeSymbolizer(argv[0]);
|
2020-08-11 12:19:18 +02:00
|
|
|
testing::InitGoogleMock(&argc, argv);
|
2022-11-22 11:06:47 +01:00
|
|
|
// Before parsing the arguments with the absl flag library, any internal '-'
|
|
|
|
|
// characters will be converted to '_' characters to make sure the string is a
|
|
|
|
|
// valid attribute name.
|
|
|
|
|
std::vector<std::string> new_argv = ReplaceDashesWithUnderscores(argc, argv);
|
|
|
|
|
std::vector<char*> raw_new_argv = VectorOfStringsToVectorOfPointers(new_argv);
|
|
|
|
|
absl::ParseCommandLine(argc, &raw_new_argv[0]);
|
2019-08-12 13:40:47 +02:00
|
|
|
|
2022-11-08 13:56:19 +01:00
|
|
|
// This absl handler use unsupported features/instructions on Fuchsia
|
|
|
|
|
#if !defined(WEBRTC_FUCHSIA)
|
2020-05-15 15:01:54 +02:00
|
|
|
absl::FailureSignalHandlerOptions options;
|
|
|
|
|
absl::InstallFailureSignalHandler(options);
|
2022-11-08 13:56:19 +01:00
|
|
|
#endif
|
2019-08-12 13:40:47 +02:00
|
|
|
|
2018-10-15 15:25:34 +02:00
|
|
|
std::unique_ptr<webrtc::TestMain> main = webrtc::TestMain::Create();
|
2020-08-11 12:19:18 +02:00
|
|
|
int err_code = main->Init();
|
2018-10-15 15:25:34 +02:00
|
|
|
if (err_code != 0) {
|
|
|
|
|
return err_code;
|
2017-12-04 15:56:21 +01:00
|
|
|
}
|
2018-10-15 15:25:34 +02:00
|
|
|
return main->Run(argc, argv);
|
2013-07-09 08:02:33 +00:00
|
|
|
}
|