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}
diff --git a/BUILD.gn b/BUILD.gn
index f7eca78..cdc2b4e 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -42,6 +42,7 @@
         ":rtc_unittests",
         ":slow_tests",
         ":video_engine_tests",
+        ":webrtc_lib_link_test",
         ":webrtc_nonparallel_tests",
         ":webrtc_perf_tests",
         "common_audio:common_audio_unittests",
@@ -73,9 +74,6 @@
       } 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",
@@ -466,19 +464,17 @@
     }
   }
 
-  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") {
+  if (rtc_include_tests) {
+    rtc_executable("webrtc_lib_link_test") {
       testonly = true
 
       sources = [
         "webrtc_lib_link_test.cc",
       ]
       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",
-        "//test:test_main",
-        "//testing/gtest",
       ]
     }
   }
diff --git a/webrtc_lib_link_test.cc b/webrtc_lib_link_test.cc
index afd787f..37e1b14 100644
--- a/webrtc_lib_link_test.cc
+++ b/webrtc_lib_link_test.cc
@@ -24,8 +24,6 @@
 #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(
@@ -44,8 +42,6 @@
   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();
@@ -60,18 +56,21 @@
   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 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";
+  printf("peer_connection=%s\n", peer_connection == nullptr ? "nullptr" : "ok");
 }
 
-TEST(WebRTCLinkTest, TestCreatingViaPCFactory) {
+void TestCase2RegularFactory() {
   auto task_queue_factory = CreateDefaultTaskQueueFactory();
   auto media_deps = CreateSomeMediaDeps(task_queue_factory.get());
 
@@ -81,7 +80,16 @@
       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);
+  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
+
+int main(int argc, char** argv) {
+  webrtc::TestCase1ModularFactory();
+  webrtc::TestCase2RegularFactory();
+  return 0;
+}