Deflake a few save/restore test timeouts.

PiperOrigin-RevId: 631921522
This commit is contained in:
Jamie Liu
2024-05-08 14:17:57 -07:00
committed by gVisor bot
parent fe1fad577f
commit a3b19da789
3 changed files with 48 additions and 18 deletions
+3
View File
@@ -1014,7 +1014,9 @@ cc_binary(
"//test/util:eventfd_util",
"//test/util:file_descriptor",
"//test/util:fs_util",
"//test/util:logging",
"//test/util:posix_error",
"//test/util:save_util",
"//test/util:temp_path",
"//test/util:test_main",
"//test/util:test_util",
@@ -1679,6 +1681,7 @@ cc_binary(
"//test/util:file_descriptor",
"//test/util:fs_util",
"//test/util:posix_error",
"//test/util:save_util",
"//test/util:signal_util",
"//test/util:temp_path",
"//test/util:test_main",
+10 -3
View File
@@ -39,7 +39,9 @@
#include "test/util/eventfd_util.h"
#include "test/util/file_descriptor.h"
#include "test/util/fs_util.h"
#include "test/util/logging.h"
#include "test/util/posix_error.h"
#include "test/util/save_util.h"
#include "test/util/temp_path.h"
#include "test/util/test_util.h"
@@ -160,10 +162,15 @@ class GetdentsTest : public ::testing::Test {
// Fill directory with num files, named by number starting at 0.
void FillDirectory(size_t num) {
for (size_t i = 0; i < num; i++) {
auto name = JoinPath(dir_.path(), absl::StrCat(i));
TEST_CHECK(CreateWithContents(name, "").ok());
// Don't save after each file creation since num can be large.
{
DisableSave ds;
for (size_t i = 0; i < num; i++) {
auto name = JoinPath(dir_.path(), absl::StrCat(i));
TEST_CHECK(CreateWithContents(name, "").ok());
}
}
MaybeSave();
}
// Fill directory with a given list of filenames.
+35 -15
View File
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <errno.h>
#include <fcntl.h> /* Obtain O_* constant definitions */
#include <linux/futex.h>
#include <linux/magic.h>
@@ -32,6 +33,7 @@
#include "test/util/file_descriptor.h"
#include "test/util/fs_util.h"
#include "test/util/posix_error.h"
#include "test/util/save_util.h"
#include "test/util/signal_util.h"
#include "test/util/temp_path.h"
#include "test/util/test_util.h"
@@ -275,23 +277,41 @@ TEST_P(PipeTest, Seek) {
SKIP_IF(!CreateBlocking());
for (int i = 0; i < 4; i++) {
// Attempt absolute seeks.
EXPECT_THAT(lseek(rfd_.get(), 0, SEEK_SET), SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(rfd_.get(), 4, SEEK_SET), SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 0, SEEK_SET), SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 4, SEEK_SET), SyscallFailsWithErrno(ESPIPE));
// Saving after each failed lseek() is too expensive for the testing
// benefit, especially in a loop.
{
DisableSave ds;
// Attempt absolute seeks.
EXPECT_THAT(lseek(rfd_.get(), 0, SEEK_SET),
SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(rfd_.get(), 4, SEEK_SET),
SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 0, SEEK_SET),
SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 4, SEEK_SET),
SyscallFailsWithErrno(ESPIPE));
// Attempt relative seeks.
EXPECT_THAT(lseek(rfd_.get(), 0, SEEK_CUR), SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(rfd_.get(), 4, SEEK_CUR), SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 0, SEEK_CUR), SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 4, SEEK_CUR), SyscallFailsWithErrno(ESPIPE));
// Attempt relative seeks.
EXPECT_THAT(lseek(rfd_.get(), 0, SEEK_CUR),
SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(rfd_.get(), 4, SEEK_CUR),
SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 0, SEEK_CUR),
SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 4, SEEK_CUR),
SyscallFailsWithErrno(ESPIPE));
// Attempt end-of-file seeks.
EXPECT_THAT(lseek(rfd_.get(), 0, SEEK_CUR), SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(rfd_.get(), -4, SEEK_END), SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 0, SEEK_CUR), SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), -4, SEEK_END), SyscallFailsWithErrno(ESPIPE));
// Attempt end-of-file seeks.
EXPECT_THAT(lseek(rfd_.get(), 0, SEEK_CUR),
SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(rfd_.get(), -4, SEEK_END),
SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), 0, SEEK_CUR),
SyscallFailsWithErrno(ESPIPE));
EXPECT_THAT(lseek(wfd_.get(), -4, SEEK_END),
SyscallFailsWithErrno(ESPIPE));
}
MaybeSave();
// Add some more data to the pipe.
int buf = kTestValue;