diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2012-12-03 22:09:52 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2012-12-03 22:09:52 +0000 |
commit | 6bc86018d189e9ab62d30ef8190bac961dd22248 (patch) | |
tree | b4aec1c621c61c7cd6284fd788705ed9ef027e85 /unittests/Support | |
parent | 604db310f0d1bbb612ed4c792979c6d3aecdbc1c (diff) |
[Support] Make FileOutputBuffer work on Windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Support')
-rw-r--r-- | unittests/Support/FileOutputBufferTest.cpp | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/unittests/Support/FileOutputBufferTest.cpp b/unittests/Support/FileOutputBufferTest.cpp index edd350afcf..4c0d57b845 100644 --- a/unittests/Support/FileOutputBufferTest.cpp +++ b/unittests/Support/FileOutputBufferTest.cpp @@ -7,9 +7,10 @@ // //===----------------------------------------------------------------------===// +#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" @@ -27,13 +28,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 +39,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 +55,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 +76,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 +93,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 +101,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 +123,4 @@ TEST(FileOutputBuffer, Test) { uint32_t RemovedCount; ASSERT_NO_ERROR(fs::remove_all(TestDirectory.str(), RemovedCount)); } - -#endif // LLVM_ON_UNIX - } // anonymous namespace |