mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Add a test which breaks if libwebrtc.a don't pull in the right symbols.
It's impossible to ensure we are pulling in everything people reasonably believe is used, but it should be a good chunk of it. I don't plan to actually run this test on the bots, it's enough if it is built (which it should, because I add it to the default set of things to build). Bug: webrtc:11027 Change-Id: I186936eeb450d2f63b3a5bed13189e84d5b3fb76 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157175 Commit-Queue: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29518}
This commit is contained in:
parent
5b74f8d7ff
commit
eeb79e94b9
3 changed files with 120 additions and 2 deletions
27
BUILD.gn
27
BUILD.gn
|
@ -73,6 +73,9 @@ if (!build_with_chromium) {
|
|||
} else {
|
||||
deps += [ "modules/video_capture:video_capture_tests" ]
|
||||
}
|
||||
if (!is_android && !is_ios) {
|
||||
deps += [ ":webrtc_lib_link_test" ]
|
||||
}
|
||||
if (rtc_enable_protobuf) {
|
||||
deps += [
|
||||
"audio:low_bandwidth_audio_test",
|
||||
|
@ -389,8 +392,11 @@ config("common_objc") {
|
|||
if (!build_with_chromium) {
|
||||
# Target to build all the WebRTC production code.
|
||||
rtc_static_library("webrtc") {
|
||||
# Only the root target should depend on this.
|
||||
visibility = [ "//:default" ]
|
||||
# Only the root target and the test should depend on this.
|
||||
visibility = [
|
||||
"//:default",
|
||||
"//:webrtc_lib_link_test",
|
||||
]
|
||||
|
||||
sources = []
|
||||
complete_static_lib = true
|
||||
|
@ -459,6 +465,23 @@ if (!build_with_chromium) {
|
|||
deps += [ "logging:rtc_event_log_proto" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (rtc_include_tests && !is_android && !is_ios) {
|
||||
# Note: This test can't work on mobile because the test runner machinery
|
||||
# on those platforms depend on abseil, which will link-clash with libwebrtc.
|
||||
rtc_test("webrtc_lib_link_test") {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
"webrtc_lib_link_test.cc",
|
||||
]
|
||||
deps = [
|
||||
":webrtc",
|
||||
"//test:test_main",
|
||||
"//testing/gtest",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rtc_source_set("webrtc_common") {
|
||||
|
|
8
DEPS
8
DEPS
|
@ -2280,3 +2280,11 @@ include_rules = [
|
|||
# Abseil flags are allowed in tests and tools.
|
||||
"+absl/flags",
|
||||
]
|
||||
|
||||
specific_include_rules = {
|
||||
"webrtc_lib_link_test\.cc": [
|
||||
"+media/engine",
|
||||
"+modules/audio_device",
|
||||
"+modules/audio_processing",
|
||||
]
|
||||
}
|
||||
|
|
87
webrtc_lib_link_test.cc
Normal file
87
webrtc_lib_link_test.cc
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#include "api/audio_codecs/audio_decoder_factory_template.h"
|
||||
#include "api/audio_codecs/audio_encoder_factory_template.h"
|
||||
#include "api/audio_codecs/opus/audio_decoder_opus.h"
|
||||
#include "api/audio_codecs/opus/audio_encoder_opus.h"
|
||||
#include "api/call/call_factory_interface.h"
|
||||
#include "api/create_peerconnection_factory.h"
|
||||
#include "api/peer_connection_interface.h"
|
||||
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
||||
#include "api/stats/rtcstats_objects.h"
|
||||
#include "api/task_queue/default_task_queue_factory.h"
|
||||
#include "api/video_codecs/builtin_video_decoder_factory.h"
|
||||
#include "api/video_codecs/builtin_video_encoder_factory.h"
|
||||
#include "media/engine/webrtc_media_engine.h"
|
||||
#include "modules/audio_device/include/audio_device.h"
|
||||
#include "modules/audio_processing/include/audio_processing.h"
|
||||
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
cricket::MediaEngineDependencies CreateSomeMediaDeps(
|
||||
TaskQueueFactory* task_queue_factory) {
|
||||
cricket::MediaEngineDependencies media_deps;
|
||||
media_deps.task_queue_factory = task_queue_factory;
|
||||
media_deps.adm = AudioDeviceModule::CreateForTest(
|
||||
AudioDeviceModule::kDummyAudio, task_queue_factory);
|
||||
media_deps.audio_encoder_factory =
|
||||
webrtc::CreateAudioEncoderFactory<webrtc::AudioEncoderOpus>();
|
||||
media_deps.audio_decoder_factory =
|
||||
webrtc::CreateAudioDecoderFactory<webrtc::AudioDecoderOpus>();
|
||||
media_deps.video_encoder_factory = CreateBuiltinVideoEncoderFactory();
|
||||
media_deps.video_decoder_factory = webrtc::CreateBuiltinVideoDecoderFactory();
|
||||
media_deps.audio_processing = webrtc::AudioProcessingBuilder().Create();
|
||||
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 pcf_deps;
|
||||
pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory();
|
||||
pcf_deps.signaling_thread = rtc::Thread::Current();
|
||||
pcf_deps.network_thread = rtc::Thread::Current();
|
||||
pcf_deps.worker_thread = rtc::Thread::Current();
|
||||
pcf_deps.call_factory = webrtc::CreateCallFactory();
|
||||
pcf_deps.event_log_factory = std::make_unique<webrtc::RtcEventLogFactory>(
|
||||
pcf_deps.task_queue_factory.get());
|
||||
auto media_deps = CreateSomeMediaDeps(pcf_deps.task_queue_factory.get());
|
||||
pcf_deps.media_engine = cricket::CreateMediaEngine(std::move(media_deps));
|
||||
return pcf_deps;
|
||||
}
|
||||
|
||||
TEST(WebRTCLinkTest, TestCreatingAPeerConnectionViaModularFactory) {
|
||||
auto pcf_deps = CreateSomePcfDeps();
|
||||
auto peer_connection_factory =
|
||||
webrtc::CreateModularPeerConnectionFactory(std::move(pcf_deps));
|
||||
webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
|
||||
auto peer_connection = peer_connection_factory->CreatePeerConnection(
|
||||
rtc_config, nullptr, nullptr, nullptr);
|
||||
ASSERT_EQ(peer_connection.get(), nullptr)
|
||||
<< "Should fail, we're not setting things up right";
|
||||
}
|
||||
|
||||
TEST(WebRTCLinkTest, TestCreatingViaPCFactory) {
|
||||
auto task_queue_factory = CreateDefaultTaskQueueFactory();
|
||||
auto media_deps = CreateSomeMediaDeps(task_queue_factory.get());
|
||||
|
||||
auto peer_connection_factory = webrtc::CreatePeerConnectionFactory(
|
||||
rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(),
|
||||
std::move(media_deps.adm), std::move(media_deps.audio_encoder_factory),
|
||||
std::move(media_deps.audio_decoder_factory),
|
||||
std::move(media_deps.video_encoder_factory),
|
||||
std::move(media_deps.video_decoder_factory), nullptr, nullptr);
|
||||
ASSERT_NE(peer_connection_factory.get(), nullptr);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
Loading…
Reference in a new issue