summaryrefslogtreecommitdiffstats
path: root/unittests/Support/MemoryBufferTest.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-09-02 00:51:34 +0000
committerReid Kleckner <rnk@google.com>2016-09-02 00:51:34 +0000
commit62525658faf2d79776e5b6189944a38fab7f5aba (patch)
tree2d9ffc46fc5126569203b8ce599b17f02d031957 /unittests/Support/MemoryBufferTest.cpp
parentc367442e0e409371afc7855218e29a383a2d3787 (diff)
Try to fix some temp file leaks in SupportTests, PR18335
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280443 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Support/MemoryBufferTest.cpp')
-rw-r--r--unittests/Support/MemoryBufferTest.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/unittests/Support/MemoryBufferTest.cpp b/unittests/Support/MemoryBufferTest.cpp
index 963dcd91c8b6..0efa22c157d9 100644
--- a/unittests/Support/MemoryBufferTest.cpp
+++ b/unittests/Support/MemoryBufferTest.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
@@ -71,6 +72,7 @@ TEST_F(MemoryBufferTest, NullTerminator4K) {
SmallString<64> TestPath;
sys::fs::createTemporaryFile("MemoryBufferTest_NullTerminator4K", "temp",
TestFD, TestPath);
+ FileRemover Cleanup(TestPath);
raw_fd_ostream OF(TestFD, true, /*unbuffered=*/true);
for (unsigned i = 0; i < 4096 / 16; ++i) {
OF << "0123456789abcdef";
@@ -133,6 +135,7 @@ void MemoryBufferTest::testGetOpenFileSlice(bool Reopen) {
SmallString<64> TestPath;
// Create a temporary file and write data into it.
sys::fs::createTemporaryFile("prefix", "temp", TestFD, TestPath);
+ FileRemover Cleanup(TestPath);
// OF is responsible for closing the file; If the file is not
// reopened, it will be unbuffered so that the results are
// immediately visible through the fd.
@@ -182,6 +185,7 @@ TEST_F(MemoryBufferTest, slice) {
int FD;
SmallString<64> TestPath;
sys::fs::createTemporaryFile("MemoryBufferTest_Slice", "temp", FD, TestPath);
+ FileRemover Cleanup(TestPath);
raw_fd_ostream OF(FD, true, /*unbuffered=*/true);
for (unsigned i = 0; i < 0x2000 / 8; ++i) {
OF << "12345678";