diff mbox series

[1/1] xfs/004: fix column extraction code

Message ID 172478423017.2039568.10354044892529803918.stgit@frogsfrogsfrogs (mailing list archive)
State Not Applicable, archived
Headers show
Series [1/1] xfs/004: fix column extraction code | expand

Commit Message

Darrick J. Wong Aug. 27, 2024, 6:46 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Now that the xfs_db freesp command prints a CDF of the free space
histograms, fix the pct column extraction code to handle the two
new columns by <cough> using awk.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/xfs/004 |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

Christoph Hellwig Aug. 30, 2024, 5:57 a.m. UTC | #1
On Tue, Aug 27, 2024 at 11:46:39AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Now that the xfs_db freesp command prints a CDF of the free space
> histograms, fix the pct column extraction code to handle the two
> new columns by <cough> using awk.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

.. and we really need this ASAP to not fail tests with the latest
xfsprogs.
diff mbox series

Patch

diff --git a/tests/xfs/004 b/tests/xfs/004
index 8b2fd9b320..473b82c945 100755
--- a/tests/xfs/004
+++ b/tests/xfs/004
@@ -82,14 +82,17 @@  then
 fi
 
 # check the 'pct' field from freesp command is good
-perl -ne '
-	    BEGIN	{ $percent = 0; }
-	    /free/	&& next;	# skip over free extent size number
-	    if (/\s+(\d+\.\d+)$/) {
-		$percent += $1;
-	    }
-	    END	{ $percent += 0.5; print int($percent), "\n" }	# round up
-' <$tmp.xfs_db >$tmp.ans
+awk '
+{
+	if ($0 ~ /free/) {
+		next;
+	}
+
+	percent += $5;
+}
+END {
+	printf("%d\n", int(percent + 0.5));
+}' < $tmp.xfs_db > $tmp.ans
 ans="`cat $tmp.ans`"
 echo "Checking percent column yields 100: $ans"
 if [ "$ans" != 100 ]