mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Use GetAbsoluteTestTmpdir() rather than hard-code "/tmp"
This change makes these tests easier to run on systems that have their temp directory in another location. PiperOrigin-RevId: 388601202
This commit is contained in:
@@ -121,7 +121,8 @@ TEST(LseekTest, InvalidFD) {
|
||||
}
|
||||
|
||||
TEST(LseekTest, DirCurEnd) {
|
||||
const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open("/tmp", O_RDONLY));
|
||||
const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(
|
||||
Open(GetAbsoluteTestTmpdir().c_str(), O_RDONLY));
|
||||
ASSERT_THAT(lseek(fd.get(), 0, SEEK_CUR), SyscallSucceedsWithValue(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -445,9 +445,10 @@ TEST(MemfdTest, SealsAreInodeLevelProperties) {
|
||||
|
||||
// Tmpfs files also support seals, but are created with F_SEAL_SEAL.
|
||||
TEST(MemfdTest, TmpfsFilesHaveSealSeal) {
|
||||
SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(IsTmpfs("/tmp")));
|
||||
std::string tmpdir = GetAbsoluteTestTmpdir();
|
||||
SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(IsTmpfs(tmpdir.c_str())));
|
||||
const TempPath tmpfs_file =
|
||||
ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFileIn("/tmp"));
|
||||
ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFileIn(tmpdir.c_str()));
|
||||
const FileDescriptor fd =
|
||||
ASSERT_NO_ERRNO_AND_VALUE(Open(tmpfs_file.path(), O_RDWR, 0644));
|
||||
EXPECT_THAT(fcntl(fd.get(), F_GET_SEALS),
|
||||
|
||||
@@ -765,7 +765,7 @@ TEST_F(StatTest, StatxSymlink) {
|
||||
SKIP_IF(!IsRunningOnGvisor() && statx(-1, nullptr, 0, 0, nullptr) < 0 &&
|
||||
errno == ENOSYS);
|
||||
|
||||
std::string parent_dir = "/tmp";
|
||||
std::string parent_dir = GetAbsoluteTestTmpdir();
|
||||
TempPath link = ASSERT_NO_ERRNO_AND_VALUE(
|
||||
TempPath::CreateSymlinkTo(parent_dir, test_file_name_));
|
||||
std::string p = link.path();
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace testing {
|
||||
namespace {
|
||||
|
||||
TEST(StatfsTest, CannotStatBadPath) {
|
||||
auto temp_file = NewTempAbsPathInDir("/tmp");
|
||||
auto temp_file = NewTempAbsPath();
|
||||
|
||||
struct statfs st;
|
||||
EXPECT_THAT(statfs(temp_file.c_str(), &st), SyscallFailsWithErrno(ENOENT));
|
||||
|
||||
Reference in New Issue
Block a user