diff mbox series

generic/386: get right field in df command

Message ID 1576560051-31851-1-git-send-email-xuyang2018.jy@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series generic/386: get right field in df command | expand

Commit Message

Yang Xu Dec. 17, 2019, 5:20 a.m. UTC
Since xfstests commit 5568077041bb ("generic/386: Fix _filter_quota_rpt"),
this case outputs things. And it fails on ext4 as below:

--------------------------
QA output created by 386
Silence is golden.
hard limit 524283904 bytes, expected 524288000
hard limit 500 bytes, expected 524288000
--------------------------

the df command doesn't get expected output, origial output as below:
--------------------------
for df:
Filesystem           1K-blocks       Used  Available  Use% Pathname
/dev/sda11            20511312      45108   20466204    0% /mnt/xfstests/scratch
/dev/sda11              512000          4     511996    0% /mnt/xfstests/scratch/test
for df -h command:
Filesystem     Size   Used  Avail Use% Pathname
/dev/sda11    19.6G  44.1M  19.5G   0% /mnt/xfstests/scratch
/dev/sda11     500M     4K 500.0M   0% /mnt/xfstests/scratch/test
--------------------------

It fails because ext4 project quota hides on common inode instead of superblock
inode, so it has used 1 block. Also, the "df -h" fails because byte_size() only
can parse integer value correctly. So, I think we can get size/1k-blocks instead
of Avail/Available field in this case.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 tests/generic/386 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tests/generic/386 b/tests/generic/386
index 0c44c80e..a39621e7 100755
--- a/tests/generic/386
+++ b/tests/generic/386
@@ -63,7 +63,7 @@  _require_scratch
 # interested in contains our project name in the first field.  For "df"
 # it contains our project directory in the last field.
 # But if the device name is too long, the "df" output is broke into two
-# lines, the fourth field is not correct, so take $(NF-2) of "df"
+# lines, the second field is not correct, so take $(NF-4) of "df".
 _filter_quota_rpt() {
 	awk '
 	BEGIN {
@@ -89,7 +89,7 @@  _filter_quota_rpt() {
 			bsize = byte_size($4);
 		} else if ($NF ~ proj_dir) {
 			# this is the "df" output
-			bsize = byte_size($(NF-2));
+			bsize = byte_size($(NF-4));
 		} else {
 			next;
 		}