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