summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/Host/FileSystemTest.cpp
diff options
context:
space:
mode:
authorLawrence D'Anna <lawrence_danna@apple.com>2019-09-26 17:54:59 +0000
committerLawrence D'Anna <lawrence_danna@apple.com>2019-09-26 17:54:59 +0000
commit2fce1137c7c227f40edbb657c484797addba38ca (patch)
tree1aca86d16d377f546f54a9b2c4782e51f113008c /lldb/unittests/Host/FileSystemTest.cpp
parent875d20bcde2e2b1990f3a4bdfc800959e8a72ed6 (diff)
downloadbcm5719-llvm-2fce1137c7c227f40edbb657c484797addba38ca.tar.gz
bcm5719-llvm-2fce1137c7c227f40edbb657c484797addba38ca.zip
Convert FileSystem::Open() to return Expected<FileUP>
Summary: This patch converts FileSystem::Open from this prototype: Status Open(File &File, const FileSpec &file_spec, ...); to this one: llvm::Expected<std::unique_ptr<File>> Open(const FileSpec &file_spec, ...); This is beneficial on its own, as llvm::Expected is a more modern and recommended error type than Status. It is also a necessary step towards https://reviews.llvm.org/D67891, and further developments for lldb_private::File. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67996 llvm-svn: 373003
Diffstat (limited to 'lldb/unittests/Host/FileSystemTest.cpp')
-rw-r--r--lldb/unittests/Host/FileSystemTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lldb/unittests/Host/FileSystemTest.cpp b/lldb/unittests/Host/FileSystemTest.cpp
index 7fea3b3a529..31184d9ad53 100644
--- a/lldb/unittests/Host/FileSystemTest.cpp
+++ b/lldb/unittests/Host/FileSystemTest.cpp
@@ -288,3 +288,18 @@ TEST(FileSystemTest, EnumerateDirectory) {
EXPECT_THAT(visited,
testing::UnorderedElementsAre("/foo", "/bar", "/baz", "/qux"));
}
+
+TEST(FileSystemTest, OpenErrno) {
+#ifdef _WIN32
+ FileSpec spec("C:\\FILE\\THAT\\DOES\\NOT\\EXIST.TXT");
+#else
+ FileSpec spec("/file/that/does/not/exist.txt");
+#endif
+ FileSystem fs;
+ auto file = fs.Open(spec, File::eOpenOptionRead, 0, true);
+ ASSERT_FALSE(file);
+ std::error_code code = errorToErrorCode(file.takeError());
+ EXPECT_EQ(code.category(), std::system_category());
+ EXPECT_EQ(code.value(), ENOENT);
+}
+
OpenPOWER on IntegriCloud