Lines Matching refs:fs
204 ASSERT_NO_ERROR(fs::make_absolute(temp_store)); in TEST()
220 sys::fs::make_absolute("/root", Relative); in TEST()
227 sys::fs::make_absolute("//root", Relative); in TEST()
622 fs::createUniqueDirectory("file-system-test", TestDirectory)); in SetUp()
633 void TearDown() override { ASSERT_NO_ERROR(fs::remove(TestDirectory.str())); } in TearDown()
641 fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath)); in TEST_F()
644 fs::UniqueID F1, F2; in TEST_F()
645 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath), F1)); in TEST_F()
646 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath), F2)); in TEST_F()
653 fs::createTemporaryFile("prefix", "temp", FileDescriptor2, TempPath2)); in TEST_F()
655 fs::UniqueID D; in TEST_F()
656 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath2), D)); in TEST_F()
660 ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); in TEST_F()
664 ASSERT_NO_ERROR(fs::create_link(Twine(TempPath), Twine(TempPath2))); in TEST_F()
665 fs::UniqueID D2; in TEST_F()
666 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath2), D2)); in TEST_F()
673 fs::createUniqueDirectory("dir1", Dir1)); in TEST_F()
674 ASSERT_NO_ERROR(fs::getUniqueID(Dir1.c_str(), F1)); in TEST_F()
675 ASSERT_NO_ERROR(fs::getUniqueID(Dir1.c_str(), F2)); in TEST_F()
680 fs::createUniqueDirectory("dir2", Dir2)); in TEST_F()
681 ASSERT_NO_ERROR(fs::getUniqueID(Dir2.c_str(), F2)); in TEST_F()
683 ASSERT_NO_ERROR(fs::remove(Dir1)); in TEST_F()
684 ASSERT_NO_ERROR(fs::remove(Dir2)); in TEST_F()
685 ASSERT_NO_ERROR(fs::remove(TempPath2)); in TEST_F()
686 ASSERT_NO_ERROR(fs::remove(TempPath)); in TEST_F()
691 fs::create_directories(Twine(TestDirectory) + "/test1/test2/test3")); in TEST_F()
692 ASSERT_TRUE(fs::exists(Twine(TestDirectory) + "/test1/test2/test3")); in TEST_F()
703 ASSERT_NO_ERROR(fs::real_path(TestDirectory, RealBase)); in TEST_F()
706 ASSERT_NO_ERROR(fs::real_path( in TEST_F()
716 ASSERT_NO_ERROR(fs::real_path(HomeDir, Expected)); in TEST_F()
717 ASSERT_NO_ERROR(fs::real_path("~", Actual, true)); in TEST_F()
719 ASSERT_NO_ERROR(fs::real_path("~/", Actual, true)); in TEST_F()
723 ASSERT_NO_ERROR(fs::remove_directories(Twine(TestDirectory) + "/test1")); in TEST_F()
734 fs::expand_tilde(HomeDir, Expected); in TEST_F()
736 fs::expand_tilde("~", Actual); in TEST_F()
741 fs::expand_tilde("~\\foo", Actual); in TEST_F()
744 fs::expand_tilde("~/foo", Actual); in TEST_F()
756 fs::create_directories(Twine(TestDirectory) + "/noreadperm")); in TEST_F()
757 ASSERT_TRUE(fs::exists(Twine(TestDirectory) + "/noreadperm")); in TEST_F()
759 fs::setPermissions(Twine(TestDirectory) + "/noreadperm", fs::no_perms); in TEST_F()
760 fs::setPermissions(Twine(TestDirectory) + "/noreadperm", fs::all_exe); in TEST_F()
762 ASSERT_NO_ERROR(fs::real_path(Twine(TestDirectory) + "/noreadperm", Expanded, in TEST_F()
765 ASSERT_NO_ERROR(fs::remove_directories(Twine(TestDirectory) + "/noreadperm")); in TEST_F()
772 auto TempFileOrError = fs::TempFile::create(TestDirectory + "/test-%%%%"); in TEST_F()
774 fs::TempFile File = std::move(*TempFileOrError); in TEST_F()
778 ASSERT_TRUE(fs::exists(TestDirectory + "/keep")); in TEST_F()
779 ASSERT_NO_ERROR(fs::remove(TestDirectory + "/keep")); in TEST_F()
784 auto TempFileOrError = fs::TempFile::create(TestDirectory + "/test-%%%%"); in TEST_F()
786 fs::TempFile File = std::move(*TempFileOrError); in TEST_F()
790 ASSERT_FALSE(fs::exists(TestDirectory + "/keep")); in TEST_F()
798 fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath)); in TEST_F()
801 ASSERT_TRUE(sys::fs::exists(Twine(TempPath))); in TEST_F()
806 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD2, TempPath2)); in TEST_F()
810 fs::file_status A, B; in TEST_F()
811 ASSERT_NO_ERROR(fs::status(Twine(TempPath), A)); in TEST_F()
812 ASSERT_NO_ERROR(fs::status(Twine(TempPath2), B)); in TEST_F()
813 EXPECT_FALSE(fs::equivalent(A, B)); in TEST_F()
818 ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); in TEST_F()
819 ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); in TEST_F()
820 ASSERT_EQ(fs::remove(Twine(TempPath2), false), in TEST_F()
823 std::error_code EC = fs::status(TempPath2.c_str(), B); in TEST_F()
825 EXPECT_EQ(B.type(), fs::file_type::file_not_found); in TEST_F()
828 ASSERT_EQ(fs::access(Twine(TempPath2), sys::fs::AccessMode::Exist), in TEST_F()
832 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "", TempPath3)); in TEST_F()
837 ASSERT_NO_ERROR(fs::create_link(Twine(TempPath), Twine(TempPath2))); in TEST_F()
839 ASSERT_NO_ERROR(fs::equivalent(Twine(TempPath), Twine(TempPath2), equal)); in TEST_F()
841 ASSERT_NO_ERROR(fs::status(Twine(TempPath), A)); in TEST_F()
842 ASSERT_NO_ERROR(fs::status(Twine(TempPath2), B)); in TEST_F()
843 EXPECT_TRUE(fs::equivalent(A, B)); in TEST_F()
847 ASSERT_NO_ERROR(fs::remove(Twine(TempPath))); in TEST_F()
850 ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); in TEST_F()
853 ASSERT_EQ(fs::access(Twine(TempPath), sys::fs::AccessMode::Exist), in TEST_F()
864 EXPECT_EQ(fs::createUniqueFile(Path270, FileDescriptor, TempPath), in TEST_F()
872 ASSERT_NO_ERROR(fs::createTemporaryFile(Path216, "", TempPath)); in TEST_F()
873 ASSERT_NO_ERROR(fs::remove(Twine(TempPath))); in TEST_F()
880 fs::createUniqueDirectory("CreateUniqueFileTest", TestDirectory)); in TEST_F()
885 std::vector<fs::TempFile> TempFiles; in TEST_F()
888 Expected<fs::TempFile> T = fs::TempFile::create(Model); in TEST_F()
912 for (fs::TempFile &T : TempFiles) in TEST_F()
917 ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "foo")); in TEST_F()
918 ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "foo")); in TEST_F()
919 ASSERT_EQ(fs::create_directory(Twine(TestDirectory) + "foo", false), in TEST_F()
921 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "foo")); in TEST_F()
927 fs::file_status Status; in TEST_F()
929 fs::create_directory(Twine(TestDirectory) + "baz500", false, in TEST_F()
930 fs::perms::owner_read | fs::perms::owner_exe)); in TEST_F()
931 ASSERT_NO_ERROR(fs::status(Twine(TestDirectory) + "baz500", Status)); in TEST_F()
932 ASSERT_EQ(Status.permissions() & fs::perms::all_all, in TEST_F()
933 fs::perms::owner_read | fs::perms::owner_exe); in TEST_F()
934 ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "baz777", false, in TEST_F()
935 fs::perms::all_all)); in TEST_F()
936 ASSERT_NO_ERROR(fs::status(Twine(TestDirectory) + "baz777", Status)); in TEST_F()
937 ASSERT_EQ(Status.permissions() & fs::perms::all_all, fs::perms::all_all); in TEST_F()
956 ASSERT_NO_ERROR(fs::create_directories(Twine(LongDir))); in TEST_F()
957 ASSERT_NO_ERROR(fs::create_directories(Twine(LongDir))); in TEST_F()
958 ASSERT_EQ(fs::create_directories(Twine(LongDir), false), in TEST_F()
963 ASSERT_NO_ERROR(fs::remove(ThisDir)); in TEST_F()
977 ASSERT_NO_ERROR(fs::create_directories(Twine(LongPathWithUnixSeparators))); in TEST_F()
979 ASSERT_NO_ERROR(fs::remove_directories(Twine(TestDirectory) + in TEST_F()
993 ASSERT_NO_ERROR(fs::create_directory(Twine(LongDir))); in TEST_F()
997 ASSERT_NO_ERROR(fs::create_directory("b")); in TEST_F()
998 ASSERT_EQ(fs::create_directory(Twine(LongDir), false), errc::file_exists); in TEST_F()
1000 ASSERT_NO_ERROR(fs::remove("b")); in TEST_F()
1001 ASSERT_NO_ERROR(fs::remove( in TEST_F()
1009 for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec)) in TEST_F()
1014 fs::create_directories(Twine(TestDirectory) + "/recursive/a0/aa1")); in TEST_F()
1016 fs::create_directories(Twine(TestDirectory) + "/recursive/a0/ab1")); in TEST_F()
1017 ASSERT_NO_ERROR(fs::create_directories(Twine(TestDirectory) + in TEST_F()
1020 fs::create_directories(Twine(TestDirectory) + "/recursive/z0/za1")); in TEST_F()
1022 fs::create_directories(Twine(TestDirectory) + "/recursive/pop/p1")); in TEST_F()
1025 for (fs::recursive_directory_iterator i(Twine(TestDirectory) in TEST_F()
1064 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/a0/aa1")); in TEST_F()
1065 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/a0/ab1")); in TEST_F()
1066 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/a0")); in TEST_F()
1068 fs::remove(Twine(TestDirectory) + "/recursive/dontlookhere/da1")); in TEST_F()
1069 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/dontlookhere")); in TEST_F()
1070 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/pop/p1")); in TEST_F()
1071 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/pop")); in TEST_F()
1072 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/z0/za1")); in TEST_F()
1073 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/z0")); in TEST_F()
1074 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive")); in TEST_F()
1078 fs::create_directories(Twine(TestDirectory) + "/reclevel/a/b/c")); in TEST_F()
1079 fs::recursive_directory_iterator I(Twine(TestDirectory) + "/reclevel", ec), E; in TEST_F()
1085 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/reclevel/a/b/c")); in TEST_F()
1086 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/reclevel/a/b")); in TEST_F()
1087 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/reclevel/a")); in TEST_F()
1088 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/reclevel")); in TEST_F()
1094 ASSERT_NO_ERROR(fs::create_directories(Twine(TestDirectory) + "/symlink")); in TEST_F()
1096 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/a")); in TEST_F()
1098 fs::create_directories(Twine(TestDirectory) + "/symlink/b/bb")); in TEST_F()
1100 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/b/ba")); in TEST_F()
1102 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/b/bc")); in TEST_F()
1104 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/c")); in TEST_F()
1106 fs::create_directories(Twine(TestDirectory) + "/symlink/d/dd/ddd")); in TEST_F()
1107 ASSERT_NO_ERROR(fs::create_link(Twine(TestDirectory) + "/symlink/d/dd", in TEST_F()
1110 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/e")); in TEST_F()
1120 for (fs::directory_iterator i(Twine(TestDirectory) + "/symlink", ec), e; in TEST_F()
1137 for (fs::recursive_directory_iterator i( in TEST_F()
1155 for (fs::recursive_directory_iterator i( in TEST_F()
1174 ASSERT_NO_ERROR(fs::remove_directories(Twine(TestDirectory) + "/symlink")); in TEST_F()
1191 ASSERT_NO_ERROR(fs::create_directories(Twine(RootDir) + "/a")); in TEST_F()
1192 ASSERT_NO_ERROR(fs::create_directories(Twine(RootDir) + "/b")); in TEST_F()
1196 for (fs::directory_iterator I(Twine(RootDir), EC), E; I != E; in TEST_F()
1205 ASSERT_NO_ERROR(fs::remove(Twine(RootDir) + "/a")); in TEST_F()
1206 ASSERT_NO_ERROR(fs::remove(Twine(RootDir) + "/b")); in TEST_F()
1207 ASSERT_NO_ERROR(fs::remove(Twine(RootDir))); in TEST_F()
1215 ASSERT_NO_ERROR(fs::createUniqueDirectory("fs_remove", BaseDir)); in TEST_F()
1217 ASSERT_NO_ERROR(fs::create_directories(Twine(BaseDir) + "/foo/bar/baz")); in TEST_F()
1218 ASSERT_NO_ERROR(fs::create_directories(Twine(BaseDir) + "/foo/bar/buzz")); in TEST_F()
1219 ASSERT_NO_ERROR(fs::createUniqueFile( in TEST_F()
1221 ASSERT_NO_ERROR(fs::createUniqueFile( in TEST_F()
1223 ASSERT_NO_ERROR(fs::createUniqueFile( in TEST_F()
1225 ASSERT_NO_ERROR(fs::createUniqueFile( in TEST_F()
1231 EXPECT_TRUE(fs::exists(Twine(BaseDir) + "/foo/bar/baz")); in TEST_F()
1232 EXPECT_TRUE(fs::exists(Twine(BaseDir) + "/foo/bar/buzz")); in TEST_F()
1233 EXPECT_TRUE(fs::exists(Paths[0])); in TEST_F()
1234 EXPECT_TRUE(fs::exists(Paths[1])); in TEST_F()
1235 EXPECT_TRUE(fs::exists(Paths[2])); in TEST_F()
1236 EXPECT_TRUE(fs::exists(Paths[3])); in TEST_F()
1238 ASSERT_NO_ERROR(fs::remove_directories("D:/footest")); in TEST_F()
1240 ASSERT_NO_ERROR(fs::remove_directories(BaseDir)); in TEST_F()
1241 ASSERT_FALSE(fs::exists(BaseDir)); in TEST_F()
1251 raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text); in TEST_F()
1262 raw_fd_ostream File(FilePathname, EC, sys::fs::OF_None); in TEST_F()
1271 ASSERT_NO_ERROR(fs::remove(Twine(FilePathname))); in TEST_F()
1278 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath)); in TEST_F()
1279 ASSERT_NO_ERROR(fs::resize_file(FD, 123)); in TEST_F()
1280 fs::file_status Status; in TEST_F()
1281 ASSERT_NO_ERROR(fs::status(FD, Status)); in TEST_F()
1284 ASSERT_NO_ERROR(fs::remove(TempPath)); in TEST_F()
1290 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath)); in TEST_F()
1294 auto Hash = fs::md5_contents(FD); in TEST_F()
1306 fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath)); in TEST_F()
1308 ASSERT_NO_ERROR(fs::resize_file(FileDescriptor, Size)); in TEST_F()
1314 fs::mapped_file_region mfr(fs::convertFDToNativeFile(FileDescriptor), in TEST_F()
1315 fs::mapped_file_region::readwrite, Size, 0, EC); in TEST_F()
1327 EC = fs::openFileForRead(Twine(TempPath), FD); in TEST_F()
1329 fs::mapped_file_region mfr(fs::convertFDToNativeFile(FD), in TEST_F()
1330 fs::mapped_file_region::readonly, Size, 0, EC); in TEST_F()
1337 fs::mapped_file_region m(fs::convertFDToNativeFile(FD), in TEST_F()
1338 fs::mapped_file_region::readonly, Size, 0, EC); in TEST_F()
1342 ASSERT_NO_ERROR(fs::remove(TempPath)); in TEST_F()
1555 fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath)); in TEST_F()
1559 ASSERT_TRUE(sys::fs::exists(Twine(TempPath))); in TEST_F()
1564 ASSERT_NO_ERROR(fs::openFileForRead(Twine(TempPath), FileDescriptor2, in TEST_F()
1565 fs::OF_None, &ResultPath)) in TEST_F()
1571 fs::UniqueID D1, D2; in TEST_F()
1572 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath), D1)); in TEST_F()
1573 ASSERT_NO_ERROR(fs::getUniqueID(Twine(ResultPath), D2)); in TEST_F()
1587 ASSERT_NO_ERROR(sys::fs::openFileForWrite(Twine(TempPath), FileDescriptor, in TEST_F()
1588 fs::CD_OpenExisting)); in TEST_F()
1590 ASSERT_NO_ERROR(fs::setLastAccessAndModificationTime(FileDescriptor, Epoch)); in TEST_F()
1594 ASSERT_NO_ERROR(fs::openFileForRead(Twine(TempPath), FileDescriptor, in TEST_F()
1595 fs::OF_UpdateAtime, &ResultPath)); in TEST_F()
1597 sys::fs::file_status Status; in TEST_F()
1598 ASSERT_NO_ERROR(sys::fs::status(FileDescriptor, Status)); in TEST_F()
1611 fs::CreationDisposition Disp, StringRef Data) { in createFileWithData()
1613 ASSERT_EQ(ShouldExistBefore, fs::exists(Path)); in createFileWithData()
1614 ASSERT_NO_ERROR(fs::openFileForWrite(Path, FD, Disp)); in createFileWithData()
1616 ASSERT_TRUE(fs::exists(Path)); in createFileWithData()
1633 ASSERT_FALSE(fs::exists(NonExistantFile)); in TEST_F()
1634 ASSERT_NO_ERROR(fs::openFileForWrite(NonExistantFile, FD, fs::CD_CreateNew)); in TEST_F()
1635 ASSERT_TRUE(fs::exists(NonExistantFile)); in TEST_F()
1641 sys::fs::file_status Status; in TEST_F()
1642 ASSERT_NO_ERROR(sys::fs::status(FD, Status)); in TEST_F()
1649 ASSERT_ERROR(fs::openFileForWrite(NonExistantFile, FD, fs::CD_CreateNew)); in TEST_F()
1657 ASSERT_FALSE(fs::exists(NonExistantFile)); in TEST_F()
1659 fs::openFileForWrite(NonExistantFile, FD, fs::CD_CreateAlways)); in TEST_F()
1663 ASSERT_TRUE(fs::exists(NonExistantFile)); in TEST_F()
1669 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1678 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1682 fs::openFileForWrite(NonExistantFile, FD, fs::CD_CreateAlways)); in TEST_F()
1684 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1692 ASSERT_FALSE(fs::exists(NonExistantFile)); in TEST_F()
1693 ASSERT_ERROR(fs::openFileForWrite(NonExistantFile, FD, fs::CD_OpenExisting)); in TEST_F()
1694 ASSERT_FALSE(fs::exists(NonExistantFile)); in TEST_F()
1697 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1700 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1705 createFileWithData(NonExistantFile, true, fs::CD_OpenExisting, "Buzz"); in TEST_F()
1711 createFileWithData(NonExistantFile, false, fs::CD_OpenAlways, "Fizz"); in TEST_F()
1714 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1718 createFileWithData(NonExistantFile, true, fs::CD_OpenAlways, "Bu"); in TEST_F()
1723 fs::CreationDisposition Disps[] = {fs::CD_CreateAlways, fs::CD_OpenAlways, in TEST_F()
1724 fs::CD_OpenExisting}; in TEST_F()
1730 for (fs::CreationDisposition Disp : Disps) { in TEST_F()
1734 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1739 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1742 fs::openFileForWrite(NonExistantFile, FD, Disp, fs::OF_Append)); in TEST_F()
1744 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1778 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1782 ASSERT_NO_ERROR(fs::openFileForRead(NonExistantFile, FD)); in TEST_F()
1790 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1795 fs::openFileForWrite(NonExistantFile, FD, fs::CD_OpenExisting)); in TEST_F()
1802 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1806 ASSERT_NO_ERROR(fs::openFileForReadWrite(NonExistantFile, FD, in TEST_F()
1807 fs::CD_OpenExisting, fs::OF_None)); in TEST_F()
1814 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "01234"); in TEST_F()
1818 Expected<fs::file_t> FD = fs::openNativeFileForRead(NonExistantFile); in TEST_F()
1821 auto Close = make_scope_exit([&] { fs::closeFile(*FD); }); in TEST_F()
1822 if (Expected<size_t> BytesRead = fs::readNativeFile( in TEST_F()
1834 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "01234"); in TEST_F()
1836 Expected<fs::file_t> FD = fs::openNativeFileForRead(NonExistantFile); in TEST_F()
1838 auto Close = make_scope_exit([&] { fs::closeFile(*FD); }); in TEST_F()
1842 if (Expected<size_t> BytesRead = fs::readNativeFileSlice( in TEST_F()
1858 ASSERT_NO_ERROR(fs::is_local(TestDirectory, TestDirectoryIsLocal)); in TEST_F()
1859 EXPECT_EQ(TestDirectoryIsLocal, fs::is_local(TestDirectory)); in TEST_F()
1864 fs::createUniqueFile(Twine(TestDirectory) + "/temp", FD, TempPath)); in TEST_F()
1868 ASSERT_TRUE(sys::fs::exists(Twine(TempPath))); in TEST_F()
1871 ASSERT_NO_ERROR(fs::is_local(FD, TempFileIsLocal)); in TEST_F()
1872 EXPECT_EQ(TempFileIsLocal, fs::is_local(FD)); in TEST_F()
1882 EXPECT_EQ(fs::getUmask(), 0U) << "Should always be 0 on Windows."; in TEST_F()
1885 unsigned CurrentMask = fs::getUmask(); in TEST_F()
1898 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath)); in TEST_F()
1900 fs::perms AllRWE = static_cast<fs::perms>(0777); in TEST_F()
1902 ASSERT_NO_ERROR(fs::setPermissions(TempPath, AllRWE)); in TEST_F()
1904 ErrorOr<fs::perms> Perms = fs::getPermissions(TempPath); in TEST_F()
1908 ASSERT_NO_ERROR(fs::setPermissions(TempPath, AllRWE)); in TEST_F()
1910 Perms = fs::getPermissions(TempPath); in TEST_F()
1915 fs::setPermissions(FD, static_cast<fs::perms>(AllRWE & ~fs::getUmask()))); in TEST_F()
1916 Perms = fs::getPermissions(TempPath); in TEST_F()
1918 EXPECT_EQ(Perms.get(), static_cast<fs::perms>(0755)) in TEST_F()
1924 fs::setPermissions(FD, static_cast<fs::perms>(AllRWE & ~fs::getUmask()))); in TEST_F()
1925 Perms = fs::getPermissions(TempPath); in TEST_F()
1927 EXPECT_EQ(Perms.get(), static_cast<fs::perms>(0720)) in TEST_F()
1938 ASSERT_NO_ERROR(fs::current_path(path)); in TEST_F()
1944 ~RestorePath() { fs::set_current_path(path); } in TEST_F()
1947 ASSERT_NO_ERROR(fs::set_current_path(TestDirectory)); in TEST_F()
1949 ASSERT_NO_ERROR(fs::current_path(path)); in TEST_F()
1951 fs::UniqueID D1, D2; in TEST_F()
1952 ASSERT_NO_ERROR(fs::getUniqueID(TestDirectory, D1)); in TEST_F()
1953 ASSERT_NO_ERROR(fs::getUniqueID(path, D2)); in TEST_F()
1960 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath)); in TEST_F()
1964 ASSERT_TRUE(fs::exists(Twine(TempPath))); in TEST_F()
1966 auto CheckPermissions = [&](fs::perms Expected) { in TEST_F()
1967 ErrorOr<fs::perms> Actual = fs::getPermissions(TempPath); in TEST_F()
1972 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_all), NoError); in TEST_F()
1973 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
1975 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read | fs::all_exe), NoError); in TEST_F()
1976 EXPECT_TRUE(CheckPermissions(fs::all_read | fs::all_exe)); in TEST_F()
1979 fs::perms ReadOnly = fs::all_read | fs::all_exe; in TEST_F()
1980 EXPECT_EQ(fs::setPermissions(TempPath, fs::no_perms), NoError); in TEST_F()
1983 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_read), NoError); in TEST_F()
1986 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_write), NoError); in TEST_F()
1987 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
1989 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_exe), NoError); in TEST_F()
1992 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_all), NoError); in TEST_F()
1993 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
1995 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_read), NoError); in TEST_F()
1998 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_write), NoError); in TEST_F()
1999 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2001 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_exe), NoError); in TEST_F()
2004 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_all), NoError); in TEST_F()
2005 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2007 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_read), NoError); in TEST_F()
2010 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_write), NoError); in TEST_F()
2011 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2013 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_exe), NoError); in TEST_F()
2016 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_all), NoError); in TEST_F()
2017 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2019 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read), NoError); in TEST_F()
2022 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_write), NoError); in TEST_F()
2023 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2025 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_exe), NoError); in TEST_F()
2028 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_uid_on_exe), NoError); in TEST_F()
2031 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_gid_on_exe), NoError); in TEST_F()
2034 EXPECT_EQ(fs::setPermissions(TempPath, fs::sticky_bit), NoError); in TEST_F()
2037 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_uid_on_exe | in TEST_F()
2038 fs::set_gid_on_exe | in TEST_F()
2039 fs::sticky_bit), in TEST_F()
2043 EXPECT_EQ(fs::setPermissions(TempPath, ReadOnly | fs::set_uid_on_exe | in TEST_F()
2044 fs::set_gid_on_exe | in TEST_F()
2045 fs::sticky_bit), in TEST_F()
2049 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_perms), NoError); in TEST_F()
2050 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2052 EXPECT_EQ(fs::setPermissions(TempPath, fs::no_perms), NoError); in TEST_F()
2053 EXPECT_TRUE(CheckPermissions(fs::no_perms)); in TEST_F()
2055 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_read), NoError); in TEST_F()
2056 EXPECT_TRUE(CheckPermissions(fs::owner_read)); in TEST_F()
2058 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_write), NoError); in TEST_F()
2059 EXPECT_TRUE(CheckPermissions(fs::owner_write)); in TEST_F()
2061 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_exe), NoError); in TEST_F()
2062 EXPECT_TRUE(CheckPermissions(fs::owner_exe)); in TEST_F()
2064 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_all), NoError); in TEST_F()
2065 EXPECT_TRUE(CheckPermissions(fs::owner_all)); in TEST_F()
2067 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_read), NoError); in TEST_F()
2068 EXPECT_TRUE(CheckPermissions(fs::group_read)); in TEST_F()
2070 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_write), NoError); in TEST_F()
2071 EXPECT_TRUE(CheckPermissions(fs::group_write)); in TEST_F()
2073 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_exe), NoError); in TEST_F()
2074 EXPECT_TRUE(CheckPermissions(fs::group_exe)); in TEST_F()
2076 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_all), NoError); in TEST_F()
2077 EXPECT_TRUE(CheckPermissions(fs::group_all)); in TEST_F()
2079 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_read), NoError); in TEST_F()
2080 EXPECT_TRUE(CheckPermissions(fs::others_read)); in TEST_F()
2082 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_write), NoError); in TEST_F()
2083 EXPECT_TRUE(CheckPermissions(fs::others_write)); in TEST_F()
2085 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_exe), NoError); in TEST_F()
2086 EXPECT_TRUE(CheckPermissions(fs::others_exe)); in TEST_F()
2088 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_all), NoError); in TEST_F()
2089 EXPECT_TRUE(CheckPermissions(fs::others_all)); in TEST_F()
2091 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read), NoError); in TEST_F()
2092 EXPECT_TRUE(CheckPermissions(fs::all_read)); in TEST_F()
2094 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_write), NoError); in TEST_F()
2095 EXPECT_TRUE(CheckPermissions(fs::all_write)); in TEST_F()
2097 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_exe), NoError); in TEST_F()
2098 EXPECT_TRUE(CheckPermissions(fs::all_exe)); in TEST_F()
2100 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_uid_on_exe), NoError); in TEST_F()
2101 EXPECT_TRUE(CheckPermissions(fs::set_uid_on_exe)); in TEST_F()
2103 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_gid_on_exe), NoError); in TEST_F()
2104 EXPECT_TRUE(CheckPermissions(fs::set_gid_on_exe)); in TEST_F()
2111 EXPECT_EQ(fs::setPermissions(TempPath, fs::sticky_bit), NoError); in TEST_F()
2112 EXPECT_TRUE(CheckPermissions(fs::sticky_bit)); in TEST_F()
2114 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_uid_on_exe | in TEST_F()
2115 fs::set_gid_on_exe | in TEST_F()
2116 fs::sticky_bit), in TEST_F()
2118 EXPECT_TRUE(CheckPermissions(fs::set_uid_on_exe | fs::set_gid_on_exe | in TEST_F()
2119 fs::sticky_bit)); in TEST_F()
2121 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read | fs::set_uid_on_exe | in TEST_F()
2122 fs::set_gid_on_exe | in TEST_F()
2123 fs::sticky_bit), in TEST_F()
2125 EXPECT_TRUE(CheckPermissions(fs::all_read | fs::set_uid_on_exe | in TEST_F()
2126 fs::set_gid_on_exe | fs::sticky_bit)); in TEST_F()
2128 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_perms), NoError); in TEST_F()
2129 EXPECT_TRUE(CheckPermissions(fs::all_perms)); in TEST_F()
2132 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_perms & ~fs::sticky_bit), in TEST_F()
2134 EXPECT_TRUE(CheckPermissions(fs::all_perms & ~fs::sticky_bit)); in TEST_F()
2216 EC = fs::createTemporaryFile("test", "temp", FD, TempPath); in TEST_F()
2221 EC = fs::tryLockFile(FD); in TEST_F()
2223 EC = fs::unlockFile(FD); in TEST_F()
2227 ASSERT_ERROR(fs::tryLockFile(FD)); in TEST_F()
2229 ASSERT_NO_ERROR(fs::tryLockFile(FD)); in TEST_F()
2230 ASSERT_NO_ERROR(fs::unlockFile(FD)); in TEST_F()
2236 ASSERT_NO_ERROR(fs::tryLockFile(FD)); in TEST_F()
2237 ASSERT_NO_ERROR(fs::unlockFile(FD)); in TEST_F()
2240 Expected<fs::FileLocker> L1 = Stream.lock(); in TEST_F()
2243 Expected<fs::FileLocker> L2 = Stream2.tryLockFor(250ms); in TEST_F()
2246 Expected<fs::FileLocker> L3 = Stream.tryLockFor(0ms); in TEST_F()
2250 ASSERT_NO_ERROR(fs::tryLockFile(FD)); in TEST_F()
2251 ASSERT_NO_ERROR(fs::unlockFile(FD)); in TEST_F()