diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2013-12-19 00:41:03 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2013-12-19 00:41:03 +0000 |
commit | 2fcb0c34b324bb7fb80f74b8d14db8cfd2892916 (patch) | |
tree | 3d5ced4d1c5faad683b3a836c43ad09d34e6013a /unittests | |
parent | d218959ec5e6c7d3b129f9437bc243b9bdab9e27 (diff) |
ArchiveFileDescriptorTests: Resurrect part of r197600, but make it invalidated, to appease buildbots.
Please revert this several hours later ;)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197635 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/ArchiveFileDescriptor/ArchiveFileDescriptor.cpp | 55 | ||||
-rw-r--r-- | unittests/ArchiveFileDescriptor/CMakeLists.txt | 8 | ||||
-rw-r--r-- | unittests/ArchiveFileDescriptor/Makefile | 15 | ||||
-rw-r--r-- | unittests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | unittests/Makefile | 4 |
5 files changed, 81 insertions, 2 deletions
diff --git a/unittests/ArchiveFileDescriptor/ArchiveFileDescriptor.cpp b/unittests/ArchiveFileDescriptor/ArchiveFileDescriptor.cpp new file mode 100644 index 00000000000..1cafa248fe4 --- /dev/null +++ b/unittests/ArchiveFileDescriptor/ArchiveFileDescriptor.cpp @@ -0,0 +1,55 @@ +//===- llvm/unittest/ArchiveFileDescriptor/ArchiveFileDescriptor.cpp ------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Object/Archive.h" +#include "llvm/Object/ObjectFile.h" +#include "llvm/Support/MemoryBuffer.h" +#include "gtest/gtest.h" + +using namespace llvm; +using namespace llvm::object; + +static void failIfError(error_code EC) { + if (!EC) + return; + + errs() << "ERROR: " << EC.message() << "\n"; + exit(1); +} + +TEST(ArchiveFileDescriptor, Test1) { +#if 0 // FIXME: It may be reverted. + int FD; + + error_code EC = sys::fs::openFileForRead("ArchiveFileDescriptor", FD); + failIfError(EC); + + OwningPtr<MemoryBuffer> MemoryBuffer; + EC = MemoryBuffer::getOpenFile(FD, "Dummy Filename", + MemoryBuffer, + /* FileSize */ -1, + /* RequiresNullTerminator */ false); + failIfError(EC); + + // Attempt to open the binary. + OwningPtr<Binary> Binary; + EC = createBinary(MemoryBuffer.take(), Binary); + failIfError(EC); + + if (Archive *Arc = dyn_cast<Archive>(Binary.get())) { + (void)Arc; + errs() << "ERROR: Loaded archive, was expecting object file\n"; + } else if (ObjectFile *Obj = dyn_cast<ObjectFile>(Binary.get())) { + (void)Obj; + } else { + outs() << "ERROR: Unknown file type\n"; + exit(1); + } +#endif +} diff --git a/unittests/ArchiveFileDescriptor/CMakeLists.txt b/unittests/ArchiveFileDescriptor/CMakeLists.txt new file mode 100644 index 00000000000..c7e292ad647 --- /dev/null +++ b/unittests/ArchiveFileDescriptor/CMakeLists.txt @@ -0,0 +1,8 @@ +set(LLVM_LINK_COMPONENTS + Object + Support + ) + +add_llvm_unittest(ArchiveFileDescriptor + ArchiveFileDescriptor.cpp + ) diff --git a/unittests/ArchiveFileDescriptor/Makefile b/unittests/ArchiveFileDescriptor/Makefile new file mode 100644 index 00000000000..460b86c0a05 --- /dev/null +++ b/unittests/ArchiveFileDescriptor/Makefile @@ -0,0 +1,15 @@ +##===- unittests/ArchiveFileDescriptor/Makefile ------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +TESTNAME = ArchiveFileDescriptor +LINK_COMPONENTS := object + +include $(LEVEL)/Makefile.config +include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 52702ba23aa..9857e787eeb 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -7,6 +7,7 @@ endfunction() add_subdirectory(ADT) add_subdirectory(Analysis) +add_subdirectory(ArchiveFileDescriptor) add_subdirectory(Bitcode) add_subdirectory(CodeGen) add_subdirectory(DebugInfo) diff --git a/unittests/Makefile b/unittests/Makefile index 06ba93243e3..d80cab26212 100644 --- a/unittests/Makefile +++ b/unittests/Makefile @@ -9,8 +9,8 @@ LEVEL = .. -PARALLEL_DIRS = ADT Analysis Bitcode CodeGen DebugInfo ExecutionEngine IR \ - MC Object Option Support Transforms +PARALLEL_DIRS = ADT Analysis ArchiveFileDescriptor Bitcode CodeGen DebugInfo \ + ExecutionEngine IR MC Object Option Support Transforms include $(LEVEL)/Makefile.common |