[LTP] [PATCH 1/1] fsx-linux: Reduce log output

Petr Vorel
2023-12-07T11:12:42Z

Log output is very verbose. Given how many times the test tries it's a
significant time spent for printing output. This change also helps to
run on slower SUT without need to set LTP_TIMEOUT_MUL environment
variable.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/kernel/fs/fsx-linux/fsx-linux.c | 33 ++++-------------------
1 file changed, 5 insertions(+), 28 deletions(-)

diff --git a/testcases/kernel/fs/fsx-linux/fsx-linux.c b/testcases/kernel/fs/fsx-linux/fsx-linux.c
index 112c21f85..375ef4a1a 100644
--- a/testcases/kernel/fs/fsx-linux/fsx-linux.c
+++ b/testcases/kernel/fs/fsx-linux/fsx-linux.c
@@ -98,7 +98,6 @@ static void update_file_size(struct file_pos_t const *pos)
{
if (pos->offset + pos->size > file_size) {
file_size = pos->offset + pos->size;
-
tst_res(TINFO, "File size changed: %llu", file_size);
}
}
@@ -134,12 +133,6 @@ static int op_read(void)
struct file_pos_t pos;

op_file_position(file_size, op_read_align, &pos);
-
- tst_res(TINFO,
- "Reading at offset=%llu, size=%llu",
- pos.offset,
- pos.size);
-
memset(temp_buff, 0, file_max_size);

SAFE_LSEEK(file_desc, (off_t)pos.offset, SEEK_SET);
@@ -176,11 +169,6 @@ static int op_write(void)
temp_buff[i] = data;
}

- tst_res(TINFO,
- "Writing at offset=%llu, size=%llu",
- pos.offset,
- pos.size);
-
SAFE_LSEEK(file_desc, (off_t)pos.offset, SEEK_SET);
SAFE_WRITE(SAFE_WRITE_ALL, file_desc, temp_buff, pos.size);

@@ -194,11 +182,7 @@ static int op_truncate(void)
struct file_pos_t pos;

op_file_position(file_max_size, op_trunc_align, &pos);
-
file_size = pos.offset + pos.size;
-
- tst_res(TINFO, "Truncating to %llu", file_size);
-
SAFE_FTRUNCATE(file_desc, file_size);
memset(file_buff + file_size, 0, file_max_size - file_size);

@@ -218,11 +202,6 @@ static int op_map_read(void)
op_file_position(file_size, op_read_align, &pos);
op_align_pages(&pos);

- tst_res(TINFO,
- "Map reading at offset=%llu, size=%llu",
- pos.offset,
- pos.size);
-
addr = SAFE_MMAP(
0, pos.size,
PROT_READ,
@@ -261,11 +240,6 @@ static int op_map_write(void)
if (file_size < pos.offset + pos.size)
SAFE_FTRUNCATE(file_desc, pos.offset + pos.size);

- tst_res(TINFO,
- "Map writing at offset=%llu, size=%llu",
- pos.offset,
- pos.size);
-
for (long long i = 0; i < pos.size; i++)
file_buff[pos.offset + i] = random() % 10 + 'l';

@@ -277,10 +251,13 @@ static int op_map_write(void)
(off_t)pos.offset);

memcpy(addr, file_buff + pos.offset, pos.size);
- msync(addr, pos.size, MS_SYNC);

- SAFE_MUNMAP(addr, pos.size);
+ if (msync(addr, pos.size, MS_SYNC) != 0) {
+ tst_res(TWARN, "Map writing at offset=%llu, size=%llu failed",
+ pos.offset, pos.size);
+ }

+ SAFE_MUNMAP(addr, pos.size);
update_file_size(&pos);

return 1;
--
2.43.0