Disable AudioDeviceTest unittests under sanitizers.

Both the tests and the code under test are very old, unstaffed and not
a part of webRTC stack.
Here sanitizers make the tests hang, without providing useful report.
So we are just disabling them, without intention to re-enable them.

Bug: webrtc:10951
Change-Id: I40e97208606ba3f0eb5b19d404f7d038e6cc2bdf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152487
Commit-Queue: Yves Gerey <yvesg@google.com>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29157}
diff --git a/modules/audio_device/audio_device_unittest.cc b/modules/audio_device/audio_device_unittest.cc
index 55382a5..cd6be0a 100644
--- a/modules/audio_device/audio_device_unittest.cc
+++ b/modules/audio_device/audio_device_unittest.cc
@@ -501,10 +501,22 @@
 
 // AudioDeviceTest test fixture.
 
-class AudioDeviceTest
+// bugs.webrtc.org/9808
+// Both the tests and the code under test are very old, unstaffed and not
+// a part of webRTC stack.
+// Here sanitizers make the tests hang, without providing usefull report.
+// So we are just disabling them, without intention to re-enable them.
+#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
+    defined(THREAD_SANITIZER) || defined(UNDEFINED_SANITIZER)
+#define MAYBE_AudioDeviceTest DISABLED_AudioDeviceTest
+#else
+#define MAYBE_AudioDeviceTest AudioDeviceTest
+#endif
+
+class MAYBE_AudioDeviceTest
     : public ::testing::TestWithParam<webrtc::AudioDeviceModule::AudioLayer> {
  protected:
-  AudioDeviceTest()
+  MAYBE_AudioDeviceTest()
       : audio_layer_(GetParam()),
         task_queue_factory_(CreateDefaultTaskQueueFactory()) {
     rtc::LogMessage::LogToDebug(rtc::LS_INFO);
@@ -553,7 +565,7 @@
   // An alternative would be for the mock to outlive audio_device.
   void PreTearDown() { EXPECT_EQ(0, audio_device_->Terminate()); }
 
-  virtual ~AudioDeviceTest() {
+  virtual ~MAYBE_AudioDeviceTest() {
     if (audio_device_) {
       EXPECT_EQ(0, audio_device_->Terminate());
     }
@@ -655,7 +667,7 @@
 
 // Instead of using the test fixture, verify that the different factory methods
 // work as intended.
-TEST(AudioDeviceTestWin, ConstructDestructWithFactory) {
+TEST(MAYBE_AudioDeviceTestWin, ConstructDestructWithFactory) {
   std::unique_ptr<TaskQueueFactory> task_queue_factory =
       CreateDefaultTaskQueueFactory();
   rtc::scoped_refptr<AudioDeviceModule> audio_device;
@@ -691,9 +703,9 @@
 }
 
 // Uses the test fixture to create, initialize and destruct the ADM.
-TEST_P(AudioDeviceTest, ConstructDestructDefault) {}
+TEST_P(MAYBE_AudioDeviceTest, ConstructDestructDefault) {}
 
-TEST_P(AudioDeviceTest, InitTerminate) {
+TEST_P(MAYBE_AudioDeviceTest, InitTerminate) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   // Initialization is part of the test fixture.
   EXPECT_TRUE(audio_device()->Initialized());
@@ -702,7 +714,7 @@
 }
 
 // Enumerate all available and active output devices.
-TEST_P(AudioDeviceTest, PlayoutDeviceNames) {
+TEST_P(MAYBE_AudioDeviceTest, PlayoutDeviceNames) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   char device_name[kAdmMaxDeviceNameSize];
   char unique_id[kAdmMaxGuidSize];
@@ -719,7 +731,7 @@
 }
 
 // Enumerate all available and active input devices.
-TEST_P(AudioDeviceTest, RecordingDeviceNames) {
+TEST_P(MAYBE_AudioDeviceTest, RecordingDeviceNames) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   char device_name[kAdmMaxDeviceNameSize];
   char unique_id[kAdmMaxGuidSize];
@@ -737,7 +749,7 @@
 }
 
 // Counts number of active output devices and ensure that all can be selected.
-TEST_P(AudioDeviceTest, SetPlayoutDevice) {
+TEST_P(MAYBE_AudioDeviceTest, SetPlayoutDevice) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   int num_devices = audio_device()->PlayoutDevices();
   if (NewWindowsAudioDeviceModuleIsUsed()) {
@@ -760,7 +772,7 @@
 }
 
 // Counts number of active input devices and ensure that all can be selected.
-TEST_P(AudioDeviceTest, SetRecordingDevice) {
+TEST_P(MAYBE_AudioDeviceTest, SetRecordingDevice) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   int num_devices = audio_device()->RecordingDevices();
   if (NewWindowsAudioDeviceModuleIsUsed()) {
@@ -783,14 +795,14 @@
 }
 
 // Tests Start/Stop playout without any registered audio callback.
-TEST_P(AudioDeviceTest, StartStopPlayout) {
+TEST_P(MAYBE_AudioDeviceTest, StartStopPlayout) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   StartPlayout();
   StopPlayout();
 }
 
 // Tests Start/Stop recording without any registered audio callback.
-TEST_P(AudioDeviceTest, StartStopRecording) {
+TEST_P(MAYBE_AudioDeviceTest, StartStopRecording) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   StartRecording();
   StopRecording();
@@ -799,7 +811,7 @@
 // Tests Init/Stop/Init recording without any registered audio callback.
 // See https://bugs.chromium.org/p/webrtc/issues/detail?id=8041 for details
 // on why this test is useful.
-TEST_P(AudioDeviceTest, InitStopInitRecording) {
+TEST_P(MAYBE_AudioDeviceTest, InitStopInitRecording) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   EXPECT_EQ(0, audio_device()->InitRecording());
   EXPECT_TRUE(audio_device()->RecordingIsInitialized());
@@ -810,7 +822,7 @@
 
 // Verify that additional attempts to initialize or start recording while
 // already being active works. Additional calls should just be ignored.
-TEST_P(AudioDeviceTest, StartInitRecording) {
+TEST_P(MAYBE_AudioDeviceTest, StartInitRecording) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   StartRecording();
   // An additional attempt to initialize at this stage should be ignored.
@@ -822,7 +834,7 @@
 
 // Verify that additional attempts to initialize or start playou while
 // already being active works. Additional calls should just be ignored.
-TEST_P(AudioDeviceTest, StartInitPlayout) {
+TEST_P(MAYBE_AudioDeviceTest, StartInitPlayout) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   StartPlayout();
   // An additional attempt to initialize at this stage should be ignored.
@@ -833,7 +845,7 @@
 }
 
 // Tests Init/Stop/Init recording while playout is active.
-TEST_P(AudioDeviceTest, InitStopInitRecordingWhilePlaying) {
+TEST_P(MAYBE_AudioDeviceTest, InitStopInitRecordingWhilePlaying) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   StartPlayout();
   EXPECT_EQ(0, audio_device()->InitRecording());
@@ -845,7 +857,7 @@
 }
 
 // Tests Init/Stop/Init playout without any registered audio callback.
-TEST_P(AudioDeviceTest, InitStopInitPlayout) {
+TEST_P(MAYBE_AudioDeviceTest, InitStopInitPlayout) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   EXPECT_EQ(0, audio_device()->InitPlayout());
   EXPECT_TRUE(audio_device()->PlayoutIsInitialized());
@@ -855,7 +867,7 @@
 }
 
 // Tests Init/Stop/Init playout while recording is active.
-TEST_P(AudioDeviceTest, InitStopInitPlayoutWhileRecording) {
+TEST_P(MAYBE_AudioDeviceTest, InitStopInitPlayoutWhileRecording) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   StartRecording();
   EXPECT_EQ(0, audio_device()->InitPlayout());
@@ -871,7 +883,7 @@
 #ifdef WEBRTC_WIN
 // Tests Start/Stop playout followed by a second session (emulates a restart
 // triggered by a user using public APIs).
-TEST_P(AudioDeviceTest, StartStopPlayoutWithExternalRestart) {
+TEST_P(MAYBE_AudioDeviceTest, StartStopPlayoutWithExternalRestart) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   StartPlayout();
   StopPlayout();
@@ -883,7 +895,7 @@
 
 // Tests Start/Stop recording followed by a second session (emulates a restart
 // triggered by a user using public APIs).
-TEST_P(AudioDeviceTest, StartStopRecordingWithExternalRestart) {
+TEST_P(MAYBE_AudioDeviceTest, StartStopRecordingWithExternalRestart) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   StartRecording();
   StopRecording();
@@ -897,7 +909,7 @@
 // triggered by an internal callback e.g. corresponding to a device switch).
 // Note that, internal restart is only supported in combination with the latest
 // Windows ADM.
-TEST_P(AudioDeviceTest, StartStopPlayoutWithInternalRestart) {
+TEST_P(MAYBE_AudioDeviceTest, StartStopPlayoutWithInternalRestart) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   if (audio_layer() != AudioDeviceModule::kWindowsCoreAudio2) {
     return;
@@ -942,7 +954,7 @@
 // triggered by an internal callback e.g. corresponding to a device switch).
 // Note that, internal restart is only supported in combination with the latest
 // Windows ADM.
-TEST_P(AudioDeviceTest, StartStopRecordingWithInternalRestart) {
+TEST_P(MAYBE_AudioDeviceTest, StartStopRecordingWithInternalRestart) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   if (audio_layer() != AudioDeviceModule::kWindowsCoreAudio2) {
     return;
@@ -991,7 +1003,7 @@
 // Note that we can't add expectations on audio parameters in EXPECT_CALL
 // since parameter are not provided in the each callback. We therefore test and
 // verify the parameters in the fake audio transport implementation instead.
-TEST_P(AudioDeviceTest, StartPlayoutVerifyCallbacks) {
+TEST_P(MAYBE_AudioDeviceTest, StartPlayoutVerifyCallbacks) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   MockAudioTransport mock(TransportType::kPlay);
   mock.HandleCallbacks(event(), nullptr, kNumCallbacks);
@@ -1023,7 +1035,7 @@
 
 // Start recording and verify that the native audio layer starts providing real
 // audio samples using the RecordedDataIsAvailable() callback.
-TEST_P(AudioDeviceTest, MAYBE_StartRecordingVerifyCallbacks) {
+TEST_P(MAYBE_AudioDeviceTest, MAYBE_StartRecordingVerifyCallbacks) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   MockAudioTransport mock(TransportType::kRecord);
   mock.HandleCallbacks(event(), nullptr, kNumCallbacks);
@@ -1039,7 +1051,7 @@
 
 // Start playout and recording (full-duplex audio) and verify that audio is
 // active in both directions.
-TEST_P(AudioDeviceTest, MAYBE_StartPlayoutAndRecordingVerifyCallbacks) {
+TEST_P(MAYBE_AudioDeviceTest, MAYBE_StartPlayoutAndRecordingVerifyCallbacks) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   MockAudioTransport mock(TransportType::kPlayAndRecord);
   mock.HandleCallbacks(event(), nullptr, kNumCallbacks);
@@ -1069,7 +1081,7 @@
 // sequence by running in loopback for a few seconds while measuring the size
 // (max and average) of the FIFO. The size of the FIFO is increased by the
 // recording side and decreased by the playout side.
-TEST_P(AudioDeviceTest, RunPlayoutAndRecordingInFullDuplex) {
+TEST_P(MAYBE_AudioDeviceTest, RunPlayoutAndRecordingInFullDuplex) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   NiceMock<MockAudioTransport> mock(TransportType::kPlayAndRecord);
   FifoAudioStream audio_stream;
@@ -1102,7 +1114,7 @@
 // Runs audio in full duplex until user hits Enter. Intended as a manual test
 // to ensure that the audio quality is good and that real device switches works
 // as intended.
-TEST_P(AudioDeviceTest,
+TEST_P(MAYBE_AudioDeviceTest,
        DISABLED_RunPlayoutAndRecordingInFullDuplexAndWaitForEnterKey) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   if (audio_layer() != AudioDeviceModule::kWindowsCoreAudio2) {
@@ -1140,7 +1152,7 @@
 // some sort of audio feedback loop. E.g. a headset where the mic is placed
 // close to the speaker to ensure highest possible echo. It is also recommended
 // to run the test at highest possible output volume.
-TEST_P(AudioDeviceTest, DISABLED_MeasureLoopbackLatency) {
+TEST_P(MAYBE_AudioDeviceTest, DISABLED_MeasureLoopbackLatency) {
   SKIP_TEST_IF_NOT(requirements_satisfied());
   NiceMock<MockAudioTransport> mock(TransportType::kPlayAndRecord);
   LatencyAudioStream audio_stream;
@@ -1170,14 +1182,14 @@
 // implementations) for Windows.
 INSTANTIATE_TEST_SUITE_P(
     AudioLayerWin,
-    AudioDeviceTest,
+    MAYBE_AudioDeviceTest,
     ::testing::Values(AudioDeviceModule::kPlatformDefaultAudio,
                       AudioDeviceModule::kWindowsCoreAudio2));
 #else
 // For all platforms but Windows, only test the default audio layer.
 INSTANTIATE_TEST_SUITE_P(
     AudioLayer,
-    AudioDeviceTest,
+    MAYBE_AudioDeviceTest,
     ::testing::Values(AudioDeviceModule::kPlatformDefaultAudio));
 #endif