Skip to contentSkip to conversation

readahead02.c fixes: use tst_parse_filesize() so that we can pass sizes with units e.g. -s 128M

PATCH In review coolgw 2 participants 2 messages Jan 9, 2023 – Jan 10, 2023

lore
Share & tools
lore

coolgw

author
#0 lore raw

PATCH 1/1 readahead02.c fixes: use tst_parse_filesize() so that we can pass sizes with units e.g. -s 128M

---
 testcases/kernel/syscalls/readahead/readahead02.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/readahead/readahead02.c +2 -2
index 3ed88c005..c282b4d68 100644
@@ -367,8 +367,8 @@ static void setup_readahead_length(void)
 
 static void setup(void)
 {
-	if (opt_fsizestr) {
-		testfile_size = SAFE_STRTOL(opt_fsizestr, 1, INT_MAX);
+        if (tst_parse_filesize(opt_fsizestr, &testfile_size, 1, INT_MAX)) {
+		tst_brk(TBROK, "invalid initial filesize '%s'", opt_fsizestr);
 		tst_set_max_runtime(1 + testfile_size / (DEFAULT_FILESIZE/32));
 	}
 
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hello,

Quoted 10 lines · coolgw
---
 testcases/kernel/syscalls/readahead/readahead02.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/readahead/readahead02.c +0 -0
index 3ed88c005..c282b4d68 100644

testcases/kernel/syscalls/readahead/readahead02.c static void setup_readahead_length(void) · line 371

Quoted 7 lines
testcases/kernel/syscalls/readahead/readahead02.c +2 -2
@@ -367,8 +367,8 @@ static void setup_readahead_length(void)
 
 static void setup(void)
 {
-	if (opt_fsizestr) {
-		testfile_size = SAFE_STRTOL(opt_fsizestr, 1, INT_MAX);
+        if (tst_parse_filesize(opt_fsizestr, &testfile_size, 1, INT_MAX)) {
+		tst_brk(TBROK, "invalid initial filesize '%s'", opt_fsizestr);

So far correct; if parsing fails we call tst_brk which redirects to cleanup.

testcases/kernel/syscalls/readahead/readahead02.c static void setup_readahead_length(void) · line 372

Quoted 1 line
testcases/kernel/syscalls/readahead/readahead02.c +0 -0
 		tst_set_max_runtime(1 + testfile_size / (DEFAULT_FILESIZE/32));

However this will never be called because it is on the error path.

The time which we give the test to execute is proportional to the file size (if the size is non-default!). If it were not then large file sizes would cause timeouts (possibly at random) which would result in regressions.

Also note that in the existing test we only use tst_set_max_runtime when the value is non default. This is a mistake, but luckily the test.max_runtime = 30 and the calculated runtime for the default size would be 33. So you are not likely to cause a regression by changing this.

Setting to changes requested in patchwork.

Quoted 4 lines
testcases/kernel/syscalls/readahead/readahead02.c +0 -0
 	}
 
Signature · 1 line
2.35.3
Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp