Deletion of temp files in modules_unittests.

Temporary files created by AudioFormat tests in modules_unittest are
removed after each test case rather than after the whole suite is
finished. This saves disk space on the running device.

Bug: webrtc:8344
Change-Id: Iace3a7a62bb06e15fa596caf32da873944654c9a
Reviewed-on: https://webrtc-review.googlesource.com/8100
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20244}
diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc
index 3bf6fd2..854d6a5 100644
--- a/modules/audio_processing/audio_processing_unittest.cc
+++ b/modules/audio_processing/audio_processing_unittest.cc
@@ -308,6 +308,19 @@
     remove(kv.second.c_str());
 }
 
+// Only remove "out" files. Keep "ref" files.
+void ClearTempOutFiles() {
+  for (auto it = temp_filenames.begin(); it != temp_filenames.end();) {
+    const std::string& filename = it->first;
+    if (filename.substr(0, 3).compare("out") == 0) {
+      remove(it->second.c_str());
+      temp_filenames.erase(it++);
+    } else {
+      it++;
+    }
+  }
+}
+
 void OpenFileAndReadMessage(const std::string& filename, MessageLite* msg) {
   FILE* file = fopen(filename.c_str(), "rb");
   ASSERT_TRUE(file != NULL);
@@ -2422,6 +2435,11 @@
     }
   }
 
+  void TearDown() {
+    // Remove "out" files after each test.
+    ClearTempOutFiles();
+  }
+
   static void TearDownTestCase() {
     ClearTempFiles();
   }