generic/386: check the correct field from df output
authorTheodore Ts'o <tytso@mit.edu>
Sun, 22 Dec 2019 21:27:30 +0000 (16:27 -0500)
committerEryu Guan <guaneryu@gmail.com>
Sun, 29 Dec 2019 15:55:35 +0000 (23:55 +0800)
The generic/386 test was checking the "Available" field when it
should have been checking the "1k-blocks" field, which represents
the project quota's hard limit.  On xfs, an empty directory takes no
space, so it doesn't matter.  But for ext4, an empty directory still
takes 4k (or whatever the file system's block size happens to be):

Filesystem           1K-blocks       Used  Available  Use% Pathname
/dev/vdc                512000          4     511996    0% /vdc/test

This causes generic/386 to falsely fail.

This fix is needed to fix generic/386 from failing on ext4:

    hard limit 524283904 bytes, expected 524288000

[Eryu: Used $(NF-4) instead of $2 as Eric Sandeen and Yang Xu
suggested]

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/386

index 0c44c80e22c2ac0203bc3930542c1cb6e7647d65..1291dae04e97174adeaf1dd8ac15062778a3899c 100755 (executable)
@@ -58,12 +58,12 @@ _require_scratch
 # Make sure the hard limits reported are what was set.
 # It is entirely too clever...
 # It exploits the fact that we've set the soft and hard limits to
-# the same value, and as a result the value in the fourth field in
+# the same value, and as a result the value in the second field in
 # both the "df" and the "report" output.  For "report", the line we're
 # 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;
                }