From: redi Date: Thu, 10 Jan 2019 11:12:00 +0000 (+0000) Subject: Include name of test in filesystem-test.XXXXXX filenames X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f0279417e4d473828dd5106bb0e2098640398cb;p=thirdparty%2Fgcc.git Include name of test in filesystem-test.XXXXXX filenames Also fix some tests that were not cleaning up after themselves, as identified by the change to nonexistent_path. * testsuite/util/testsuite_fs.h (nonexistent_path): Include name of the source file containing the caller. * testsuite/27_io/filesystem/iterators/directory_iterator.cc: Remove directories created by test. * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc: Likewise. * testsuite/experimental/filesystem/iterators/directory_iterator.cc: Likewise. * testsuite/experimental/filesystem/iterators/ recursive_directory_iterator.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267801 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4e248d46f182..6bc27c5ae300 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2019-01-10 Jonathan Wakely + + * testsuite/util/testsuite_fs.h (nonexistent_path): Include name + of the source file containing the caller. + * testsuite/27_io/filesystem/iterators/directory_iterator.cc: Remove + directories created by test. + * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc: + Likewise. + * testsuite/experimental/filesystem/iterators/directory_iterator.cc: + Likewise. + * testsuite/experimental/filesystem/iterators/ + recursive_directory_iterator.cc: Likewise. + 2019-01-10 Jakub Jelinek PR tree-optimization/88775 diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc index ddb424b4be00..5288bd297bd0 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/directory_iterator.cc @@ -138,6 +138,9 @@ test05() static_assert( noexcept(begin(it)), "begin is noexcept" ); VERIFY( end(it) == endit ); static_assert( noexcept(end(it)), "end is noexcept" ); + + std::error_code ec; + remove_all(p, ec); } int diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc index bf67bfd215b2..47b3266d3ebf 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc @@ -179,6 +179,9 @@ test05() static_assert( noexcept(begin(it)), "begin is noexcept" ); VERIFY( end(it) == endit ); static_assert( noexcept(end(it)), "end is noexcept" ); + + std::error_code ec; + remove_all(p, ec); } int diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc index 758291afcd67..cc3cd8798651 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc @@ -129,6 +129,9 @@ test05() static_assert( noexcept(begin(it)), "begin is noexcept" ); VERIFY( end(it) == endit ); static_assert( noexcept(end(it)), "end is noexcept" ); + + std::error_code ec; + remove_all(p, ec); } int diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc index ad37ba33f8e9..6217aca8b9a3 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc @@ -176,6 +176,9 @@ test05() static_assert( noexcept(begin(it)), "begin is noexcept" ); VERIFY( end(it) == endit ); static_assert( noexcept(end(it)), "end is noexcept" ); + + std::error_code ec; + remove_all(p, ec); } int diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h index 642156900834..48f503b3c276 100644 --- a/libstdc++-v3/testsuite/util/testsuite_fs.h +++ b/libstdc++-v3/testsuite/util/testsuite_fs.h @@ -86,8 +86,18 @@ namespace __gnu_test // This is NOT supposed to be a secure way to get a unique name! // We just need a path that doesn't exist for testing purposes. test_fs::path - nonexistent_path() + nonexistent_path(std::string file = __builtin_FILE()) { + // Include the caller's filename to help identify tests that fail to + // clean up the files they create. + // Remove .cc extension: + if (file.length() > 3 && file.compare(file.length() - 3, 3, ".cc") == 0) + file.resize(file.length() - 3); + // And directory: + auto pos = file.find_last_of("/\\"); + if (pos != file.npos) + file.erase(0, pos+1); + test_fs::path p; #if defined(_GNU_SOURCE) || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L char tmp[] = "filesystem-test.XXXXXX"; @@ -97,16 +107,22 @@ namespace __gnu_test std::error_code(errno, std::generic_category())); ::unlink(tmp); ::close(fd); - p = tmp; + if (!file.empty()) + file.insert(0, 1, '-'); + file.insert(0, tmp); + p = file; #else - char buf[64]; + if (file.length() > 64) + file.resize(64); + char buf[128]; static int counter; #if _GLIBCXX_USE_C99_STDIO - std::snprintf(buf, 64, + std::snprintf(buf, 128, #else std::sprintf(buf, #endif - "filesystem-test.%d.%lu", counter++, (unsigned long) ::getpid()); + "filesystem-test.%d.%lu-%s", counter++, (unsigned long) ::getpid(), + file.c_str()); p = buf; #endif return p;