From 8ffeeb2e346d5ca994db061e204c09a84ef473d6 Mon Sep 17 00:00:00 2001 From: Gustaf Ullberg Date: Wed, 11 Oct 2017 11:42:38 +0200 Subject: [PATCH] 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 Commit-Queue: Gustaf Ullberg Cr-Commit-Position: refs/heads/master@{#20244} --- .../audio_processing_unittest.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc index 3bf6fd263e..854d6a552c 100644 --- a/modules/audio_processing/audio_processing_unittest.cc +++ b/modules/audio_processing/audio_processing_unittest.cc @@ -308,6 +308,19 @@ void ClearTempFiles() { 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 @@ class AudioProcessingTest } } + void TearDown() { + // Remove "out" files after each test. + ClearTempOutFiles(); + } + static void TearDownTestCase() { ClearTempFiles(); }