summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/filesystem/fs.op.funcs
Commit message (Collapse)AuthorAgeFilesLines
* Implement <filesystem>Eric Fiselier2018-07-2741-5067/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements the <filesystem> header and uses that to provide <experimental/filesystem>. Unlike other standard headers, the symbols needed for <filesystem> have not yet been placed in libc++.so. Instead they live in the new libc++fs.a library. Users of filesystem are required to link this library. (Also note that libc++experimental no longer contains the definition of <experimental/filesystem>, which now requires linking libc++fs). The reason for keeping <filesystem> out of the dylib for now is that it's still somewhat experimental, and the possibility of requiring an ABI breaking change is very real. In the future the symbols will likely be moved into the dylib, or the dylib will be made to link libc++fs automagically). Note that moving the symbols out of libc++experimental may break user builds until they update to -lc++fs. This should be OK, because the experimental library provides no stability guarantees. However, I plan on looking into ways we can force libc++experimental to automagically link libc++fs. In order to use a single implementation and set of tests for <filesystem>, it has been placed in a special `__fs` namespace. This namespace is inline in C++17 onward, but not before that. As such implementation is available in C++11 onward, but no filesystem namespace is present "directly", and as such name conflicts shouldn't occur in C++11 or C++14. llvm-svn: 338093
* Correct comment about stat truncating st_mtimespec to secondsEric Fiselier2018-07-261-19/+6
| | | | llvm-svn: 338000
* Workaround OS X 10.11 behavior where stat truncates st_mtimespec to seconds.Eric Fiselier2018-07-261-11/+38
| | | | llvm-svn: 337998
* Add print statements to help debuggingEric Fiselier2018-07-261-11/+21
| | | | llvm-svn: 337991
* Remove test which shouldn't have been committedEric Fiselier2018-07-251-19/+0
| | | | llvm-svn: 337971
* [libc++] Use __int128_t to represent file_time_type.Eric Fiselier2018-07-251-168/+314
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The ``file_time_type`` time point is used to represent the write times for files. Its job is to act as part of a C++ wrapper for less ideal system interfaces. The underlying filesystem uses the ``timespec`` struct for the same purpose. However, the initial implementation of ``file_time_type`` could not represent either the range or resolution of ``timespec``, making it unsuitable. Fixing this requires an implementation which uses more than 64 bits to store the time point. I primarily considered two solutions: Using ``__int128_t`` and using a arithmetic emulation of ``timespec``. Each has its pros and cons, and both come with more than one complication. However, after a lot of consideration, I decided on using `__int128_t`. This patch implements that change. Please see the [FileTimeType Design Document](http://libcxx.llvm.org/docs/DesignDocs/FileTimeType.html) for more information. Reviewers: mclow.lists, ldionne, joerg, arthur.j.odwyer, EricWF Reviewed By: EricWF Subscribers: christof, K-ballo, cfe-commits, BillyONeal Differential Revision: https://reviews.llvm.org/D49774 llvm-svn: 337960
* Fix bugs in create_directory implementation.Eric Fiselier2018-07-253-6/+67
| | | | | | | | | | | | | | Libc++ was incorrectly reporting an error when the target of create_directory already exists, but was not a directory. This behavior is not specified in the most recent standard, which says no error should be reported. Additionally, libc++ failed to report an error when the attribute directory path didn't exist or didn't name a directory. This has been fixed as well. Although it's not clear if we should call status or symlink_status on the attribute directory. This patch chooses to still call status. llvm-svn: 337888
* Implement filesystem_error::what() and improve reporting.Eric Fiselier2018-07-232-4/+5
| | | | | | | | | | | This patch implements the `what()` for filesystem errors. The message includes the 'what_arg', any paths that were specified, and the error code message. Additionally this patch refactors how errors are created, making it easier to report them correctly. llvm-svn: 337664
* Implement a better copy_file.Eric Fiselier2018-07-222-144/+240
| | | | | | | | | | | | | | | | | | | | This patch improves both the performance, and the safety of the copy_file implementation. The performance improvements are achieved by using sendfile on Linux and copyfile on OS X when available. The TOCTOU hardening is achieved by opening the source and destination files and then using fstat to check their attributes to see if we can copy them. Unfortunately for the destination file, there is no way to open it without accidentally creating it, so we first have to use stat to determine if it exists, and if we should copy to it. Then, once we're sure we should try to copy, we open the dest file and ensure it names the same entity we previously stat'ed. llvm-svn: 337649
* [libc++] Implement Directory Entry Caching -- Sort of.Eric Fiselier2018-07-201-10/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch implements directory_entry caching *almost* as specified in P0317r1. However, I explicitly chose to deviate from the standard as I'll explain below. The approach I decided to take is a fully caching one. When `refresh()` is called, the cache is populated by calls to `stat` and `lstat` as needed. During directory iteration the cache is only populated with the `file_type` as reported by `readdir`. The cache can be in the following states: * `_Empty`: There is nothing in the cache (likely due to an error) * `_IterSymlink`: Created by directory iteration when we walk onto a symlink only the symlink file type is known. * `_IterNonSymlink`: Created by directory iteration when we walk onto a non-symlink. Both the regular file type and symlink file type are known. * `_RefreshSymlink` and `_RefreshNonSymlink`: A full cache created by `refresh()`. This case includes dead symlinks. * `_RefreshSymlinkUnresolved`: A partial cache created by refresh when we fail to resolve the file pointed to by a symlink (likely due to permissions). Symlink attributes are cached, but attributes about the linked entity are not. As mentioned, this implementation purposefully deviates from the standard. According to some readings of the specification, and the Windows filesystem implementation, the constructors and modifiers which don't pass an `error_code` must throw when the `directory_entry` points to a entity which doesn't exist. or when attribute resolution fails for another reason. @BillyONeal has proposed a more reasonable set of requirements, where modifiers other than refresh ignore errors. This is the behavior libc++ currently implements, with the expectation some form of the new language will be accepted into the standard. Some additional semantics which differ from the Windows implementation: 1. `refresh` will not throw when the entry doesn't exist. In this case we can still meet the functions specification, so we don't treat it as an error. 2. We don't clear the path name when a constructor fails via refresh (this will hopefully be changed in the standard as well). It should be noted that libstdc++'s current implementation has the same behavior as libc++, except for point (2). If the changes to the specification don't get accepted, we'll be able to make the changes later. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0317r1.html Reviewers: mclow.lists, gromer, ldionne, aaron.ballman Subscribers: BillyONeal, christof, cfe-commits Differential Revision: https://reviews.llvm.org/D49530 llvm-svn: 337516
* Filesystem tests: un-confuse write timeJF Bastien2018-06-011-14/+13
| | | | | | | | | | | | | | | | | | | | | | Summary: The filesystem test was confused about access versus write / modification time. The spec says: file_time_type last_write_time(const path& p, error_code& ec) noexcept; Returns: The time of last data modification of p, determined as if by the value of the POSIX stat structure member st_mtime obtained as if by POSIX stat(). The signature with argument ec returns file_time_type::min() if an error occurs. The test was looking at st_atime, not st_mtime, when comparing the result from last_write_time. That was probably due to using a pair instead of naming things nicely or using types. I opted to rename things so it's clearer. This used to cause test bot failures. <rdar://problem/40648859> Reviewers: EricWF, mclow.lists, aemerson Subscribers: christof, cfe-commits Differential Revision: https://reviews.llvm.org/D47557 llvm-svn: 333723
* [libcxx][test] Fix fs::proximate tests on platforms where /net exists.Jan Korous2018-04-041-1/+1
| | | | | | Following Eric's patch. llvm-svn: 329199
* [libcxx][test] Improve assert messageJan Korous2018-04-041-3/+11
| | | | llvm-svn: 329194
* Fix fs::proximate tests on platforms where /net exists.Eric Fiselier2018-04-031-4/+4
| | | | | | | | | The proximate tests depended on `/net` not being a valid path, however, on OS X it is. Correct the tests to handle this. llvm-svn: 329038
* Implement filesystem NB comments, relative paths, and related issues.Eric Fiselier2018-04-027-157/+321
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a fairly large patch that implements all of the filesystem NB comments and the relative paths changes (ex. adding weakly_canonical). These issues and papers are all interrelated so their implementation couldn't be split up nicely. This patch upgrades <experimental/filesystem> to match the C++17 spec and not the published experimental TS spec. Some of the changes in this patch are both API and ABI breaking, however libc++ makes no guarantee about stability for experimental implementations. The major changes in this patch are: * Implement NB comments for filesystem (P0492R2), including: * Implement `perm_options` enum as part of NB comments, and update the `permissions` function to match. * Implement changes to `remove_filename` and `replace_filename` * Implement changes to `path::stem()` and `path::extension()` which support splitting examples like `.profile`. * Change path iteration to return an empty path instead of '.' for trailing separators. * Change `operator/=` to handle absolute paths on the RHS. * Change `absolute` to no longer accept a current path argument. * Implement relative paths according to NB comments (P0219r1) * Combine `path.cpp` and `operations.cpp` since some path functions require access to the operations internals, and some fs operations require access to the path parser. llvm-svn: 329028
* Fix test case initialization issues in permissions testEric Fiselier2018-03-261-1/+7
| | | | llvm-svn: 328477
* Implement filesystem::perm_options specified in NB comments.Eric Fiselier2018-03-262-31/+48
| | | | | | | | | | The NB comments for filesystem changed permissions and added a new enum `perm_options` which control how the permissions are applied. This implements than NB resolution llvm-svn: 328476
* Make filesystem tests generic between experimental and std versions.Eric Fiselier2018-03-2638-91/+76
| | | | | | | | | | | | | | | As I move towards implementing std::filesystem, there is a need to make the existing tests run against both the std and experimental versions. Additionally, it's helpful to allow running the tests against other implementations of filesystem. This patch converts the test to easily target either. First, it adds a filesystem_include.hpp header which is soley responsible for selecting and including the correct implementation. Second, it converts existing tests to use this header instead of including filesystem directly. llvm-svn: 328475
* [libcxx] Fix last_write_time test for filesystems that don't support very ↵Volodymyr Sapsai2018-02-281-10/+32
| | | | | | | | | | | | | | | | | | | | | small times. APFS minimum supported file write time is -2^63 nanoseconds, which doesn't go as far as `file_time_type::min()` that is equal to -2^63 microseconds on macOS. This change doesn't affect filesystems that support `file_time_type` range only for in-memory file time representation but not for on-disk representation. Such filesystems are considered as `SupportsMinTime`. rdar://problem/35865151 Reviewers: EricWF, Hahnfeld Subscribers: jkorous-apple, mclow.lists, cfe-commits, christof Differential Revision: https://reviews.llvm.org/D42755 llvm-svn: 326383
* Implement LWG 3014 - Fix more noexcept issues in filesystem.Eric Fiselier2018-02-043-4/+4
| | | | | | | | | This patch removes the noexcept declaration from filesystem operations which require creating temporary paths or creating a directory iterator. Either of these operations can throw. llvm-svn: 324192
* Address LWG 2849 and fix missing failure condition in copy_file.Eric Fiselier2018-02-041-1/+6
| | | | | | | Previously copy_file didn't handle the case where the input and output were the same file. llvm-svn: 324187
* Add error code handling to remove_all testEkaterina Vaartis2018-01-121-1/+1
| | | | | | As mentioned by EricWF in revision D41830 llvm-svn: 322351
* Make std::experimental::filesystem::remove and remove_all return false or 0 ↵Ekaterina Vaartis2018-01-112-3/+27
| | | | | | | | if the file doesn't exist Differential Revision: https://reviews.llvm.org/D41830 llvm-svn: 322293
* Implement LWG 3013 - some filesystem members should not be noexcept.Eric Fiselier2017-10-302-6/+6
| | | | | | | | | | | | | | | LWG 3013 points out that the constructors and increment members of the directory iterators need to allocate, and therefore cannot be marked noexcept. It also points out that `is_empty` and `copy` likely need to allocate as well, and as such can also not be noexcept. This patch speculatively implements the resolution removing noexcept, because libc++ does indeed have the possibility of throwing on allocation failure. llvm-svn: 316941
* Fix last_write_time.pass.cpp to work with clang-3.9 and earlierRoman Lebedev2017-10-151-0/+2
| | | | | | At least with clang-3.9 and earlier, -Wunknown-pragmas is also needed. llvm-svn: 315882
* Really do make sure that last_write_time.pass.cpp still works with old clangRoman Lebedev2017-10-151-2/+6
| | | | | | | I *did* try to check that such kind of an issue was not introduced by the rL315874, but clearly i failed to finish verification. llvm-svn: 315876
* Silence clang's -Wtautological-constant-compare in last_write_time.pass.cppRoman Lebedev2017-10-151-0/+22
| | | | | | | Previously this broke the builders, when D38101 was committed. Silence the warning so that it can be re-landed. llvm-svn: 315874
* Fix equivalent test on OS X and FreeBSDEric Fiselier2017-07-051-7/+7
| | | | llvm-svn: 307119
* Implement LWG 2937 - equivalent("dne", "exists") is not an errorEric Fiselier2017-07-051-51/+75
| | | | | | | | | | | | | | This patch speculatively implements the PR for LWG 2937, which fixes two issues with equivalent. (1) It makes equivalent("dne", "exists") an error. Previously only equivalent("dne", "dne") was an error and the former case was not (it returned false). Now equivalent reports an error when either input doesn't exist. (2) It makes equivalent(p1, p2) well-formed when `is_other(p1) && is_other(p2)`. Previously this was an error, but there is seemingly no reason why it should be on POSIX system. llvm-svn: 307117
* add tests for ENAMETOOLONGEric Fiselier2017-02-172-9/+25
| | | | llvm-svn: 295390
* [test] Fix hard_link_count test to account for fs with dir nlink==1Michal Gorny2017-02-081-4/+8
| | | | | | | | | | Filesystems are not required to maintain a hard link count consistent with number of subdirectories. For example, on btrfs all directories have nlink==1. Account for that in the test. Differential Revision: https://reviews.llvm.org/D29706 llvm-svn: 294431
* filesystem: fix n4100 conformance for `temp_directory_path`Saleem Abdulrasool2017-02-051-0/+8
| | | | | | | | | N4100 states that an error shall be reported if `!exists(p) || !is_directory(p)`. We were missing the first half of the conditional. Invert the error and normal code paths to make the code easier to follow. llvm-svn: 294127
* [libcxx] [test] Fix comment typos, strip trailing whitespace.Stephan T. Lavavej2017-01-182-3/+3
| | | | | | No functional change, no code review. llvm-svn: 292434
* Fix last_write_time tests for filesystems that don't support negative and ↵Jonas Hahnfeld2017-01-141-29/+63
| | | | | | | | | | | very large times Seems to be the case for NFS. Original patch by Eric Fiselier! Differential Revision: https://reviews.llvm.org/D22452 llvm-svn: 292013
* Fix unused parameters and variablesEric Fiselier2016-12-2313-47/+11
| | | | llvm-svn: 290459
* Enable the -Wsign-compare warning to better support MSVCEric Fiselier2016-12-111-1/+2
| | | | llvm-svn: 289363
* Fix non-portable tests for temp_directory_path(...)Eric Fiselier2016-10-241-8/+11
| | | | llvm-svn: 285020
* Fix libc++ specific assertion in permissions(...) testsEric Fiselier2016-10-231-1/+2
| | | | llvm-svn: 284945
* Implement LWG 2712 and update other issues statusEric Fiselier2016-10-161-2/+26
| | | | llvm-svn: 284318
* Implement LWG 2681 and 2682Eric Fiselier2016-10-161-0/+41
| | | | llvm-svn: 284316
* Implement LWG 2672.Eric Fiselier2016-10-151-0/+29
| | | | llvm-svn: 284314
* Fix LWG2683 - filesystem::copy() should always clear the user-provided ↵Eric Fiselier2016-10-111-5/+27
| | | | | | error_code llvm-svn: 283951
* test: relax the FS test a slight bit to be more reliableSaleem Abdulrasool2016-08-111-1/+2
| | | | | | | | | Some filesystems track atime always. This relaxes the test to accept either a filesystem which does not accurately track atime or does track the atime accurately. This allows the test to pass on filesystems mounted with `strictatime` on Linux or on macOS. llvm-svn: 278357
* test/hard_link_count(): Fix test on darwinMatthias Braun2016-08-101-8/+17
| | | | | | | The hard link count that stat reports are different between normal hfs and the case sensitive variant. Accept both. llvm-svn: 278191
* [libcxx][filesystem] Remove setgid from parent before testing permissionsJonas Hahnfeld2016-07-181-0/+3
| | | | | | | | | man page for mkdir says: "If the parent directory has the set-group-ID bit set, then so will the newly created directory." Differential Revision: https://reviews.llvm.org/D22265 llvm-svn: 275760
* Implement LWG issue 2720. Replace perms::resolve_symlinks with ↵Eric Fiselier2016-06-211-9/+13
| | | | | | | | | | | | | | | perms::symlink_nofollow. This changes how filesystem::permissions(p, perms) handles symlinks. Previously symlinks were not resolved by default instead only getting resolved when "perms::resolve_symlinks" was used. After this change symlinks are resolved by default and perms::symlink_nofollow must be given to change this. This issue has not yet been moved to Ready status, and I will revert if it doesn't get moved at the current meeting. However I feel confident that it will and it's nice to have implementations when moving issues. llvm-svn: 273328
* Implement LWG issue 2725. The issue should move this meetingEric Fiselier2016-06-211-0/+4
| | | | llvm-svn: 273325
* Fix bugs in last_write_time implementation.Eric Fiselier2016-06-191-23/+89
| | | | | | | | | | | | | | | * Fix passing a negative number as either tv_usec or tv_nsec. When file_time_type is negative and has a non-zero sub-second value we subtract 1 from tv_sec and make the sub-second duration positive. * Detect and report when 'file_time_type' cannot be represented by time_t. This happens when using large/small file_time_type values with a 32 bit time_t. There is more work to be done in the implementation. It should start to use stat's st_mtim or st_mtimeval if it's provided as an extension. That way we can provide a better resolution. llvm-svn: 273103
* Fix 3 bugs in filesystem tests and implementation.Eric Fiselier2016-06-181-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the following bugs, all of which were discovered while testing a 32 bit build on a 64 bit machine. * path.itr/iterator.pass.cpp has undefined behavior. 'path::iterator' stashes the value of the element inside the iterator. This violates the BiDirIterator requirements but is allowed for path::iterator. However this means that using reverse_iterator<path::iterator> has undefined behavior because it assumes that 'Iter tmp = it; return *tmp' will not create a dangling reference. However it does, and this caused this particular test to fail. * path.native.obs/string_alloc.pass.cpp tested the SSO with a long string. On 32 bit builds std::wstring only has the SSO for strings of size 2. The test was using a string of size 4. * fs.op.space/space.pass.cpp had overflows while calculating the expected values. The fix here is to convert the statvfs data members to std::uintmax_t before multiplying them. The internal implementation already does this but the tests needed to do it as well. llvm-svn: 273078
* Add additional tests in an attempt to diagnose ARM test failures.Eric Fiselier2016-06-181-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Currently 4 tests are failing on the ARM buildbot. To try and diagnose each of the failures this patch does the following: 1) path.itr/iterator.pass.cpp * Temporarily print iteration sequence to see where its failing. 2) path.native.obs/string_alloc.pass.cpp * Remove test that ::new is not called when constructing a short string that requires a conversion. Since during the conversion global locale objects might be constructed. 3) fs.op.funcs/space.pass.cpp * Explicitly use uintmax_t in the implementation of space, hopefully preventing possible overflows. * Add additional tests that check for overflow is the calculation of the space_info values. * Add additional tests for the values returned from statfvs. 4) fs.op.funcs/last_write_time.pass.cpp * No changes made yet. llvm-svn: 273075
OpenPOWER on IntegriCloud