All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] src/seek_sanity_test: ensure file size is big enough
@ 2017-05-05 14:57 Luis Henriques
  2017-05-08  8:52 ` Eryu Guan
  0 siblings, 1 reply; 6+ messages in thread
From: Luis Henriques @ 2017-05-05 14:57 UTC (permalink / raw)
  To: fstests; +Cc: Yan, Zheng, Luis Henriques

Tests test07, test08, and test09 preallocate a file and assume the file
size used is bigger than 10xbufsz (100xbufsz for test09).  This patch
adjusts the file size so this assumption is always true.

As an example, here's test06 output for cephfs, where the allocation size
is set to 4194304, and the output is (4194304 * 10 + 4194304)

  07. Test file with unwritten extents, only have dirty pages
  07.01 SEEK_HOLE expected 0 or 4194304, got 46137344.              FAIL
  07.02 SEEK_HOLE expected 1 or 4194304, got 46137344.              FAIL

(Note: The test will be skipped if an integer overflow occurs.)

Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
 src/seek_sanity_test.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index a6dd48cc257b..41da59801212 100644
--- a/src/seek_sanity_test.c
+++ b/src/seek_sanity_test.c
@@ -282,6 +282,13 @@ static int test09(int fd, int testnum)
 	int bufsz = alloc_size;
 	int filsz = 8 << 20;
 
+	while ((filsz < (bufsz * 100 + bufsz)) && (filsz > 0))
+		filsz <<= 1;
+	if (filsz <= 0) {
+		fprintf(stdout, "Test skipped due to int overflow.\n");
+		return ret;
+	}
+
 	/*
 	 * HOLE - unwritten DATA in dirty page - HOLE -
 	 * unwritten DATA in writeback page
@@ -338,6 +345,13 @@ static int test08(int fd, int testnum)
 	int bufsz = alloc_size;
 	int filsz = 4 << 20;
 
+	while ((filsz < (bufsz * 10 + bufsz)) && (filsz > 0))
+		filsz <<= 1;
+	if (filsz <= 0) {
+		fprintf(stdout, "Test skipped due to int overflow.\n");
+		return ret;
+	}
+
 	/* HOLE - unwritten DATA in writeback page */
 	/* Each unit is bufsz */
 	buf = do_malloc(bufsz);
@@ -387,6 +401,13 @@ static int test07(int fd, int testnum)
 	int bufsz = alloc_size;
 	int filsz = 4 << 20;
 
+	while ((filsz < (bufsz * 10 + bufsz)) && (filsz > 0))
+		filsz <<= 1;
+	if (filsz <= 0) {
+		fprintf(stdout, "Test skipped due to int overflow.\n");
+		return ret;
+	}
+
 	/* HOLE - unwritten DATA in dirty page */
 	/* Each unit is bufsz */
 	buf = do_malloc(bufsz);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-08 15:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 14:57 [PATCH] src/seek_sanity_test: ensure file size is big enough Luis Henriques
2017-05-08  8:52 ` Eryu Guan
2017-05-08  9:37   ` Luis Henriques
2017-05-08  9:45     ` Luis Henriques
2017-05-08 10:47       ` Eryu Guan
2017-05-08 15:12         ` [PATCH v2] " Luis Henriques

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.