diff options
Diffstat (limited to 'tests/zfs-tests/include')
-rw-r--r-- | tests/zfs-tests/include/commands.cfg | 1 | ||||
-rw-r--r-- | tests/zfs-tests/include/libtest.shlib | 80 |
2 files changed, 81 insertions, 0 deletions
diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index 968ab3cd1..57b1bd315 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -52,6 +52,7 @@ export SYSTEM_FILES='arp gunzip gzip head + hostid hostname id iostat diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index ddfe550bf..1d1c57e7a 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -3428,3 +3428,83 @@ function swap_cleanup return 0 } + +# +# Set a global system tunable (64-bit value) +# +# $1 tunable name +# $2 tunable values +# +function set_tunable64 +{ + set_tunable_impl "$1" "$2" Z +} + +# +# Set a global system tunable (32-bit value) +# +# $1 tunable name +# $2 tunable values +# +function set_tunable32 +{ + set_tunable_impl "$1" "$2" W +} + +function set_tunable_impl +{ + typeset tunable="$1" + typeset value="$2" + typeset mdb_cmd="$3" + typeset module="${4:-zfs}" + + [[ -z "$tunable" ]] && return 1 + [[ -z "$value" ]] && return 1 + [[ -z "$mdb_cmd" ]] && return 1 + + case "$(uname)" in + Linux) + typeset zfs_tunables="/sys/module/$module/parameters" + [[ -w "$zfs_tunables/$tunable" ]] || return 1 + echo -n "$value" > "$zfs_tunables/$tunable" + return "$?" + ;; + SunOS) + [[ "$module" -eq "zfs" ]] || return 1 + echo "${tunable}/${mdb_cmd}0t${value}" | mdb -kw + return "$?" + ;; + esac +} + +# +# Get a global system tunable +# +# $1 tunable name +# +function get_tunable +{ + get_tunable_impl "$1" +} + +function get_tunable_impl +{ + typeset tunable="$1" + typeset module="${2:-zfs}" + + [[ -z "$tunable" ]] && return 1 + + case "$(uname)" in + Linux) + typeset zfs_tunables="/sys/module/$module/parameters" + [[ -f "$zfs_tunables/$tunable" ]] || return 1 + cat $zfs_tunables/$tunable + return "$?" + ;; + SunOS) + [[ "$module" -eq "zfs" ]] || return 1 + ;; + esac + + return 1 +} |