mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add NoRandomSave to tests with correctness DisableSave
Tests using DisableSave because a portion of the test is *incompatible* with S/R clearly cannot use random S/R, as the saves may occur in the DisableSave critical section. Most such tests already have NoRandomSave. Add it to the rest. PiperOrigin-RevId: 236914708 Change-Id: Iee1cf044cfa7cb8d5aba21ddc130926218210c48
This commit is contained in:
@@ -431,7 +431,7 @@ TEST_F(FlockTest, TestDupFdFollowedByLock) {
|
||||
// NOTE: These blocking tests are not perfect. Unfortunantely it's very hard to
|
||||
// determine if a thread was actually blocked in the kernel so we're forced
|
||||
// to use timing.
|
||||
TEST_F(FlockTest, BlockingLockNoBlockingForSharedLocks) {
|
||||
TEST_F(FlockTest, BlockingLockNoBlockingForSharedLocks_NoRandomSave) {
|
||||
// This test will verify that although LOCK_NB isn't specified
|
||||
// two different fds can obtain shared locks without blocking.
|
||||
ASSERT_THAT(flock(test_file_fd_.get(), LOCK_SH), SyscallSucceeds());
|
||||
@@ -471,7 +471,7 @@ TEST_F(FlockTest, BlockingLockNoBlockingForSharedLocks) {
|
||||
EXPECT_THAT(flock(test_file_fd_.get(), LOCK_UN), SyscallSucceeds());
|
||||
}
|
||||
|
||||
TEST_F(FlockTest, BlockingLockFirstSharedSecondExclusive) {
|
||||
TEST_F(FlockTest, BlockingLockFirstSharedSecondExclusive_NoRandomSave) {
|
||||
// This test will verify that if someone holds a shared lock any attempt to
|
||||
// obtain an exclusive lock will result in blocking.
|
||||
ASSERT_THAT(flock(test_file_fd_.get(), LOCK_SH), SyscallSucceeds());
|
||||
@@ -508,7 +508,7 @@ TEST_F(FlockTest, BlockingLockFirstSharedSecondExclusive) {
|
||||
EXPECT_THAT(flock(test_file_fd_.get(), LOCK_UN), SyscallSucceeds());
|
||||
}
|
||||
|
||||
TEST_F(FlockTest, BlockingLockFirstExclusiveSecondShared) {
|
||||
TEST_F(FlockTest, BlockingLockFirstExclusiveSecondShared_NoRandomSave) {
|
||||
// This test will verify that if someone holds an exclusive lock any attempt
|
||||
// to obtain a shared lock will result in blocking.
|
||||
ASSERT_THAT(flock(test_file_fd_.get(), LOCK_EX), SyscallSucceeds());
|
||||
@@ -545,7 +545,7 @@ TEST_F(FlockTest, BlockingLockFirstExclusiveSecondShared) {
|
||||
EXPECT_THAT(flock(test_file_fd_.get(), LOCK_UN), SyscallSucceeds());
|
||||
}
|
||||
|
||||
TEST_F(FlockTest, BlockingLockFirstExclusiveSecondExclusive) {
|
||||
TEST_F(FlockTest, BlockingLockFirstExclusiveSecondExclusive_NoRandomSave) {
|
||||
// This test will verify that if someone holds an exclusive lock any attempt
|
||||
// to obtain another exclusive lock will result in blocking.
|
||||
ASSERT_THAT(flock(test_file_fd_.get(), LOCK_EX), SyscallSucceeds());
|
||||
|
||||
@@ -1072,7 +1072,7 @@ TEST(Inotify, ChmodGeneratesAttribEvent_NoRandomSave) {
|
||||
};
|
||||
|
||||
// Don't do cooperative S/R tests for any of the {f}chmod* syscalls below, the
|
||||
// test will always fail because nodes cannot be saved when they have stricted
|
||||
// test will always fail because nodes cannot be saved when they have stricter
|
||||
// permissions than the original host node.
|
||||
const DisableSave ds;
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ TEST_F(OpenTest, CanTruncateReadOnly) {
|
||||
|
||||
// If we don't have read permission on the file, opening with
|
||||
// O_TRUNC should fail.
|
||||
TEST_F(OpenTest, CanTruncateReadOnlyNoWritePermission) {
|
||||
TEST_F(OpenTest, CanTruncateReadOnlyNoWritePermission_NoRandomSave) {
|
||||
// Drop capabilities that allow us to override file permissions.
|
||||
ASSERT_NO_ERRNO(SetCapability(CAP_DAC_OVERRIDE, false));
|
||||
|
||||
@@ -314,7 +314,7 @@ TEST_F(OpenTest, CanTruncateReadOnlyNoWritePermission) {
|
||||
|
||||
// If we don't have read permission but have write permission, opening O_WRONLY
|
||||
// and O_TRUNC should succeed.
|
||||
TEST_F(OpenTest, CanTruncateWriteOnlyNoReadPermission) {
|
||||
TEST_F(OpenTest, CanTruncateWriteOnlyNoReadPermission_NoRandomSave) {
|
||||
const DisableSave ds; // Permissions are dropped.
|
||||
|
||||
EXPECT_THAT(fchmod(test_file_fd_.get(), S_IWUSR | S_IWGRP),
|
||||
|
||||
@@ -278,7 +278,7 @@ TEST_F(StatTest, LinkCountsWithRegularFileChild) {
|
||||
|
||||
// This test verifies that inodes remain around when there is an open fd
|
||||
// after link count hits 0.
|
||||
TEST_F(StatTest, ZeroLinksOpenFdRegularFileChild) {
|
||||
TEST_F(StatTest, ZeroLinksOpenFdRegularFileChild_NoRandomSave) {
|
||||
// Setting the enviornment variable GVISOR_GOFER_UNCACHED to any value
|
||||
// will prevent this test from running, see the tmpfs lifecycle.
|
||||
//
|
||||
|
||||
@@ -160,7 +160,7 @@ TEST(UnlinkTest, AtFile) {
|
||||
EXPECT_THAT(unlinkat(dirfd, "UnlinkAtFile", 0), SyscallSucceeds());
|
||||
}
|
||||
|
||||
TEST(UnlinkTest, OpenFile) {
|
||||
TEST(UnlinkTest, OpenFile_NoRandomSave) {
|
||||
// We can't save unlinked file unless they are on tmpfs.
|
||||
const DisableSave ds;
|
||||
auto file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile());
|
||||
|
||||
Reference in New Issue
Block a user