diff options
author | John Wren Kennedy <[email protected]> | 2018-11-20 10:51:42 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-11-20 09:51:42 -0800 |
commit | 70621ff20eb9dab94dde5e1c5cba7113e4cb7036 (patch) | |
tree | c58bba54087f330183484a6299c4e2184b313314 /tests | |
parent | ebb873590173fe8b98b4b1b48074925c89245aa0 (diff) |
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 <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: John Wren Kennedy <[email protected]>
Closes #8136
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh | 10 |
1 files 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 ] |