From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id DD9073836C59; Fri, 12 Feb 2021 15:13:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD9073836C59 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-7220] libstdc++: Make "nonexistent" paths less predictable in filesystem tests X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: d1a821b93c45bfe7606b5dee8d160c7172b37e3e X-Git-Newrev: 4179ec107943bea360b8aa75e29e2c5ad9f13e9e Message-Id: <20210212151320.DD9073836C59@sourceware.org> Date: Fri, 12 Feb 2021 15:13:20 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2021 15:13:21 -0000 https://gcc.gnu.org/g:4179ec107943bea360b8aa75e29e2c5ad9f13e9e commit r11-7220-g4179ec107943bea360b8aa75e29e2c5ad9f13e9e Author: Jonathan Wakely Date: Fri Feb 12 15:13:02 2021 +0000 libstdc++: Make "nonexistent" paths less predictable in filesystem tests The helper function for creating new paths doesn't work well on Windows, because the PID of a process started by Wine is very consistent and so the same path gets created each time. libstdc++-v3/ChangeLog: * testsuite/util/testsuite_fs.h (nonexistent_path): Add random number to the path. Diff: --- libstdc++-v3/testsuite/util/testsuite_fs.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h index 4cda0eefeaf..e4d04dd7799 100644 --- a/libstdc++-v3/testsuite/util/testsuite_fs.h +++ b/libstdc++-v3/testsuite/util/testsuite_fs.h @@ -34,8 +34,13 @@ namespace test_fs = std::experimental::filesystem; #include #include #include -#include -#include + +#if defined(_GNU_SOURCE) || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L +#include // mkstemp +#include // unlink, close +#else +#include // std::random_device +#endif namespace __gnu_test { @@ -121,13 +126,13 @@ namespace __gnu_test if (file.length() > 64) file.resize(64); char buf[128]; - static int counter; + static unsigned counter = std::random_device{}(); #if _GLIBCXX_USE_C99_STDIO std::snprintf(buf, 128, #else std::sprintf(buf, #endif - "filesystem-test.%d.%lu-%s", counter++, (unsigned long) ::getpid(), + "filesystem-test.%u.%lu-%s", counter++, (unsigned long) ::getpid(), file.c_str()); p = buf; #endif