diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-10-07 15:48:01 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-10-07 15:48:01 +0000 |
commit | 032169da0a54b372a2d7e5f9f75a069c7034b9f7 (patch) | |
tree | 3157ff94d15a72fd8414c49a4cd97b158b252494 /unittests/Driver | |
parent | ed6a9434ed1e6034d378ce9177af2ff8e9329bbc (diff) | |
download | clang-032169da0a54b372a2d7e5f9f75a069c7034b9f7.tar.gz |
[VFS] Port driver tool chains to VFS.
There are still some loose ends here but it's sufficient so we can detect
GCC headers that are inside of a VFS.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249556 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Driver')
-rw-r--r-- | unittests/Driver/CMakeLists.txt | 1 | ||||
-rw-r--r-- | unittests/Driver/ToolChainTest.cpp | 74 |
2 files changed, 75 insertions, 0 deletions
diff --git a/unittests/Driver/CMakeLists.txt b/unittests/Driver/CMakeLists.txt index 8cc963b33a..acd0b76a12 100644 --- a/unittests/Driver/CMakeLists.txt +++ b/unittests/Driver/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS ) add_clang_unittest(ClangDriverTests + ToolChainTest.cpp MultilibTest.cpp ) diff --git a/unittests/Driver/ToolChainTest.cpp b/unittests/Driver/ToolChainTest.cpp new file mode 100644 index 0000000000..8fddc9b6a0 --- /dev/null +++ b/unittests/Driver/ToolChainTest.cpp @@ -0,0 +1,74 @@ +//===- unittests/Driver/ToolChainTest.cpp --- ToolChain tests -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Unit tests for ToolChains. +// +//===----------------------------------------------------------------------===// + +#include "clang/Driver/ToolChain.h" +#include "clang/Basic/DiagnosticIDs.h" +#include "clang/Basic/DiagnosticOptions.h" +#include "clang/Basic/LLVM.h" +#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Driver/Compilation.h" +#include "clang/Driver/Driver.h" +#include "llvm/Support/raw_ostream.h" +#include "gtest/gtest.h" +using namespace clang; +using namespace clang::driver; + +namespace { + +TEST(ToolChainTest, VFSGCCInstallation) { + IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions(); + + IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); + struct TestDiagnosticConsumer : public DiagnosticConsumer {}; + DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer); + IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem( + new vfs::InMemoryFileSystem); + Driver TheDriver("/usr/bin/clang", "arm-linux-gnueabihf", Diags, + InMemoryFileSystem); + + const char *EmptyFiles[] = { + "foo.cpp", + "/usr/bin/clang", + "/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o", + "/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o", + "/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o", + "/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o", + "/usr/lib/arm-linux-gnueabi/crt1.o", + "/usr/lib/arm-linux-gnueabi/crti.o", + "/usr/lib/arm-linux-gnueabi/crtn.o", + "/usr/lib/arm-linux-gnueabihf/crt1.o", + "/usr/lib/arm-linux-gnueabihf/crti.o", + "/usr/lib/arm-linux-gnueabihf/crtn.o", + "/usr/include/arm-linux-gnueabi/.keep", + "/usr/include/arm-linux-gnueabihf/.keep", + "/lib/arm-linux-gnueabi/.keep", + "/lib/arm-linux-gnueabihf/.keep"}; + + for (const char *Path : EmptyFiles) + InMemoryFileSystem->addFile(Path, 0, + llvm::MemoryBuffer::getMemBuffer("\n")); + + std::unique_ptr<Compilation> C( + TheDriver.BuildCompilation({"-fsyntax-only", "foo.cpp"})); + + std::string S; + { + llvm::raw_string_ostream OS(S); + C->getDefaultToolChain().printVerboseInfo(OS); + } + EXPECT_EQ("Found candidate GCC installation: " + "/usr/lib/gcc/arm-linux-gnueabihf/4.6.3\n", + S); +} + +} // end anonymous namespace |