aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Driver/ToolChainTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Driver/ToolChainTest.cpp')
-rw-r--r--clang/unittests/Driver/ToolChainTest.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp
index 3faa285..a9ac309 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -484,4 +484,61 @@ TEST(ToolChainTest, Toolsets) {
}
}
+TEST(ToolChainTest, ConfigFileSearch) {
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+ DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+ IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
+ new llvm::vfs::InMemoryFileSystem);
+
+#ifdef _WIN32
+ const char *TestRoot = "C:\\";
+#else
+ const char *TestRoot = "/";
+#endif
+ FS->setCurrentWorkingDirectory(TestRoot);
+
+ FS->addFile(
+ "/opt/sdk/root.cfg", 0,
+ llvm::MemoryBuffer::getMemBuffer("--sysroot=/opt/sdk/platform0\n"));
+ FS->addFile(
+ "/home/test/sdk/root.cfg", 0,
+ llvm::MemoryBuffer::getMemBuffer("--sysroot=/opt/sdk/platform1\n"));
+ FS->addFile(
+ "/home/test/bin/root.cfg", 0,
+ llvm::MemoryBuffer::getMemBuffer("--sysroot=/opt/sdk/platform2\n"));
+
+ {
+ Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+ "clang LLVM compiler", FS);
+ std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(
+ {"/home/test/bin/clang", "--config", "root.cfg",
+ "--config-system-dir=/opt/sdk", "--config-user-dir=/home/test/sdk"}));
+ ASSERT_TRUE(C);
+ ASSERT_FALSE(C->containsError());
+ EXPECT_EQ("/opt/sdk/platform1", TheDriver.SysRoot);
+ }
+ {
+ Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+ "clang LLVM compiler", FS);
+ std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(
+ {"/home/test/bin/clang", "--config", "root.cfg",
+ "--config-system-dir=/opt/sdk", "--config-user-dir="}));
+ ASSERT_TRUE(C);
+ ASSERT_FALSE(C->containsError());
+ EXPECT_EQ("/opt/sdk/platform0", TheDriver.SysRoot);
+ }
+ {
+ Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+ "clang LLVM compiler", FS);
+ std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(
+ {"/home/test/bin/clang", "--config", "root.cfg",
+ "--config-system-dir=", "--config-user-dir="}));
+ ASSERT_TRUE(C);
+ ASSERT_FALSE(C->containsError());
+ EXPECT_EQ("/opt/sdk/platform2", TheDriver.SysRoot);
+ }
+}
+
} // end anonymous namespace.