diff options
author | dim <dim@FreeBSD.org> | 2013-04-08 18:41:23 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-04-08 18:41:23 +0000 |
commit | 169d2bd06003c39970bc94c99669a34b61bb7e45 (patch) | |
tree | 06099edc18d30894081a822b756f117cbe0b8207 /unittests/Support/FileOutputBufferTest.cpp | |
parent | 0ac5f94c68a3d8fbd1380dbba26d891ea7816b5e (diff) | |
download | FreeBSD-src-169d2bd06003c39970bc94c99669a34b61bb7e45.zip FreeBSD-src-169d2bd06003c39970bc94c99669a34b61bb7e45.tar.gz |
Vendor import of llvm trunk r178860:
http://llvm.org/svn/llvm-project/llvm/trunk@178860
Diffstat (limited to 'unittests/Support/FileOutputBufferTest.cpp')
-rw-r--r-- | unittests/Support/FileOutputBufferTest.cpp | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/unittests/Support/FileOutputBufferTest.cpp b/unittests/Support/FileOutputBufferTest.cpp index edd350a..80d7245 100644 --- a/unittests/Support/FileOutputBufferTest.cpp +++ b/unittests/Support/FileOutputBufferTest.cpp @@ -7,13 +7,12 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Support/FileOutputBuffer.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/FileOutputBuffer.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/PathV2.h" #include "llvm/Support/raw_ostream.h" - #include "gtest/gtest.h" using namespace llvm; @@ -27,13 +26,6 @@ using namespace llvm::sys; } else {} namespace { - - -// NOTE: Temporarily run this test on unix only. Once the file mapping -// routines are ported to Windows, this conditional can be removed. -#if LLVM_ON_UNIX - - TEST(FileOutputBuffer, Test) { // Create unique temporary directory for these tests SmallString<128> TestDirectory; @@ -45,7 +37,7 @@ TEST(FileOutputBuffer, Test) { ::close(fd); TestDirectory = path::parent_path(TestDirectory); } - + // TEST 1: Verify commit case. SmallString<128> File1(TestDirectory); File1.append("/file1"); @@ -61,7 +53,7 @@ TEST(FileOutputBuffer, Test) { } // Verify file exists and starts with special header. bool MagicMatches = false; - ASSERT_NO_ERROR(fs::has_magic(Twine(File1), Twine("AABBCCDDEEFFGGHHIIJJ"), + ASSERT_NO_ERROR(fs::has_magic(Twine(File1), Twine("AABBCCDDEEFFGGHHIIJJ"), MagicMatches)); EXPECT_TRUE(MagicMatches); // Verify file is correct size. @@ -82,8 +74,7 @@ TEST(FileOutputBuffer, Test) { // Verify file does not exist (because buffer not commited). bool Exists = false; ASSERT_NO_ERROR(fs::exists(Twine(File2), Exists)); - EXPECT_FALSE(Exists); - + EXPECT_FALSE(Exists); // TEST 3: Verify sizing down case. SmallString<128> File3(TestDirectory); @@ -100,7 +91,7 @@ TEST(FileOutputBuffer, Test) { } // Verify file exists and starts with special header. bool MagicMatches3 = false; - ASSERT_NO_ERROR(fs::has_magic(Twine(File3), Twine("AABBCCDDEEFFGGHHIIJJ"), + ASSERT_NO_ERROR(fs::has_magic(Twine(File3), Twine("AABBCCDDEEFFGGHHIIJJ"), MagicMatches3)); EXPECT_TRUE(MagicMatches3); // Verify file is correct size. @@ -108,13 +99,12 @@ TEST(FileOutputBuffer, Test) { ASSERT_NO_ERROR(fs::file_size(Twine(File3), File3Size)); ASSERT_EQ(File3Size, 5000ULL); - // TEST 4: Verify file can be made executable. SmallString<128> File4(TestDirectory); File4.append("/file4"); { OwningPtr<FileOutputBuffer> Buffer; - ASSERT_NO_ERROR(FileOutputBuffer::create(File4, 8192, Buffer, + ASSERT_NO_ERROR(FileOutputBuffer::create(File4, 8192, Buffer, FileOutputBuffer::F_executable)); // Start buffer with special header. memcpy(Buffer->getBufferStart(), "AABBCCDDEEFFGGHHIIJJ", 20); @@ -131,7 +121,4 @@ TEST(FileOutputBuffer, Test) { uint32_t RemovedCount; ASSERT_NO_ERROR(fs::remove_all(TestDirectory.str(), RemovedCount)); } - -#endif // LLVM_ON_UNIX - } // anonymous namespace |