Rewrite the lib link test to just be a binary.

This works on mobile and has less dependencies. There's no upside to
using gtest since I'm not planning on running the test anyway, so this
is a much better solution.

Bug: webrtc:11027
Change-Id: Id63af7086b9d9c9199c62bc8654b4202a4a1f759
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157380
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29529}
This commit is contained in:
Patrik Höglund 2019-10-18 08:04:19 +02:00 committed by Commit Bot
parent 98872dc556
commit 2167163770
2 changed files with 22 additions and 18 deletions

View File

@ -42,6 +42,7 @@ if (!build_with_chromium) {
":rtc_unittests", ":rtc_unittests",
":slow_tests", ":slow_tests",
":video_engine_tests", ":video_engine_tests",
":webrtc_lib_link_test",
":webrtc_nonparallel_tests", ":webrtc_nonparallel_tests",
":webrtc_perf_tests", ":webrtc_perf_tests",
"common_audio:common_audio_unittests", "common_audio:common_audio_unittests",
@ -73,9 +74,6 @@ if (!build_with_chromium) {
} else { } else {
deps += [ "modules/video_capture:video_capture_tests" ] deps += [ "modules/video_capture:video_capture_tests" ]
} }
if (!is_android && !is_ios) {
deps += [ ":webrtc_lib_link_test" ]
}
if (rtc_enable_protobuf) { if (rtc_enable_protobuf) {
deps += [ deps += [
"audio:low_bandwidth_audio_test", "audio:low_bandwidth_audio_test",
@ -466,19 +464,17 @@ if (!build_with_chromium) {
} }
} }
if (rtc_include_tests && !is_android && !is_ios) { if (rtc_include_tests) {
# Note: This test can't work on mobile because the test runner machinery rtc_executable("webrtc_lib_link_test") {
# on those platforms depend on abseil, which will link-clash with libwebrtc.
rtc_test("webrtc_lib_link_test") {
testonly = true testonly = true
sources = [ sources = [
"webrtc_lib_link_test.cc", "webrtc_lib_link_test.cc",
] ]
deps = [ deps = [
# NOTE: Don't add deps here. If this test fails to link, it means you
# need to add stuff to the webrtc static lib target above.
":webrtc", ":webrtc",
"//test:test_main",
"//testing/gtest",
] ]
} }
} }

View File

@ -24,8 +24,6 @@
#include "modules/audio_device/include/audio_device.h" #include "modules/audio_device/include/audio_device.h"
#include "modules/audio_processing/include/audio_processing.h" #include "modules/audio_processing/include/audio_processing.h"
#include "test/gtest.h"
namespace webrtc { namespace webrtc {
cricket::MediaEngineDependencies CreateSomeMediaDeps( cricket::MediaEngineDependencies CreateSomeMediaDeps(
@ -44,8 +42,6 @@ cricket::MediaEngineDependencies CreateSomeMediaDeps(
return media_deps; return media_deps;
} }
// This test should pull in as much of WebRTC as possible to make sure most
// commonly used symbols are actually in libwebrtc.a.
webrtc::PeerConnectionFactoryDependencies CreateSomePcfDeps() { webrtc::PeerConnectionFactoryDependencies CreateSomePcfDeps() {
webrtc::PeerConnectionFactoryDependencies pcf_deps; webrtc::PeerConnectionFactoryDependencies pcf_deps;
pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory(); pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory();
@ -60,18 +56,21 @@ webrtc::PeerConnectionFactoryDependencies CreateSomePcfDeps() {
return pcf_deps; return pcf_deps;
} }
TEST(WebRTCLinkTest, TestCreatingAPeerConnectionViaModularFactory) { // NOTE: These "test cases" should pull in as much of WebRTC as possible to make
// sure most commonly used symbols are actually in libwebrtc.a. It's entirely
// possible these tests won't work at all times (maybe crash even), but that's
// fine.
void TestCase1ModularFactory() {
auto pcf_deps = CreateSomePcfDeps(); auto pcf_deps = CreateSomePcfDeps();
auto peer_connection_factory = auto peer_connection_factory =
webrtc::CreateModularPeerConnectionFactory(std::move(pcf_deps)); webrtc::CreateModularPeerConnectionFactory(std::move(pcf_deps));
webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
auto peer_connection = peer_connection_factory->CreatePeerConnection( auto peer_connection = peer_connection_factory->CreatePeerConnection(
rtc_config, nullptr, nullptr, nullptr); rtc_config, nullptr, nullptr, nullptr);
ASSERT_EQ(peer_connection.get(), nullptr) printf("peer_connection=%s\n", peer_connection == nullptr ? "nullptr" : "ok");
<< "Should fail, we're not setting things up right";
} }
TEST(WebRTCLinkTest, TestCreatingViaPCFactory) { void TestCase2RegularFactory() {
auto task_queue_factory = CreateDefaultTaskQueueFactory(); auto task_queue_factory = CreateDefaultTaskQueueFactory();
auto media_deps = CreateSomeMediaDeps(task_queue_factory.get()); auto media_deps = CreateSomeMediaDeps(task_queue_factory.get());
@ -81,7 +80,16 @@ TEST(WebRTCLinkTest, TestCreatingViaPCFactory) {
std::move(media_deps.audio_decoder_factory), std::move(media_deps.audio_decoder_factory),
std::move(media_deps.video_encoder_factory), std::move(media_deps.video_encoder_factory),
std::move(media_deps.video_decoder_factory), nullptr, nullptr); std::move(media_deps.video_decoder_factory), nullptr, nullptr);
ASSERT_NE(peer_connection_factory.get(), nullptr); webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
auto peer_connection = peer_connection_factory->CreatePeerConnection(
rtc_config, nullptr, nullptr, nullptr);
printf("peer_connection=%s\n", peer_connection == nullptr ? "nullptr" : "ok");
} }
} // namespace webrtc } // namespace webrtc
int main(int argc, char** argv) {
webrtc::TestCase1ModularFactory();
webrtc::TestCase2RegularFactory();
return 0;
}