diff options
author | Ryan Moeller <[email protected]> | 2020-01-13 18:21:42 -0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-01-13 15:21:42 -0800 |
commit | 602f667285b3c72bfdcd68578105ff1cc83a36e8 (patch) | |
tree | a9ba0cc5ec0422632f0d69a92633dce48989e2c6 /tests | |
parent | 6e1c594d6491ed5c9cc052ad5d94098eff684e2a (diff) |
ZTS: Clean up properties.shlib a bit
Fixes the last property having an empty value on FreeBSD and makes the
code a bit more readable.
Reviewed-by: Kjeld Schouten <[email protected]>
Reviewed-by: Igor Kozhukhov <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #9834
Diffstat (limited to 'tests')
-rw-r--r-- | tests/zfs-tests/include/properties.shlib | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/tests/zfs-tests/include/properties.shlib b/tests/zfs-tests/include/properties.shlib index ea8449fc6..1b6f5a4e5 100644 --- a/tests/zfs-tests/include/properties.shlib +++ b/tests/zfs-tests/include/properties.shlib @@ -34,47 +34,54 @@ typeset -a vol_props=('compress' 'checksum' 'copies' 'logbias' 'primarycache' 'secondarycache' 'redundant_metadata' 'sync') # -# Given the property array passed in, return 'num_props' elements to the -# user, excluding any elements below 'start.' This allows us to exclude -# 'off' and 'on' which can be either unwanted, or a duplicate of another -# property respectively. +# Given the 'prop' passed in, return 'num_vals' elements of the corresponding +# values array to the user, excluding any elements below 'first.' This allows +# us to exclude 'off' and 'on' which can be either unwanted, or a duplicate of +# another property respectively. # -function get_rand_prop +function get_rand_prop_vals { - typeset prop_array=($(eval echo \${$1[@]})) - typeset -i num_props=$2 - typeset -i start=$3 + typeset prop=$1 + typeset -i num_vals=$2 + typeset -i first=$3 + + [[ -z $prop || -z $num_vals || -z $first ]] && \ + log_fail "get_rand_prop_vals: bad arguments" + typeset retstr="" - [[ -z $prop_array || -z $num_props || -z $start ]] && \ - log_fail "get_rand_prop: bad arguments" + typeset prop_vals_var=${prop}_prop_vals + typeset -a prop_vals=($(eval echo \${${prop_vals_var}[@]})) + + [[ -z $prop_vals ]] && \ + log_fail "get_rand_prop_vals: bad prop $prop" - typeset prop_max=$((${#prop_array[@]} - 1)) + typeset -i last=$((${#prop_vals[@]} - 1)) typeset -i i - for i in $(range_shuffle $start $prop_max | head -n $num_props); do - retstr="${prop_array[$i]} $retstr" + for i in $(range_shuffle $first $last | head -n $num_vals); do + retstr="${prop_vals[$i]} $retstr" done echo $retstr } function get_rand_checksum { - get_rand_prop checksum_prop_vals $1 2 + get_rand_prop_vals checksum $1 2 } function get_rand_checksum_any { - get_rand_prop checksum_prop_vals $1 0 + get_rand_prop_vals checksum $1 0 } function get_rand_recsize { - get_rand_prop recsize_prop_vals $1 0 + get_rand_prop_vals recsize $1 0 } function get_rand_large_recsize { - get_rand_prop recsize_prop_vals $1 9 + get_rand_prop_vals recsize $1 9 } # @@ -137,7 +144,7 @@ function randomize_ds_props fi for prop in $proplist; do - typeset val=$(get_rand_prop "${prop}_prop_vals" 1 0) + typeset val=$(get_rand_prop_vals $prop 1 0) log_must zfs set $prop=$val $ds done } |