From 70621ff20eb9dab94dde5e1c5cba7113e4cb7036 Mon Sep 17 00:00:00 2001 From: John Wren Kennedy Date: Tue, 20 Nov 2018 10:51:42 -0700 Subject: [PATCH] ZTS: Fix parsing of zpool status in checksum test filetest_001_pos consumes the output using read -r, assigning each field to a variable. The problem comes when a vdev is marked degraded, which appends extra fields to the line. This causes the trailing text to be treated as part of the `cksum` variable. Using awk instead of read -r allows us to extract the checksum error count from the output whether the vdev is degraded or not. Reviewed-by: loli10K Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: John Wren Kennedy Closes #8136 --- .../tests/functional/checksum/filetest_001_pos.ksh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh b/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh index 9062420f4..ccc60a661 100755 --- a/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh @@ -20,6 +20,10 @@ # CDDL HEADER END # +# +# Copyright (c) 2018 by Delphix. All rights reserved. +# + . $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/properties.shlib . $STF_SUITE/tests/functional/checksum/default.cfg @@ -86,7 +90,7 @@ log_must zpool import $TESTPOOL log_must zpool scrub $TESTPOOL log_must wait_scrubbed $TESTPOOL -zpool status -P -v $TESTPOOL | grep $firstvdev | read -r name state rd wr cksum +cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | awk '{print $5}') log_assert "Normal file write test saw $cksum checksum errors" log_must [ $cksum -eq 0 ] @@ -111,8 +115,8 @@ while [[ $j -lt ${#CHECKSUM_TYPES[*]} ]]; do log_must zpool scrub $TESTPOOL log_must wait_scrubbed $TESTPOOL - zpool status -P -v $TESTPOOL | grep $firstvdev | \ - read -r name state rd wr cksum + cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | \ + awk '{print $5}') log_assert "Checksum '$type' caught $cksum checksum errors" log_must [ $cksum -ne 0 ] -- 2.40.0