summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/Path.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-02-21 20:55:47 +0000
committerZachary Turner <zturner@google.com>2017-02-21 20:55:47 +0000
commit392ed9d342229b95d77a5ec6310e10093f73e75c (patch)
tree2b223846e02b9c38cebf8b5b61092040cc73bf3a /llvm/unittests/Support/Path.cpp
parentccee0e0c055327d202e48b5dfeb06cb3716e49d0 (diff)
downloadbcm5719-llvm-392ed9d342229b95d77a5ec6310e10093f73e75c.tar.gz
bcm5719-llvm-392ed9d342229b95d77a5ec6310e10093f73e75c.zip
[Support] Add a function to check if a file resides locally.
Differential Revision: https://reviews.llvm.org/D30010 llvm-svn: 295768
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
-rw-r--r--llvm/unittests/Support/Path.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index bd57ba98f31..df3c5fd0f32 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -1136,6 +1136,28 @@ TEST_F(FileSystemTest, OpenFileForRead) {
::close(FileDescriptor);
}
+TEST_F(FileSystemTest, is_local) {
+ SmallString<128> CurrentPath;
+ ASSERT_NO_ERROR(fs::current_path(CurrentPath));
+
+ bool Result;
+ ASSERT_NO_ERROR(fs::is_local(CurrentPath, Result));
+ EXPECT_TRUE(Result);
+ EXPECT_TRUE(fs::is_local(CurrentPath));
+
+ int FD;
+ SmallString<64> TempPath;
+ ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath));
+ FileRemover Cleanup(TempPath);
+
+ // Make sure it exists.
+ ASSERT_TRUE(sys::fs::exists(Twine(TempPath)));
+
+ ASSERT_NO_ERROR(fs::is_local(FD, Result));
+ EXPECT_TRUE(Result);
+ EXPECT_TRUE(fs::is_local(FD));
+}
+
TEST_F(FileSystemTest, set_current_path) {
SmallString<128> path;
OpenPOWER on IntegriCloud