2 # Common functions used by the zpool_status and zpool_iostat tests for running
3 # scripts with the -c option.
5 # Copyright (c) 2017 Lawrence Livermore National Security, LLC.
8 . $STF_SUITE/include/libtest.shlib
10 function test_zpool_script {
14 wholecmd="$cmd $script $testpool"
17 # Default number of columns that get printed without -c
18 if [ "$cmd" != "${cmd/iostat/_/}" ]; then
27 # Get the new column name that the script created
28 col="$(echo "$out" | \
29 awk '/^pool +alloc +free +read +write +/ {print $8} \
30 /NAME +STATE +READ +WRITE +CKSUM/ {print $6}')"
32 if [ -z "$col" ] ; then
33 log_fail "'$wholecmd' created no new columns"
36 # Count the number of columns for each vdev. Each script should produce
37 # at least one new column value. Even if scripts return blank, zpool
38 # will convert the blank to a '-' to make things awk-able. Normal
39 # zpool iostat -v output is 7 columns, so if the script ran correctly
40 # we should see more than that.
41 if ! newcols=$(echo "$out" | \
42 awk '/\/dev/ {print NF-'$dcols'; if (NF <= '$dcols') {exit 1}}' | \
45 log_fail "'$wholecmd' didn't create a new column value"
47 log_note "'$wholecmd' passed ($newcols new columns)"