Delete rtc_base/unittest_main.cc

Usage replaced with test/test_main.cc.

Bug: webrtc:5996
Change-Id: I65e7539f2072fb45255a3c1af0b10dd06e1701ca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137805
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28010}
This commit is contained in:
Niels Möller 2019-05-21 13:01:58 +02:00 committed by Commit Bot
parent d703cd022f
commit 04a3cc1ad9
9 changed files with 23 additions and 184 deletions

View file

@ -484,7 +484,6 @@ if (rtc_include_tests) {
"p2p:libstunprober_unittests", "p2p:libstunprober_unittests",
"p2p:rtc_p2p_unittests", "p2p:rtc_p2p_unittests",
"rtc_base:rtc_base_approved_unittests", "rtc_base:rtc_base_approved_unittests",
"rtc_base:rtc_base_tests_main",
"rtc_base:rtc_base_unittests", "rtc_base:rtc_base_unittests",
"rtc_base:rtc_json_unittests", "rtc_base:rtc_json_unittests",
"rtc_base:rtc_numerics_unittests", "rtc_base:rtc_numerics_unittests",
@ -495,6 +494,7 @@ if (rtc_include_tests) {
"rtc_base/synchronization:sequence_checker_unittests", "rtc_base/synchronization:sequence_checker_unittests",
"rtc_base/task_utils:to_queued_task_unittests", "rtc_base/task_utils:to_queued_task_unittests",
"sdk:sdk_tests", "sdk:sdk_tests",
"test:test_main",
"test/scenario/network:network_emulation_unittests", "test/scenario/network:network_emulation_unittests",
] ]

View file

@ -545,18 +545,19 @@ if (rtc_include_tests) {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:gunit_helpers", "../rtc_base:gunit_helpers",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../rtc_base:rtc_base_tests_main",
"../rtc_base:rtc_base_tests_utils", "../rtc_base:rtc_base_tests_utils",
"../rtc_base:rtc_task_queue", "../rtc_base:rtc_task_queue",
"../rtc_base:stringutils", "../rtc_base:stringutils",
"../rtc_base/third_party/sigslot", "../rtc_base/third_party/sigslot",
"../test:audio_codec_mocks", "../test:audio_codec_mocks",
"../test:field_trial", "../test:field_trial",
"../test:test_main",
"../test:test_support", "../test:test_support",
"../test:video_test_common", "../test:video_test_common",
"//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
] ]
sources = [ sources = [
"base/codec_unittest.cc", "base/codec_unittest.cc",

View file

@ -307,10 +307,10 @@ if (rtc_include_tests) {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:gunit_helpers", "../rtc_base:gunit_helpers",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../rtc_base:rtc_base_tests_main",
"../rtc_base:rtc_base_tests_utils", "../rtc_base:rtc_base_tests_utils",
"../rtc_base/third_party/sigslot", "../rtc_base/third_party/sigslot",
"../system_wrappers:metrics", "../system_wrappers:metrics",
"../test:test_main",
"../test:test_support", "../test:test_support",
"//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
@ -571,10 +571,10 @@ if (rtc_include_tests) {
"../pc:rtc_pc", "../pc:rtc_pc",
"../rtc_base", "../rtc_base",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../rtc_base:rtc_base_tests_main",
"../rtc_base:rtc_task_queue", "../rtc_base:rtc_task_queue",
"../rtc_base:safe_conversions", "../rtc_base:safe_conversions",
"../test:audio_codec_mocks", "../test:audio_codec_mocks",
"../test:test_main",
"../test:test_support", "../test:test_support",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]

View file

@ -1129,27 +1129,6 @@ if (rtc_include_tests) {
] ]
} }
rtc_source_set("rtc_base_tests_main") {
testonly = true
sources = [
"unittest_main.cc",
]
deps = [
":gunit_helpers",
":rtc_base",
":rtc_base_approved",
":rtc_base_tests_utils",
"../system_wrappers:field_trial",
"../system_wrappers:metrics",
"../test:field_trial",
"../test:test_support",
]
public_deps = [
"//testing/gtest",
]
}
rtc_source_set("rtc_base_nonparallel_tests") { rtc_source_set("rtc_base_nonparallel_tests") {
testonly = true testonly = true
@ -1166,11 +1145,11 @@ if (rtc_include_tests) {
":checks", ":checks",
":gunit_helpers", ":gunit_helpers",
":rtc_base", ":rtc_base",
":rtc_base_tests_main",
":rtc_base_tests_utils", ":rtc_base_tests_utils",
":testclient", ":testclient",
"../system_wrappers", "../system_wrappers",
"../test:fileutils", "../test:fileutils",
"../test:test_main",
"../test:test_support", "../test:test_support",
"third_party/sigslot", "third_party/sigslot",
"//testing/gtest", "//testing/gtest",
@ -1235,7 +1214,6 @@ if (rtc_include_tests) {
":rate_limiter", ":rate_limiter",
":rtc_base", ":rtc_base",
":rtc_base_approved", ":rtc_base_approved",
":rtc_base_tests_main",
":rtc_base_tests_utils", ":rtc_base_tests_utils",
":rtc_task_queue", ":rtc_task_queue",
":safe_compare", ":safe_compare",
@ -1248,6 +1226,7 @@ if (rtc_include_tests) {
"../api/units:time_delta", "../api/units:time_delta",
"../system_wrappers", "../system_wrappers",
"../test:fileutils", "../test:fileutils",
"../test:test_main",
"../test:test_support", "../test:test_support",
"memory:unittests", "memory:unittests",
"third_party/base64", "third_party/base64",
@ -1265,10 +1244,10 @@ if (rtc_include_tests) {
deps = [ deps = [
":gunit_helpers", ":gunit_helpers",
":rtc_base_approved", ":rtc_base_approved",
":rtc_base_tests_main",
":rtc_base_tests_utils", ":rtc_base_tests_utils",
":rtc_task_queue", ":rtc_task_queue",
":task_queue_for_test", ":task_queue_for_test",
"../test:test_main",
"../test:test_support", "../test:test_support",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
] ]
@ -1283,11 +1262,11 @@ if (rtc_include_tests) {
deps = [ deps = [
":gunit_helpers", ":gunit_helpers",
":rtc_base_approved", ":rtc_base_approved",
":rtc_base_tests_main",
":rtc_base_tests_utils", ":rtc_base_tests_utils",
":rtc_event", ":rtc_event",
":task_queue_for_test", ":task_queue_for_test",
":weak_ptr", ":weak_ptr",
"../test:test_main",
"../test:test_support", "../test:test_support",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
] ]
@ -1307,8 +1286,8 @@ if (rtc_include_tests) {
] ]
deps = [ deps = [
":rtc_base_approved", ":rtc_base_approved",
":rtc_base_tests_main",
":rtc_numerics", ":rtc_numerics",
"../test:test_main",
"../test:test_support", "../test:test_support",
"//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/algorithm:container",
] ]
@ -1322,9 +1301,9 @@ if (rtc_include_tests) {
] ]
deps = [ deps = [
":gunit_helpers", ":gunit_helpers",
":rtc_base_tests_main",
":rtc_base_tests_utils", ":rtc_base_tests_utils",
":rtc_json", ":rtc_json",
"../test:test_main",
"../test:test_support", "../test:test_support",
] ]
} }
@ -1374,18 +1353,19 @@ if (rtc_include_tests) {
deps = [ deps = [
":checks", ":checks",
":gunit_helpers", ":gunit_helpers",
":rtc_base_tests_main",
":rtc_base_tests_utils", ":rtc_base_tests_utils",
":stringutils", ":stringutils",
":testclient", ":testclient",
"../api:array_view", "../api:array_view",
"../test:fileutils", "../test:fileutils",
"../test:test_main",
"../test:test_support", "../test:test_support",
"memory:fifo_buffer", "memory:fifo_buffer",
"synchronization:synchronization_unittests", "synchronization:synchronization_unittests",
"third_party/sigslot", "third_party/sigslot",
"//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]
public_deps = [ public_deps = [

View file

@ -204,12 +204,13 @@ if (rtc_include_tests) {
":rate_control_settings", ":rate_control_settings",
":rtt_mult_experiment", ":rtt_mult_experiment",
"..:gunit_helpers", "..:gunit_helpers",
"../:rtc_base_tests_main",
"../:rtc_base_tests_utils", "../:rtc_base_tests_utils",
"../../api/video_codecs:video_codecs_api", "../../api/video_codecs:video_codecs_api",
"../../system_wrappers:field_trial", "../../system_wrappers:field_trial",
"../../test:field_trial", "../../test:field_trial",
"../../test:test_main",
"../../test:test_support", "../../test:test_support",
"//third_party/abseil-cpp/absl/types:optional",
] ]
} }
} }

View file

@ -83,9 +83,9 @@ if (rtc_include_tests) {
":sequence_checker", ":sequence_checker",
"..:checks", "..:checks",
"..:rtc_base_approved", "..:rtc_base_approved",
"..:rtc_base_tests_main",
"..:task_queue_for_test", "..:task_queue_for_test",
"../../api:function_view", "../../api:function_view",
"../../test:test_main",
"../../test:test_support", "../../test:test_support",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
] ]

View file

@ -1,149 +0,0 @@
/*
* Copyright 2007 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.
*/
//
// A reuseable entry point for gunit tests.
#if defined(WEBRTC_WIN)
#include <crtdbg.h>
#endif
#include "rtc_base/flags.h"
#include "rtc_base/logging.h"
#include "rtc_base/ssl_adapter.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "system_wrappers/include/field_trial.h"
#include "system_wrappers/include/metrics.h"
#include "test/field_trial.h"
#include "test/gtest.h"
#if defined(WEBRTC_WIN)
#include "rtc_base/win32_socket_init.h"
#endif
#if defined(WEBRTC_IOS)
#include "test/ios/test_support.h"
#endif
WEBRTC_DEFINE_bool(help, false, "prints this message");
WEBRTC_DEFINE_string(log, "", "logging options to use");
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.");
#if defined(WEBRTC_WIN)
WEBRTC_DEFINE_int(crt_break_alloc, -1, "memory allocation to break on");
WEBRTC_DEFINE_bool(
default_error_handlers,
false,
"leave the default exception/dbg handler functions in place");
void TestInvalidParameterHandler(const wchar_t* expression,
const wchar_t* function,
const wchar_t* file,
unsigned int line,
uintptr_t pReserved) {
// In order to log `expression`, `function`, and `file` here, we would have
// to convert them to const char*. std::wcsrtombs can do that, but it's
// locale dependent.
RTC_LOG(LS_ERROR) << "InvalidParameter Handler called. Exiting.";
exit(1);
}
void TestPureCallHandler() {
RTC_LOG(LS_ERROR) << "Purecall Handler called. Exiting.";
exit(1);
}
int TestCrtReportHandler(int report_type, char* msg, int* retval) {
RTC_LOG(LS_ERROR) << "CrtReport Handler called...";
RTC_LOG(LS_ERROR) << msg;
if (report_type == _CRT_ASSERT) {
exit(1);
} else {
*retval = 0;
return TRUE;
}
}
#endif // WEBRTC_WIN
int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false);
if (FLAG_help) {
rtc::FlagList::Print(nullptr, false);
return 0;
}
webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
// InitFieldTrialsFromString stores the char*, so the char array must outlive
// the application.
webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
webrtc::metrics::Enable();
#if defined(WEBRTC_WIN)
rtc::WinsockInitializer winsock_init;
if (!FLAG_default_error_handlers) {
// Make sure any errors don't throw dialogs hanging the test run.
_set_invalid_parameter_handler(TestInvalidParameterHandler);
_set_purecall_handler(TestPureCallHandler);
_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestCrtReportHandler);
}
#if !defined(NDEBUG) // Turn on memory leak checking on Windows.
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
if (FLAG_crt_break_alloc >= 0) {
_crtBreakAlloc = FLAG_crt_break_alloc;
}
#endif
#endif // WEBRTC_WIN
// By default, log timestamps. Allow overrides by used of a --log flag.
rtc::LogMessage::LogTimestamps();
if (*FLAG_log != '\0') {
rtc::LogMessage::ConfigureLogging(FLAG_log);
} else if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO) {
// Default to LS_INFO, even for release builds to provide better test
// logging.
rtc::LogMessage::LogToDebug(rtc::LS_INFO);
}
// Initialize SSL which are used by several tests.
rtc::InitializeSSL();
rtc::SSLStreamAdapter::EnableTimeCallbackForTesting();
#if defined(WEBRTC_IOS)
rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv, false);
rtc::test::RunTestsFromIOSApp();
#endif
const int res = RUN_ALL_TESTS();
rtc::CleanupSSL();
// clean up logging so we don't appear to leak memory.
rtc::LogMessage::ConfigureLogging("");
#if defined(WEBRTC_WIN)
// Unhook crt function so that we don't ever log after statics have been
// uninitialized.
if (!FLAG_default_error_handlers)
_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestCrtReportHandler);
#endif
#if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \
defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \
defined(UNDEFINED_SANITIZER)
// We want the test flagged as failed only for sanitizer defects,
// in which case the sanitizer will override exit code with 66.
return 0;
#endif
return res;
}

View file

@ -61,8 +61,8 @@ if (rtc_include_tests) {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:gunit_helpers", "../rtc_base:gunit_helpers",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../rtc_base:rtc_base_tests_main",
"../rtc_base:rtc_json", "../rtc_base:rtc_json",
"../test:test_main",
"../test:test_support", "../test:test_support",
] ]

View file

@ -17,6 +17,8 @@
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/flags.h" #include "rtc_base/flags.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/ssl_adapter.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/field_trial.h"
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"
@ -120,6 +122,10 @@ class TestMainImpl : public TestMain {
winsock_init_ = absl::make_unique<rtc::WinsockInitializer>(); winsock_init_ = absl::make_unique<rtc::WinsockInitializer>();
#endif #endif
// Initialize SSL which are used by several tests.
rtc::InitializeSSL();
rtc::SSLStreamAdapter::EnableTimeCallbackForTesting();
// Ensure that main thread gets wrapped as an rtc::Thread. // Ensure that main thread gets wrapped as an rtc::Thread.
// TODO(bugs.webrt.org/9714): It might be better to avoid wrapping the main // TODO(bugs.webrt.org/9714): It might be better to avoid wrapping the main
// thread, or leave it to individual tests that need it. But as long as we // thread, or leave it to individual tests that need it. But as long as we