mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
[Support] Make FileOutputBuffer work on Windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169167 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user