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 <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
This commit is contained in:
parent
ebb8735901
commit
70621ff20e
@ -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 ]
|
||||
|
Loading…
x
Reference in New Issue
Block a user