Fix: Argv may be corrupted after InitGoogleMock found any related flags
Bug: webrtc:5996 Change-Id: I42f3c7eef990e06f89d7c847b0ccc89abe257111 Reviewed-on: https://webrtc-review.googlesource.com/c/106707 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25244}
This commit is contained in:
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::unique_ptr<webrtc::TestMain> main = webrtc::TestMain::Create();
|
std::unique_ptr<webrtc::TestMain> main = webrtc::TestMain::Create();
|
||||||
int err_code = main->Init(argc, argv);
|
int err_code = main->Init(&argc, argv);
|
||||||
if (err_code != 0) {
|
if (err_code != 0) {
|
||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,8 @@ namespace {
|
|||||||
|
|
||||||
class TestMainImpl : public TestMain {
|
class TestMainImpl : public TestMain {
|
||||||
public:
|
public:
|
||||||
int Init(int argc, char* argv[]) override {
|
int Init(int* argc, char* argv[]) override {
|
||||||
::testing::InitGoogleMock(&argc, argv);
|
::testing::InitGoogleMock(argc, argv);
|
||||||
|
|
||||||
// Default to LS_INFO, even for release builds to provide better test
|
// Default to LS_INFO, even for release builds to provide better test
|
||||||
// logging.
|
// logging.
|
||||||
@ -88,7 +88,7 @@ class TestMainImpl : public TestMain {
|
|||||||
if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO)
|
if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO)
|
||||||
rtc::LogMessage::LogToDebug(rtc::LS_INFO);
|
rtc::LogMessage::LogToDebug(rtc::LS_INFO);
|
||||||
|
|
||||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false)) {
|
if (rtc::FlagList::SetFlagsFromCommandLine(argc, argv, false)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (FLAG_help) {
|
if (FLAG_help) {
|
||||||
|
@ -24,7 +24,7 @@ class TestMain {
|
|||||||
// Initializes test environment. Clients can add their own initialization
|
// Initializes test environment. Clients can add their own initialization
|
||||||
// steps after call to this method and before running tests.
|
// steps after call to this method and before running tests.
|
||||||
// Returns 0 if initialization was successful and non 0 otherwise.
|
// Returns 0 if initialization was successful and non 0 otherwise.
|
||||||
virtual int Init(int argc, char* argv[]) = 0;
|
virtual int Init(int* argc, char* argv[]) = 0;
|
||||||
|
|
||||||
// Runs test end return result error code. 0 - no errors.
|
// Runs test end return result error code. 0 - no errors.
|
||||||
virtual int Run(int argc, char* argv[]) = 0;
|
virtual int Run(int argc, char* argv[]) = 0;
|
||||||
|
Reference in New Issue
Block a user