From b7cb5839eb782b67dd84670a1571fd892a702977 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 19 Dec 2018 10:49:59 +0100 Subject: [PATCH] test/vfs_stress: prevent division by zero Issue #3090 --- repos/os/src/test/vfs_stress/main.cc | 34 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/repos/os/src/test/vfs_stress/main.cc b/repos/os/src/test/vfs_stress/main.cc index fe2b0e66b6..8b091f35f4 100644 --- a/repos/os/src/test/vfs_stress/main.cc +++ b/repos/os/src/test/vfs_stress/main.cc @@ -569,9 +569,10 @@ void Component::construct(Genode::Env &env) vfs_root_sync(); - log("created ",count," empty directories, ", - (elapsed_ms*1000)/count,"μs/op , ", - env.ram().used_ram().value/1024,"KiB consumed"); + if (count > 0) + log("created ",count," empty directories, ", + (elapsed_ms*1000)/count,"μs/op , ", + env.ram().used_ram().value/1024,"KiB consumed"); } @@ -593,9 +594,10 @@ void Component::construct(Genode::Env &env) vfs_root_sync(); - log("created ",count," empty files, ", - (elapsed_ms*1000)/count,"μs/op, ", - env.ram().used_ram().value/1024,"KiB consumed"); + if (count > 0) + log("created ",count," empty files, ", + (elapsed_ms*1000)/count,"μs/op, ", + env.ram().used_ram().value/1024,"KiB consumed"); } @@ -624,9 +626,13 @@ void Component::construct(Genode::Env &env) vfs_root_sync(); - log("wrote ",count," bytes ", - count/elapsed_ms,"kB/s, ", - env.ram().used_ram().value/1024,"KiB consumed"); + if (elapsed_ms > 0) + log("wrote ",count," bytes, ", + count/elapsed_ms,"kB/s, ", + env.ram().used_ram().value/1024,"KiB consumed"); + else + log("wrote ",count," bytes, ", + env.ram().used_ram().value/1024,"KiB consumed"); } @@ -655,9 +661,13 @@ void Component::construct(Genode::Env &env) vfs_root_sync(); - log("read ",count," bytes, ", - count/elapsed_ms,"kB/s, ", - env.ram().used_ram().value/1024,"KiB consumed"); + if (elapsed_ms > 0) + log("read ",count," bytes, ", + count/elapsed_ms,"kB/s, ", + env.ram().used_ram().value/1024,"KiB consumed"); + else + log("read ",count," bytes, ", + env.ram().used_ram().value/1024,"KiB consumed"); }