* [LTP] [PATCH] df01.sh: Fix failure when block size < 1024
@ 2020-12-21 11:34 Radoslav Kolev
2021-01-05 11:30 ` Petr Vorel
0 siblings, 1 reply; 2+ messages in thread
From: Radoslav Kolev @ 2020-12-21 11:34 UTC (permalink / raw)
To: ltp
If block size is < 1024 shell integer division will always round down.
Add 512 (1024/2) to the left side, to cause round up for values >= .5.
Signed-off-by: Radoslav Kolev <radoslav.kolev@suse.com>
---
testcases/commands/df/df01.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index 02aeec7b4..0e73a16af 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -101,8 +101,8 @@ df_check()
local free=$(stat -f mntpoint --printf=%f)
local used=$((total-free))
local bsize=$(stat -f mntpoint --printf=%s)
- total=$(($total * $bsize / 1024))
- used=$(($used * $bsize / 1024))
+ total=$((($total * $bsize + 512)/ 1024))
+ used=$((($used * $bsize + 512) / 1024))
fi
grep ${TST_DEVICE} output | grep -q "${total}.*${used}"
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-05 11:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-21 11:34 [LTP] [PATCH] df01.sh: Fix failure when block size < 1024 Radoslav Kolev
2021-01-05 11:30 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox