summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit75e557f1fd9392a20989e57d31eaa1878f7ca9c1 (patch)
treea461719db45df760167f6def422e480352ad58c3 /llvm/unittests/Support/MemoryBufferTest.cpp
parent1200a050ff59e16631972e25e93f24d34b982115 (diff)
downloadbcm5719-llvm-75e557f1fd9392a20989e57d31eaa1878f7ca9c1.tar.gz
bcm5719-llvm-75e557f1fd9392a20989e57d31eaa1878f7ca9c1.zip
Try to fix some temp file leaks in SupportTests, PR18335
llvm-svn: 280443
Diffstat (limited to 'llvm/unittests/Support/MemoryBufferTest.cpp')
-rw-r--r--llvm/unittests/Support/MemoryBufferTest.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/unittests/Support/MemoryBufferTest.cpp b/llvm/unittests/Support/MemoryBufferTest.cpp
index 963dcd91c8b..0efa22c157d 100644
--- a/llvm/unittests/Support/MemoryBufferTest.cpp
+++ b/llvm/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";
OpenPOWER on IntegriCloud