diff options
author | Jamie Liu <jamieliu@google.com> | 2020-07-07 19:44:03 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-07-07 19:45:16 -0700 |
commit | 5e05950c1c520724e2e03963850868befb95efeb (patch) | |
tree | 5f8e3883b757489d4dceeaecad220625c6192fb6 /test/util/fs_util.h | |
parent | 76c7bc51b7b02c4ba83c0a064c3629bb5ee91340 (diff) |
Deflake exec test.
- Only use MAXSYMLINKS/2+1 symlinks for each of the interpreter and script
paths in SymlinkLimitRefreshedForInterpreter to tolerate cases where the
original paths (/tmp, /bin, or /bin/echo) themselves contain symlinks.
- Ensure that UnshareFiles performs execve immediately after clone(CLONE_VFORK)
(no heap allocation for ExecveArray/RunfilesPath).
- Use lstat() rather than stat() for the existence check in fs_util's Exists;
the latter will fail if the symlink target does not exist, even if the
symlink does.
PiperOrigin-RevId: 320110156
Diffstat (limited to 'test/util/fs_util.h')
-rw-r--r-- | test/util/fs_util.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/test/util/fs_util.h b/test/util/fs_util.h index caf19b24d..8cdac23a1 100644 --- a/test/util/fs_util.h +++ b/test/util/fs_util.h @@ -44,9 +44,14 @@ PosixErrorOr<std::string> GetCWD(); // can't be determined. PosixErrorOr<bool> Exists(absl::string_view path); -// Returns a stat structure for the given path or an error. +// Returns a stat structure for the given path or an error. If the path +// represents a symlink, it will be traversed. PosixErrorOr<struct stat> Stat(absl::string_view path); +// Returns a stat structure for the given path or an error. If the path +// represents a symlink, it will not be traversed. +PosixErrorOr<struct stat> Lstat(absl::string_view path); + // Returns a stat struct for the given fd. PosixErrorOr<struct stat> Fstat(int fd); |