]> git.proxmox.com Git - mirror_zfs.git/commitdiff
ZTS: Fix parsing of zpool status in checksum test
authorJohn Wren Kennedy <jwk404@gmail.com>
Tue, 20 Nov 2018 17:51:42 +0000 (10:51 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 20 Nov 2018 17:51:42 +0000 (09:51 -0800)
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 <ezomori.nozomu@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: John Wren Kennedy <john.kennedy@delphix.com>
Closes #8136

tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh

index 9062420f4e0b3e13cc3c8915308104e2c9e37775..ccc60a661d0edc89b94214b1502beac649af5617 100755 (executable)
 # 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 ]