diff options
author | Zyad A. Ali <zyad.ali.me@gmail.com> | 2021-07-15 15:23:28 +0200 |
---|---|---|
committer | Zyad A. Ali <zyad.ali.me@gmail.com> | 2021-09-15 21:56:35 +0200 |
commit | fc8819f43cae94db8345060f0af00e013dc86098 (patch) | |
tree | ed3585202342ebfa699c54f19fc1e8db72272af3 /test/util | |
parent | 149ca009678edc580de9f0b1d54f551d376742cb (diff) |
Test creation and deletion of POSIX message queues.
Updates #136
Diffstat (limited to 'test/util')
-rw-r--r-- | test/util/temp_path.cc | 26 | ||||
-rw-r--r-- | test/util/temp_path.h | 3 |
2 files changed, 15 insertions, 14 deletions
diff --git a/test/util/temp_path.cc b/test/util/temp_path.cc index e1bdee7fd..11399f372 100644 --- a/test/util/temp_path.cc +++ b/test/util/temp_path.cc @@ -34,20 +34,6 @@ namespace { std::atomic<uint64_t> global_temp_file_number = ATOMIC_VAR_INIT(1); -// Return a new temp filename, intended to be unique system-wide. -// -// The global file number helps maintain file naming consistency across -// different runs of a test. -// -// The timestamp is necessary because the test infrastructure invokes each -// test case in a separate process (resetting global_temp_file_number) and -// potentially in parallel, which allows for races between selecting and using a -// name. -std::string NextTempBasename() { - return absl::StrCat("gvisor_test_temp_", global_temp_file_number++, "_", - absl::ToUnixNanos(absl::Now())); -} - void TryDeleteRecursively(std::string const& path) { if (!path.empty()) { int undeleted_dirs = 0; @@ -85,6 +71,18 @@ std::string GetAbsoluteTestTmpdir() { return MakeAbsolute(tmp_dir, "").ValueOrDie(); } +// The global file number helps maintain file naming consistency across +// different runs of a test. +// +// The timestamp is necessary because the test infrastructure invokes each +// test case in a separate process (resetting global_temp_file_number) and +// potentially in parallel, which allows for races between selecting and using a +// name. +std::string NextTempBasename() { + return absl::StrCat("gvisor_test_temp_", global_temp_file_number++, "_", + absl::ToUnixNanos(absl::Now())); +} + PosixErrorOr<TempPath> TempPath::CreateFileWith(absl::string_view const parent, absl::string_view const content, mode_t const mode) { diff --git a/test/util/temp_path.h b/test/util/temp_path.h index 9e5ac11f4..6c8900b6b 100644 --- a/test/util/temp_path.h +++ b/test/util/temp_path.h @@ -27,6 +27,9 @@ namespace gvisor { namespace testing { +// Return a new temp filename, intended to be unique system-wide. +std::string NextTempBasename(); + // Returns an absolute path for a file in `dir` that does not yet exist. // Distinct calls to NewTempAbsPathInDir from the same process, even from // multiple threads, are guaranteed to return different paths. Distinct calls to |