diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-10-13 15:19:32 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-10-13 15:19:32 +0000 |
commit | 6da82f84b01c73f0f4b91446a5509c7bffeb493a (patch) | |
tree | 741655a4f4f4af51f5e6c14487e3ddbc9d52e624 /unittests/Driver | |
parent | d981a124bf68ae6c8fd2d0863cdc63aae0a06e7e (diff) | |
download | clang-6da82f84b01c73f0f4b91446a5509c7bffeb493a.tar.gz |
[Driver] Use the parent_path of the clang executable as the default InstalledDir
This is what most people want anyways. Clang -cc1's main() will override
this but for other tools this is the most sensible default and avoids
some work.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250164 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Driver')
-rw-r--r-- | unittests/Driver/ToolChainTest.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/unittests/Driver/ToolChainTest.cpp b/unittests/Driver/ToolChainTest.cpp index a2d6f29e12..5159e80cc7 100644 --- a/unittests/Driver/ToolChainTest.cpp +++ b/unittests/Driver/ToolChainTest.cpp @@ -33,12 +33,12 @@ TEST(ToolChainTest, VFSGCCInstallation) { DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer); IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem( new vfs::InMemoryFileSystem); - Driver TheDriver("/usr/bin/clang", "arm-linux-gnueabihf", Diags, + Driver TheDriver("/bin/clang", "arm-linux-gnueabihf", Diags, InMemoryFileSystem); const char *EmptyFiles[] = { "foo.cpp", - "/usr/bin/clang", + "/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", @@ -78,4 +78,43 @@ TEST(ToolChainTest, VFSGCCInstallation) { S); } +TEST(ToolChainTest, VFSGCCInstallationRelativeDir) { + 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("/home/test/bin/clang", "arm-linux-gnueabi", Diags, + InMemoryFileSystem); + + const char *EmptyFiles[] = { + "foo.cpp", "/home/test/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o", + "/home/test/include/arm-linux-gnueabi/.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); + } +#if LLVM_ON_WIN32 + std::replace(S.begin(), S.end(), '\\', '/'); +#endif + EXPECT_EQ("Found candidate GCC installation: " + "/home/test/lib/gcc/arm-linux-gnueabi/4.6.1\n" + "Selected GCC installation: " + "/home/test/bin/../lib/gcc/arm-linux-gnueabi/4.6.1\n" + "Candidate multilib: .;@m32\n" + "Selected multilib: .;@m32\n", + S); +} + } // end anonymous namespace |