diff mbox series

[v5,3/5] mmapstress01: define fsize bounds by file offset bits

Message ID 20221012144823.1595671-4-edliaw@google.com
State Changes Requested
Headers show
Series mmapstress01: refactor to ltp framework | expand

Commit Message

Edward Liaw Oct. 12, 2022, 2:48 p.m. UTC
Signed-off-by: Edward Liaw <edliaw@google.com>
---
 .../kernel/mem/mmapstress/mmapstress01.c      | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
index dee73de5e..ea818ffcd 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -36,6 +36,13 @@ 
 #include <float.h>
 #include "tst_test.h"
 
+#if _FILE_OFFSET_BITS == 64
+# define FSIZE_MIN LONG_MIN
+# define FSIZE_MAX LONG_MAX
+#else
+# define FSIZE_MIN INT_MIN
+# define FSIZE_MAX INT_MAX
+#endif
 #define MAXLOOPS	500	/* max pages for map children to write */
 #define TEST_FILE	"mmapstress01.out"
 
@@ -83,18 +90,10 @@  static void setup(void)
 {
 	int pagesize = sysconf(_SC_PAGE_SIZE);
 
-#if _FILE_OFFSET_BITS == 64
-	if (tst_parse_filesize(opt_filesize, &filesize, 0, LONG_MAX))
-#else
-	if (tst_parse_filesize(opt_filesize, &filesize, 0, INT_MAX))
-#endif
+	if (tst_parse_filesize(opt_filesize, &filesize, 0, FSIZE_MAX))
 		tst_brk(TBROK, "invalid initial filesize '%s'", opt_filesize);
 
-#if _FILE_OFFSET_BITS == 64
-	if (tst_parse_filesize(opt_sparseoffset, &sparseoffset, LONG_MIN, LONG_MAX))
-#else
-	if (tst_parse_filesize(opt_sparseoffset, &sparseoffset, INT_MIN, INT_MAX))
-#endif
+	if (tst_parse_filesize(opt_sparseoffset, &sparseoffset, FSIZE_MIN, FSIZE_MAX))
 		tst_brk(TBROK, "invalid sparse offset '%s'", opt_sparseoffset);
 	if (sparseoffset % pagesize != 0)
 		tst_brk(TBROK, "sparseoffset must be pagesize multiple");