Commit Graph

53 Commits

Author SHA1 Message Date
Eric Fiselier
af1fd7c75f Address LWG 2849 and fix missing failure condition in copy_file.
Previously copy_file didn't handle the case where the input and
output were the same file.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324187 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 02:43:32 +00:00
Ekaterina Vaartis
cce11ce7c2 Add error code handling to remove_all test
As mentioned by EricWF in revision D41830



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322351 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-12 05:02:06 +00:00
Ekaterina Vaartis
45d5893943 Make std::experimental::filesystem::remove and remove_all return false or 0 if the file doesn't exist
Differential Revision: https://reviews.llvm.org/D41830



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322293 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-11 17:04:29 +00:00
Stephan T. Lavavej
8148a70b20 [libcxx] [test] Strip trailing whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@319994 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-07 00:50:23 +00:00
Marshall Clow
bc6989bcbd More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in filesystem::path
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318378 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-16 05:48:32 +00:00
Eric Fiselier
a4c272d82f Implement LWG 3013 - some filesystem members should not be noexcept.
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@316941 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30 18:59:59 +00:00
Eric Fiselier
fba9cd8c9e Fix PR35078 - recursive directory iterator's increment method throws incorrectly.
The guts of the increment method for recursive_directory_iterator
was failing to pass an error code object to calls to status/symlink_status,
which can throw under certain conditions.

This patch fixes the issues by correctly propagating the error codes.
However the noexcept still needs to be removed from the signature, as
mentioned in LWG 3014, but that change will be made in a separate commit.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@316939 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30 18:43:21 +00:00
Roman Lebedev
5cf53b55e6 Fix last_write_time.pass.cpp to work with clang-3.9 and earlier
At least with clang-3.9 and earlier, -Wunknown-pragmas is also needed.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@315882 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-15 21:52:53 +00:00
Roman Lebedev
4b05db4286 Really do make sure that last_write_time.pass.cpp still works with old clang
I *did* try to check that such kind of an issue was not introduced
by the rL315874, but clearly i failed to finish verification.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@315876 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-15 20:46:12 +00:00
Roman Lebedev
0fdc4c9c6b Silence clang's -Wtautological-constant-compare in last_write_time.pass.cpp
Previously this broke the builders, when D38101 was committed.
Silence the warning so that it can be re-landed.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@315874 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-15 20:12:42 +00:00
Eric Fiselier
530ad8eb20 Fix equivalent test on OS X and FreeBSD
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@307119 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05 03:54:38 +00:00
Eric Fiselier
3288eac673 Implement LWG 2937 - equivalent("dne", "exists") is not an error
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@307117 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-05 03:37:05 +00:00
Eric Fiselier
706e2c7374 Diagnose when reverse_iterator is used on path::iterator.
path::iterator isn't a strictly conforming iterator. Specifically
it stashes the current element inside the iterator. This leads to
UB when used with reverse_iterator since it requires the element
to outlive the lifetime of the iterator.

This patch adds a static_assert inside reverse_iterator to disallow
"stashing iterator types", and it tags path::iterator as such a type.

Additionally this patch removes all uses of reverse_iterator<path::iterator>
within the tests.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300164 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 02:54:13 +00:00
Eric Fiselier
7c7df6461c Implement LWG 2787 - [file_status.cons] is inconsistent
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@297071 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-06 21:02:06 +00:00
Eric Fiselier
4203bfb5d3 add tests for ENAMETOOLONG
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@295390 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 01:00:37 +00:00
Michal Gorny
6c7c93f95a [test] Fix hard_link_count test to account for fs with dir nlink==1
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294431 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-08 09:57:32 +00:00
Stephan T. Lavavej
19ab479cc2 [libcxx] [test] Fix comment typos.
No functional change, no code review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294160 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 22:48:20 +00:00
Saleem Abdulrasool
7566869dab filesystem: fix n4100 conformance for temp_directory_path
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294127 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 17:21:52 +00:00
Stephan T. Lavavej
16e2ba19df [libcxx] [test] Fix comment typos, strip trailing whitespace.
No functional change, no code review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292434 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 20:10:25 +00:00
Eric Fiselier
f2b48899a5 Fix filesystem::path assignment from {}
Adding `path::operator=(string_type&&)` made the expression `p = {}`
ambiguous. This path fixes that ambiguity by making the `string&&`
overload a template so it ranks lower during overload resolution.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292345 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 05:48:55 +00:00
Jonas Hahnfeld
29d52a28e4 Fix last_write_time tests for filesystems that don't support negative and very large times
Seems to be the case for NFS.

Original patch by Eric Fiselier!
Differential Revision: https://reviews.llvm.org/D22452

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292013 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-14 11:35:15 +00:00
Eric Fiselier
0e5ebbc77c Fix unused parameters and variables
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290459 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-23 23:37:52 +00:00
Eric Fiselier
a2cd270943 Enable the -Wsign-compare warning to better support MSVC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289363 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-11 05:31:00 +00:00
Eric Fiselier
efc48515b4 Enable warnings by default for C++ >= 11 and fix -Wshadow occurances
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288557 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-03 00:27:13 +00:00
Eric Fiselier
c4a7e9177a Fix non-portable tests for temp_directory_path(...)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285020 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24 20:40:35 +00:00
Eric Fiselier
6547b4fa2b Fix libc++ specific assertion in permissions(...) tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284945 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-23 19:14:58 +00:00
Eric Fiselier
1e1bbc7437 Implement LWG 2712 and update other issues status
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284318 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-16 00:47:59 +00:00
Eric Fiselier
451f34db16 Implement LWG 2681 and 2682
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284316 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-16 00:29:22 +00:00
Eric Fiselier
25dc5bdb88 Implement LWG 2672.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284314 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-15 23:05:04 +00:00
Eric Fiselier
620a9a5ecf Implement modified LWG 2665
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284313 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-15 22:37:42 +00:00
Eric Fiselier
508f208ae9 Fix LWG2683 - filesystem::copy() should always clear the user-provided error_code
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-11 22:18:09 +00:00
Eric Fiselier
113315b9a4 Implement LWG 2711. Constrain path members.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279945 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-28 21:26:01 +00:00
Adhemerval Zanella
ea714e73a6 libcxx: Fix path.compare.pass expected result
The expected 'filesystem::path::compare' result states that for different
path only result sign contains the information about passed arguments
(not its integer value).  This is due it uses the output of other compare
functions (basic_string_view and char_traits) without further handling and
char_traits uses memcmp for final buffer comparison.

However for GLIBC on AArch64 the code:

  int ret = memcmp ("b/a/c", "a/b/c", 1);

Results in '64' where for x86_64 it results in '1'.

This patch fixes the expected 'filesystem::path::compare' by normalizing
all the results before assert comparison.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278745 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 21:24:50 +00:00
Saleem Abdulrasool
1f6a37d63e test: relax the FS test a slight bit to be more reliable
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278357 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 16:58:12 +00:00
Matthias Braun
3df1df14bf test/hard_link_count(): Fix test on darwin
The hard link count that stat reports are different between normal hfs and the
case sensitive variant. Accept both.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278191 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-10 01:02:28 +00:00
Eric Fiselier
2645dbe87f Implement P0392r0. Integrate filesystem::path and string_view.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276511 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-23 03:10:56 +00:00
Jonas Hahnfeld
b9c20327ac [libcxx][filesystem] Remove setgid from parent before testing permissions
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@275760 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 06:06:50 +00:00
Eric Fiselier
7c96ddb563 Implement LWG issue 2720. Replace perms::resolve_symlinks with 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.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273328 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 22:42:42 +00:00
Eric Fiselier
756a6bd177 Implement LWG issue 2725. The issue should move this meeting
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273325 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 22:11:16 +00:00
Eric Fiselier
70f7afec38 Fix bugs in last_write_time implementation.
* 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.



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273103 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-19 02:04:49 +00:00
Eric Fiselier
880e38b206 Fix 3 bugs in filesystem tests and implementation.
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.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273078 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-18 04:10:23 +00:00
Eric Fiselier
591e18f6aa Add additional tests in an attempt to diagnose ARM test failures.
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.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273075 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-18 02:11:48 +00:00
Eric Fiselier
63a5b248d7 Add checkpoints to string allocation test to help with debugging arm failures.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273072 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-18 00:23:13 +00:00
Eric Fiselier
f1bc722d8c Fix bugs in recursive_directory_iterator::increment(ec) implementation and tests.
r273060 didn't completely fix the issues in recursive_directory_iterator and
the tests. This patch follows up with more fixes

* Fix bug where recursive_directory_iterator::increment(ec) did not reset
  the error code if no failure occurred.

* Fix bad assertion in the recursive_directory_iterator::increment(ec) test
  that would only fire for certain iteration orders.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273070 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 23:57:16 +00:00
Eric Fiselier
a730ec37a9 Work around GCC bug in tests. The bug has been fixed in GCC 6.0
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273068 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 23:30:40 +00:00
Eric Fiselier
5c8a3688be Fix initialization of test case array in C++11
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273065 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 22:36:47 +00:00
Eric Fiselier
6f3b01af9c Fix bugs in recursive_directory_iterator implementation and tests.
There are two fixes in this patch:

* Fix bug where the constructor of recursive_directory_iterator did not reset
  the error code if no failure occurred.

* Fix tests were dependent on the iteration order of the test directories.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273060 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 22:22:37 +00:00
Eric Fiselier
40d9e09d89 Get filesystem tests passing for single-threaded configurations.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273054 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 21:44:26 +00:00
Eric Fiselier
841798ce01 Update status of filesystem issues, and add tests for LWG issue 2683
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273051 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 21:24:11 +00:00
Eric Fiselier
0c75540ba2 Reorder permissions test so they are not dependent on the processes umask
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273049 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 21:00:27 +00:00