public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Radoslav Kolev <radoslav.kolev@suse.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] df01.sh: Fix failure when block size < 1024
Date: Mon, 21 Dec 2020 13:34:49 +0200	[thread overview]
Message-ID: <20201221113449.30656-1-radoslav.kolev@suse.com> (raw)

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


             reply	other threads:[~2020-12-21 11:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21 11:34 Radoslav Kolev [this message]
2021-01-05 11:30 ` [LTP] [PATCH] df01.sh: Fix failure when block size < 1024 Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201221113449.30656-1-radoslav.kolev@suse.com \
    --to=radoslav.kolev@suse.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox