tests: remove unused functions
As found by git -C tests/ grep ^function | grep -vFe '.lua:' -e '.zcp:' | while IFS=":$IFS" read -r _ _ fn _; do [ $(git -C tests/ grep -wF $fn | head -2 | wc -l) -eq 1 ] && echo $fn; done after all rounds this comes out to, sorted: check_slog_state chgusr_exec cksum_files cleanup_pools compare_modes count_ACE dataset_set_defaultproperties ds_is_snapshot get_ACE get_group get_min get_mode get_owner get_rand_checksum get_rand_checksum_any get_rand_large_recsize get_rand_recsize get_user_group getitem indirect_vdev_mapping_size is_dilos log_noresult log_notinuse log_other log_timed_out log_uninitiated log_warning num_jobs_by_cpu plus_sign_check_l plus_sign_check_v record_cksum rwx_node seconds_mmp_waits_for_activity set_cur_usr setup_mirrors setup_raidzs showshares_smb zfs_zones_setup This, of course, doesn't catch recursive ones, or ones that log with their own function name as a prefix, but Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13259
This commit is contained in:
parent
5c9f744b1a
commit
fbe811b054
|
@ -1,5 +1,4 @@
|
||||||
pkgdatadir = $(datadir)/@PACKAGE@/test-runner/include
|
pkgdatadir = $(datadir)/@PACKAGE@/test-runner/include
|
||||||
|
|
||||||
dist_pkgdata_DATA = \
|
dist_pkgdata_DATA = \
|
||||||
logapi.shlib \
|
logapi.shlib
|
||||||
stf.shlib
|
|
||||||
|
|
|
@ -26,7 +26,11 @@
|
||||||
# Copyright (c) 2012, 2020 by Delphix. All rights reserved.
|
# Copyright (c) 2012, 2020 by Delphix. All rights reserved.
|
||||||
#
|
#
|
||||||
|
|
||||||
. ${STF_TOOLS}/include/stf.shlib
|
STF_PASS=0
|
||||||
|
STF_FAIL=1
|
||||||
|
STF_UNRESOLVED=2
|
||||||
|
STF_UNSUPPORTED=4
|
||||||
|
STF_UNTESTED=5
|
||||||
|
|
||||||
# Output an assertion
|
# Output an assertion
|
||||||
#
|
#
|
||||||
|
@ -372,15 +376,6 @@ function log_unresolved
|
||||||
_endlog $STF_UNRESOLVED "$@"
|
_endlog $STF_UNRESOLVED "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Perform cleanup and exit $STF_NOTINUSE
|
|
||||||
#
|
|
||||||
# $@ - message text
|
|
||||||
|
|
||||||
function log_notinuse
|
|
||||||
{
|
|
||||||
_endlog $STF_NOTINUSE "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Perform cleanup and exit $STF_UNSUPPORTED
|
# Perform cleanup and exit $STF_UNSUPPORTED
|
||||||
#
|
#
|
||||||
# $@ - message text
|
# $@ - message text
|
||||||
|
@ -399,51 +394,6 @@ function log_untested
|
||||||
_endlog $STF_UNTESTED "$@"
|
_endlog $STF_UNTESTED "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Perform cleanup and exit $STF_UNINITIATED
|
|
||||||
#
|
|
||||||
# $@ - message text
|
|
||||||
|
|
||||||
function log_uninitiated
|
|
||||||
{
|
|
||||||
_endlog $STF_UNINITIATED "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Perform cleanup and exit $STF_NORESULT
|
|
||||||
#
|
|
||||||
# $@ - message text
|
|
||||||
|
|
||||||
function log_noresult
|
|
||||||
{
|
|
||||||
_endlog $STF_NORESULT "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Perform cleanup and exit $STF_WARNING
|
|
||||||
#
|
|
||||||
# $@ - message text
|
|
||||||
|
|
||||||
function log_warning
|
|
||||||
{
|
|
||||||
_endlog $STF_WARNING "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Perform cleanup and exit $STF_TIMED_OUT
|
|
||||||
#
|
|
||||||
# $@ - message text
|
|
||||||
|
|
||||||
function log_timed_out
|
|
||||||
{
|
|
||||||
_endlog $STF_TIMED_OUT "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Perform cleanup and exit $STF_OTHER
|
|
||||||
#
|
|
||||||
# $@ - message text
|
|
||||||
|
|
||||||
function log_other
|
|
||||||
{
|
|
||||||
_endlog $STF_OTHER "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_main_pid
|
function set_main_pid
|
||||||
{
|
{
|
||||||
_MAINPID=$1
|
_MAINPID=$1
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
#
|
|
||||||
# CDDL HEADER START
|
|
||||||
#
|
|
||||||
# The contents of this file are subject to the terms of the
|
|
||||||
# Common Development and Distribution License (the "License").
|
|
||||||
# You may not use this file except in compliance with the License.
|
|
||||||
#
|
|
||||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
# or http://www.opensolaris.org/os/licensing.
|
|
||||||
# See the License for the specific language governing permissions
|
|
||||||
# and limitations under the License.
|
|
||||||
#
|
|
||||||
# When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
# If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
#
|
|
||||||
# CDDL HEADER END
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
# Use is subject to license terms.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2012 by Delphix. All rights reserved.
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
STF_PASS=0
|
|
||||||
STF_FAIL=1
|
|
||||||
STF_UNRESOLVED=2
|
|
||||||
STF_NOTINUSE=3
|
|
||||||
STF_UNSUPPORTED=4
|
|
||||||
STF_UNTESTED=5
|
|
||||||
STF_UNINITIATED=6
|
|
||||||
STF_NORESULT=7
|
|
||||||
STF_WARNING=8
|
|
||||||
STF_TIMED_OUT=9
|
|
||||||
STF_OTHER=10
|
|
||||||
|
|
||||||
# do this to use the names: eval echo \$STF_RESULT_NAME_${result}
|
|
||||||
STF_RESULT_NAME_0="PASS"
|
|
||||||
STF_RESULT_NAME_1="FAIL"
|
|
||||||
STF_RESULT_NAME_2="UNRESOLVED"
|
|
||||||
STF_RESULT_NAME_3="NOTINUSE"
|
|
||||||
STF_RESULT_NAME_4="UNSUPPORTED"
|
|
||||||
STF_RESULT_NAME_5="UNTESTED"
|
|
||||||
STF_RESULT_NAME_6="UNINITIATED"
|
|
||||||
STF_RESULT_NAME_7="NORESULT"
|
|
||||||
STF_RESULT_NAME_8="WARNING"
|
|
||||||
STF_RESULT_NAME_9="TIMED_OUT"
|
|
||||||
STF_RESULT_NAME_10="OTHER"
|
|
||||||
|
|
||||||
# do this to use the array: ${STF_RESULT_NAMES[$result]}
|
|
||||||
STF_RESULT_NAMES=( "PASS" "FAIL" "UNRESOLVED" "NOTINUSE" "UNSUPPORTED" \
|
|
||||||
"UNTESTED" "UNINITIATED" "NORESULT" "WARNING" "TIMED_OUT" "OTHER" )
|
|
|
@ -103,17 +103,6 @@ function is_freebsd
|
||||||
[ "$UNAME" = "FreeBSD" ]
|
[ "$UNAME" = "FreeBSD" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine if this is a DilOS test system
|
|
||||||
#
|
|
||||||
# Return 0 if platform DilOS, 1 if otherwise
|
|
||||||
|
|
||||||
function is_dilos
|
|
||||||
{
|
|
||||||
typeset ID=""
|
|
||||||
[[ -f /etc/os-release ]] && . /etc/os-release
|
|
||||||
[ "$ID" = "dilos" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Determine if this is a 32-bit system
|
# Determine if this is a 32-bit system
|
||||||
#
|
#
|
||||||
# Return 0 if platform is 32-bit, 1 if otherwise
|
# Return 0 if platform is 32-bit, 1 if otherwise
|
||||||
|
@ -444,48 +433,6 @@ function default_mirror_setup_noexit
|
||||||
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
|
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# create a number of mirrors.
|
|
||||||
# We create a number($1) of 2 way mirrors using the pairs of disks named
|
|
||||||
# on the command line. These mirrors are *not* mounted
|
|
||||||
# @parameters: $1 the number of mirrors to create
|
|
||||||
# $... the devices to use to create the mirrors on
|
|
||||||
# @uses: ZPOOL ZFS TESTPOOL
|
|
||||||
function setup_mirrors
|
|
||||||
{
|
|
||||||
typeset -i nmirrors=$1
|
|
||||||
|
|
||||||
shift
|
|
||||||
while ((nmirrors > 0)); do
|
|
||||||
log_must test -n "$1" -a -n "$2"
|
|
||||||
[[ -d /$TESTPOOL$nmirrors ]] && rm -rf /$TESTPOOL$nmirrors
|
|
||||||
log_must zpool create -f $TESTPOOL$nmirrors mirror $1 $2
|
|
||||||
shift 2
|
|
||||||
((nmirrors = nmirrors - 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# create a number of raidz pools.
|
|
||||||
# We create a number($1) of 2 raidz pools using the pairs of disks named
|
|
||||||
# on the command line. These pools are *not* mounted
|
|
||||||
# @parameters: $1 the number of pools to create
|
|
||||||
# $... the devices to use to create the pools on
|
|
||||||
# @uses: ZPOOL ZFS TESTPOOL
|
|
||||||
function setup_raidzs
|
|
||||||
{
|
|
||||||
typeset -i nraidzs=$1
|
|
||||||
|
|
||||||
shift
|
|
||||||
while ((nraidzs > 0)); do
|
|
||||||
log_must test -n "$1" -a -n "$2"
|
|
||||||
[[ -d /$TESTPOOL$nraidzs ]] && rm -rf /$TESTPOOL$nraidzs
|
|
||||||
log_must zpool create -f $TESTPOOL$nraidzs raidz $1 $2
|
|
||||||
shift 2
|
|
||||||
((nraidzs = nraidzs - 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Destroy the configured testpool mirrors.
|
# Destroy the configured testpool mirrors.
|
||||||
# the mirrors are of the form ${TESTPOOL}{number}
|
# the mirrors are of the form ${TESTPOOL}{number}
|
||||||
|
@ -781,46 +728,6 @@ function dataset_setprop
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Assign suite defined dataset properties.
|
|
||||||
# This function is used to apply the suite's defined default set of
|
|
||||||
# properties to a dataset.
|
|
||||||
# @parameters: $1 dataset to use
|
|
||||||
# @uses: ZFS COMPRESSION_PROP CHECKSUM_PROP
|
|
||||||
# @returns:
|
|
||||||
# 0 if the dataset has been altered.
|
|
||||||
# 1 if no pool name was passed in.
|
|
||||||
# 2 if the dataset could not be found.
|
|
||||||
# 3 if the dataset could not have it's properties set.
|
|
||||||
#
|
|
||||||
function dataset_set_defaultproperties
|
|
||||||
{
|
|
||||||
typeset dataset="$1"
|
|
||||||
|
|
||||||
[[ -z $dataset ]] && return 1
|
|
||||||
|
|
||||||
typeset confset=
|
|
||||||
typeset -i found=0
|
|
||||||
for confset in $(zfs list); do
|
|
||||||
if [[ $dataset = $confset ]]; then
|
|
||||||
found=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
[[ $found -eq 0 ]] && return 2
|
|
||||||
if [[ -n $COMPRESSION_PROP ]]; then
|
|
||||||
dataset_setprop $dataset compression $COMPRESSION_PROP || \
|
|
||||||
return 3
|
|
||||||
log_note "Compression set to '$COMPRESSION_PROP' on $dataset"
|
|
||||||
fi
|
|
||||||
if [[ -n $CHECKSUM_PROP ]]; then
|
|
||||||
dataset_setprop $dataset checksum $CHECKSUM_PROP || \
|
|
||||||
return 3
|
|
||||||
log_note "Checksum set to '$CHECKSUM_PROP' on $dataset"
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check a numeric assertion
|
# Check a numeric assertion
|
||||||
# @parameter: $@ the assertion to check
|
# @parameter: $@ the assertion to check
|
||||||
|
@ -1458,20 +1365,6 @@ function showshares_nfs
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Helper function to show SMB shares.
|
|
||||||
#
|
|
||||||
function showshares_smb
|
|
||||||
{
|
|
||||||
if is_linux; then
|
|
||||||
net usershare list
|
|
||||||
else
|
|
||||||
share -F smb
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_nfs
|
function check_nfs
|
||||||
{
|
{
|
||||||
case "$UNAME" in
|
case "$UNAME" in
|
||||||
|
@ -1735,117 +1628,6 @@ function destroy_dataset # dataset [args]
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Firstly, create a pool with 5 datasets. Then, create a single zone and
|
|
||||||
# export the 5 datasets to it. In addition, we also add a ZFS filesystem
|
|
||||||
# and a zvol device to the zone.
|
|
||||||
#
|
|
||||||
# $1 zone name
|
|
||||||
# $2 zone root directory prefix
|
|
||||||
# $3 zone ip
|
|
||||||
#
|
|
||||||
function zfs_zones_setup #zone_name zone_root zone_ip
|
|
||||||
{
|
|
||||||
typeset zone_name=${1:-$(hostname)-z}
|
|
||||||
typeset zone_root=${2:-"/zone_root"}
|
|
||||||
typeset zone_ip=${3:-"10.1.1.10"}
|
|
||||||
typeset prefix_ctr=$ZONE_CTR
|
|
||||||
typeset pool_name=$ZONE_POOL
|
|
||||||
typeset -i cntctr=5
|
|
||||||
typeset -i i=0
|
|
||||||
|
|
||||||
# Create pool and 5 container within it
|
|
||||||
#
|
|
||||||
[[ -d /$pool_name ]] && rm -rf /$pool_name
|
|
||||||
log_must zpool create -f $pool_name $DISKS
|
|
||||||
while ((i < cntctr)); do
|
|
||||||
log_must zfs create $pool_name/$prefix_ctr$i
|
|
||||||
((i += 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# create a zvol
|
|
||||||
log_must zfs create -V 1g $pool_name/zone_zvol
|
|
||||||
block_device_wait
|
|
||||||
|
|
||||||
#
|
|
||||||
# Add slog device for pool
|
|
||||||
#
|
|
||||||
typeset sdevs="$TEST_BASE_DIR/sdev1 $TEST_BASE_DIR/sdev2"
|
|
||||||
log_must mkfile $MINVDEVSIZE $sdevs
|
|
||||||
log_must zpool add $pool_name log mirror $sdevs
|
|
||||||
|
|
||||||
# this isn't supported just yet.
|
|
||||||
# Create a filesystem. In order to add this to
|
|
||||||
# the zone, it must have it's mountpoint set to 'legacy'
|
|
||||||
# log_must zfs create $pool_name/zfs_filesystem
|
|
||||||
# log_must zfs set mountpoint=legacy $pool_name/zfs_filesystem
|
|
||||||
|
|
||||||
[[ -d $zone_root ]] && \
|
|
||||||
log_must rm -rf $zone_root/$zone_name
|
|
||||||
[[ ! -d $zone_root ]] && \
|
|
||||||
log_must mkdir -p -m 0700 $zone_root/$zone_name
|
|
||||||
|
|
||||||
# Create zone configure file and configure the zone
|
|
||||||
#
|
|
||||||
typeset zone_conf=/tmp/zone_conf.$$
|
|
||||||
echo "create" > $zone_conf
|
|
||||||
echo "set zonepath=$zone_root/$zone_name" >> $zone_conf
|
|
||||||
echo "set autoboot=true" >> $zone_conf
|
|
||||||
i=0
|
|
||||||
while ((i < cntctr)); do
|
|
||||||
echo "add dataset" >> $zone_conf
|
|
||||||
echo "set name=$pool_name/$prefix_ctr$i" >> \
|
|
||||||
$zone_conf
|
|
||||||
echo "end" >> $zone_conf
|
|
||||||
((i += 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# add our zvol to the zone
|
|
||||||
echo "add device" >> $zone_conf
|
|
||||||
echo "set match=/dev/zvol/dsk/$pool_name/zone_zvol" >> $zone_conf
|
|
||||||
echo "end" >> $zone_conf
|
|
||||||
|
|
||||||
# add a corresponding zvol rdsk to the zone
|
|
||||||
echo "add device" >> $zone_conf
|
|
||||||
echo "set match=$ZVOL_RDEVDIR/$pool_name/zone_zvol" >> $zone_conf
|
|
||||||
echo "end" >> $zone_conf
|
|
||||||
|
|
||||||
# once it's supported, we'll add our filesystem to the zone
|
|
||||||
# echo "add fs" >> $zone_conf
|
|
||||||
# echo "set type=zfs" >> $zone_conf
|
|
||||||
# echo "set special=$pool_name/zfs_filesystem" >> $zone_conf
|
|
||||||
# echo "set dir=/export/zfs_filesystem" >> $zone_conf
|
|
||||||
# echo "end" >> $zone_conf
|
|
||||||
|
|
||||||
echo "verify" >> $zone_conf
|
|
||||||
echo "commit" >> $zone_conf
|
|
||||||
log_must zonecfg -z $zone_name -f $zone_conf
|
|
||||||
log_must rm -f $zone_conf
|
|
||||||
|
|
||||||
# Install the zone
|
|
||||||
if zoneadm -z $zone_name install; then
|
|
||||||
log_note "SUCCESS: zoneadm -z $zone_name install"
|
|
||||||
else
|
|
||||||
log_fail "FAIL: zoneadm -z $zone_name install"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install sysidcfg file
|
|
||||||
#
|
|
||||||
typeset sysidcfg=$zone_root/$zone_name/root/etc/sysidcfg
|
|
||||||
echo "system_locale=C" > $sysidcfg
|
|
||||||
echo "terminal=dtterm" >> $sysidcfg
|
|
||||||
echo "network_interface=primary {" >> $sysidcfg
|
|
||||||
echo "hostname=$zone_name" >> $sysidcfg
|
|
||||||
echo "}" >> $sysidcfg
|
|
||||||
echo "name_service=NONE" >> $sysidcfg
|
|
||||||
echo "root_password=mo791xfZ/SFiw" >> $sysidcfg
|
|
||||||
echo "security_policy=NONE" >> $sysidcfg
|
|
||||||
echo "timezone=US/Eastern" >> $sysidcfg
|
|
||||||
|
|
||||||
# Boot this zone
|
|
||||||
log_must zoneadm -z $zone_name boot
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Reexport TESTPOOL & TESTPOOL(1-4)
|
# Reexport TESTPOOL & TESTPOOL(1-4)
|
||||||
#
|
#
|
||||||
|
@ -2085,25 +1867,6 @@ function wait_hotspare_state # pool disk state timeout
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Verify a given slog disk is inuse or avail
|
|
||||||
#
|
|
||||||
# Return 0 is pool/disk matches expected state, 1 otherwise
|
|
||||||
#
|
|
||||||
function check_slog_state # pool disk state{online,offline,unavail}
|
|
||||||
{
|
|
||||||
typeset pool=$1
|
|
||||||
typeset disk=${2#$DEV_DSKDIR/}
|
|
||||||
typeset state=$3
|
|
||||||
|
|
||||||
cur_state=$(get_device_state $pool $disk "logs")
|
|
||||||
|
|
||||||
if [[ $state != ${cur_state} ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Verify a given vdev disk is inuse or avail
|
# Verify a given vdev disk is inuse or avail
|
||||||
#
|
#
|
||||||
|
@ -2987,12 +2750,6 @@ function ds_is_filesystem
|
||||||
[ $type = "filesystem" ]
|
[ $type = "filesystem" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
function ds_is_snapshot
|
|
||||||
{
|
|
||||||
typeset type=$(get_prop type $1)
|
|
||||||
[ $type = "snapshot" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check if Trusted Extensions are installed and enabled
|
# Check if Trusted Extensions are installed and enabled
|
||||||
#
|
#
|
||||||
|
@ -3093,18 +2850,6 @@ function get_max
|
||||||
echo $max
|
echo $max
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_min
|
|
||||||
{
|
|
||||||
typeset -l i min=$1
|
|
||||||
shift
|
|
||||||
|
|
||||||
for i in "$@"; do
|
|
||||||
min=$((min < i ? min : i))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo $min
|
|
||||||
}
|
|
||||||
|
|
||||||
# Write data that can be compressed into a directory
|
# Write data that can be compressed into a directory
|
||||||
function write_compressible
|
function write_compressible
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,26 +69,6 @@ function get_rand_prop_vals
|
||||||
echo $retstr
|
echo $retstr
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_rand_checksum
|
|
||||||
{
|
|
||||||
get_rand_prop_vals checksum $1 2
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_rand_checksum_any
|
|
||||||
{
|
|
||||||
get_rand_prop_vals checksum $1 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_rand_recsize
|
|
||||||
{
|
|
||||||
get_rand_prop_vals recsize $1 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_rand_large_recsize
|
|
||||||
{
|
|
||||||
get_rand_prop_vals recsize $1 9
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Functions to toggle on/off properties
|
# Functions to toggle on/off properties
|
||||||
#
|
#
|
||||||
|
|
|
@ -31,21 +31,6 @@
|
||||||
. $STF_SUITE/tests/functional/acl/acl.cfg
|
. $STF_SUITE/tests/functional/acl/acl.cfg
|
||||||
. $STF_SUITE/include/libtest.shlib
|
. $STF_SUITE/include/libtest.shlib
|
||||||
|
|
||||||
#
|
|
||||||
# Get the given file/directory access mode
|
|
||||||
#
|
|
||||||
# $1 object -- file or directory
|
|
||||||
#
|
|
||||||
function get_mode #<obj>
|
|
||||||
{
|
|
||||||
typeset obj=$1
|
|
||||||
if (( ${#obj} == 0 )); then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ls -ld $obj | awk '{print $1}'
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get the given file/directory ACL
|
# Get the given file/directory ACL
|
||||||
#
|
#
|
||||||
|
@ -115,36 +100,6 @@ function compare_acls #<src> <tgt>
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Check that the given two objects have the same modes.
|
|
||||||
# Return 0, if their modes are equal with each other. Otherwise, return 1.
|
|
||||||
#
|
|
||||||
# $1 source object
|
|
||||||
# $2 target object
|
|
||||||
#
|
|
||||||
function compare_modes #<src> <tgt>
|
|
||||||
{
|
|
||||||
typeset src=$1
|
|
||||||
typeset tgt=$2
|
|
||||||
typeset -i i=0
|
|
||||||
set -A mode
|
|
||||||
|
|
||||||
(( ${#src} == 0 || ${#tgt} == 0 )) && return 1
|
|
||||||
[[ $src == $tgt ]] && return 0
|
|
||||||
|
|
||||||
typeset obj
|
|
||||||
for obj in $src $tgt
|
|
||||||
do
|
|
||||||
mode[i]=$(get_mode $obj)
|
|
||||||
|
|
||||||
(( i = i + 1 ))
|
|
||||||
done
|
|
||||||
|
|
||||||
[[ ${mode[0]} != ${mode[1]} ]] && return 1
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check that the given two objects have the same xattrs.
|
# Check that the given two objects have the same xattrs.
|
||||||
# Return 0, if their xattrs are equal with each other. Otherwise, return 1.
|
# Return 0, if their xattrs are equal with each other. Otherwise, return 1.
|
||||||
|
@ -173,57 +128,6 @@ function compare_xattrs #<src> <tgt>
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Check '+' is set for a given file/directory with 'ls [-l]' command
|
|
||||||
#
|
|
||||||
# $1 object -- file or directory.
|
|
||||||
#
|
|
||||||
function plus_sign_check_l #<obj>
|
|
||||||
{
|
|
||||||
typeset obj=$1
|
|
||||||
if (( ${#obj} == 0 )); then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
! ls -ld $obj | awk '$1 ~ /\+$/ {exit 1}'
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check '+' is set for a given file/directory with 'ls [-v]' command
|
|
||||||
#
|
|
||||||
# $1 object -- file or directory.
|
|
||||||
#
|
|
||||||
function plus_sign_check_v #<obj>
|
|
||||||
{
|
|
||||||
typeset obj=$1
|
|
||||||
if (( ${#obj} == 0 )); then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
! ls -vd $obj | awk 'NR == 1 && $1 ~ /\+$ {exit 1}'
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# A wrapper function of c program
|
|
||||||
#
|
|
||||||
# $1 legal login name
|
|
||||||
# $2-n commands and options
|
|
||||||
#
|
|
||||||
function chgusr_exec #<login_name> <commands> [...]
|
|
||||||
{
|
|
||||||
chg_usr_exec $@
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Export the current user for the following usr_exec operating.
|
|
||||||
#
|
|
||||||
# $1 legal login name
|
|
||||||
#
|
|
||||||
function set_cur_usr #<login_name>
|
|
||||||
{
|
|
||||||
export ZFS_ACL_CUR_USER=$1
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Run commands by $ZFS_ACL_CUR_USER
|
# Run commands by $ZFS_ACL_CUR_USER
|
||||||
#
|
#
|
||||||
|
@ -234,80 +138,6 @@ function usr_exec #<commands> [...]
|
||||||
chg_usr_exec "$ZFS_ACL_CUR_USER" $@
|
chg_usr_exec "$ZFS_ACL_CUR_USER" $@
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Count how many ACEs for the specified file or directory.
|
|
||||||
#
|
|
||||||
# $1 file or directory name
|
|
||||||
#
|
|
||||||
function count_ACE #<file or dir name>
|
|
||||||
{
|
|
||||||
if [[ ! -e $1 ]]; then
|
|
||||||
log_note "Need input file or directory name."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ls -vd $1 | awk 'BEGIN {count=0}
|
|
||||||
(NR != 1)&&(/[0-9]:/) {count++}
|
|
||||||
END {print count}'
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get specified number ACE content of specified file or directory.
|
|
||||||
#
|
|
||||||
# $1 file or directory name
|
|
||||||
# $2 specified number
|
|
||||||
#
|
|
||||||
function get_ACE #<file or dir name> <specified number> <verbose|compact>
|
|
||||||
{
|
|
||||||
if [[ ! -e $1 || $2 -ge $(count_ACE $1) ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
typeset file=$1
|
|
||||||
typeset -i num=$2
|
|
||||||
typeset format=${3:-verbose}
|
|
||||||
typeset -i next_num=-1
|
|
||||||
|
|
||||||
typeset tmpfile=$TEST_BASE_DIR/tmp_get_ACE.$$
|
|
||||||
typeset line=""
|
|
||||||
typeset args
|
|
||||||
|
|
||||||
case $format in
|
|
||||||
verbose) args="-vd"
|
|
||||||
;;
|
|
||||||
compact) args="-Vd"
|
|
||||||
;;
|
|
||||||
*) log_fail "Invalid parameter as ($format), " \
|
|
||||||
"only verbose|compact is supported."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
log_must eval "ls $args $file > $tmpfile"
|
|
||||||
while read line; do
|
|
||||||
[[ -z $line ]] && continue
|
|
||||||
if [[ $args == -vd ]]; then
|
|
||||||
if [[ $line == "$num":* ]]; then
|
|
||||||
(( next_num = num + 1 ))
|
|
||||||
fi
|
|
||||||
if [[ $line == "$next_num":* ]]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if (( next_num != -1 )); then
|
|
||||||
print -n $line
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if (( next_num == num )); then
|
|
||||||
print -n $line
|
|
||||||
fi
|
|
||||||
(( next_num += 1 ))
|
|
||||||
fi
|
|
||||||
done < $tmpfile
|
|
||||||
|
|
||||||
log_must rm -f $tmpfile
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Cleanup exist user/group.
|
# Cleanup exist user/group.
|
||||||
#
|
#
|
||||||
|
@ -337,57 +167,6 @@ function cleanup
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# According to specified access or acl_spec, do relevant operating by using the
|
|
||||||
# specified user.
|
|
||||||
#
|
|
||||||
# $1 specified user
|
|
||||||
# $2 node
|
|
||||||
# $3 acl_spec or access
|
|
||||||
#
|
|
||||||
function rwx_node #user node acl_spec|access
|
|
||||||
{
|
|
||||||
typeset user=$1
|
|
||||||
typeset node=$2
|
|
||||||
typeset acl_spec=$3
|
|
||||||
|
|
||||||
if [[ $user == "" || $node == "" || $acl_spec == "" ]]; then
|
|
||||||
log_note "node or acl_spec are not defined."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d $node ]]; then
|
|
||||||
case $acl_spec in
|
|
||||||
*:read_data:*|read_data)
|
|
||||||
chgusr_exec $user ls -l $node > /dev/null 2>&1
|
|
||||||
;;
|
|
||||||
*:write_data:*|write_data)
|
|
||||||
if [[ -f ${node}/tmpfile ]]; then
|
|
||||||
log_must rm -f ${node}/tmpfile
|
|
||||||
fi
|
|
||||||
chgusr_exec $user touch ${node}/tmpfile > \
|
|
||||||
/dev/null 2>&1
|
|
||||||
;;
|
|
||||||
*"execute:"*|execute)
|
|
||||||
chgusr_exec $user find $node > /dev/null 2>&1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
case $acl_spec in
|
|
||||||
*:read_data:*|read_data)
|
|
||||||
chgusr_exec $user cat $node > /dev/null 2>&1
|
|
||||||
;;
|
|
||||||
*:write_data:*|write_data)
|
|
||||||
chgusr_exec $user dd if=/usr/bin/ls of=$node > \
|
|
||||||
/dev/null 2>&1
|
|
||||||
;;
|
|
||||||
*"execute:"*|execute)
|
|
||||||
ZFS_ACL_ERR_STR=$(chgusr_exec $user $node 2>&1)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get the given file/directory xattr
|
# Get the given file/directory xattr
|
||||||
#
|
#
|
||||||
|
@ -406,121 +185,6 @@ function get_xattr #<obj>
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Get the owner of a file/directory
|
|
||||||
#
|
|
||||||
function get_owner #node
|
|
||||||
{
|
|
||||||
typeset node=$1
|
|
||||||
typeset value
|
|
||||||
|
|
||||||
if [[ -z $node ]]; then
|
|
||||||
log_fail "node is not defined."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d $node ]]; then
|
|
||||||
ls -dl $node
|
|
||||||
elif [[ -e $node ]]; then
|
|
||||||
ls -l $node
|
|
||||||
fi | awk '{print $3}'
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get the group of a file/directory
|
|
||||||
#
|
|
||||||
function get_group #node
|
|
||||||
{
|
|
||||||
typeset node=$1
|
|
||||||
typeset value
|
|
||||||
|
|
||||||
if [[ -z $node ]]; then
|
|
||||||
log_fail "node are not defined."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d $node ]]; then
|
|
||||||
ls -dl $node
|
|
||||||
elif [[ -e $node ]]; then
|
|
||||||
ls -l $node
|
|
||||||
fi | awk '{print $4}'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get the group name that a UID belongs to
|
|
||||||
#
|
|
||||||
function get_user_group #uid
|
|
||||||
{
|
|
||||||
typeset uid=$1
|
|
||||||
typeset value
|
|
||||||
|
|
||||||
if [[ -z $uid ]]; then
|
|
||||||
log_fail "UID not defined."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if value=$(id $uid); then
|
|
||||||
value=${value##*\(}
|
|
||||||
value=${value%%\)*}
|
|
||||||
echo $value
|
|
||||||
else
|
|
||||||
log_fail "Invalid UID (uid)."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get the specified item of the specified string
|
|
||||||
#
|
|
||||||
# $1: Item number, count from 0.
|
|
||||||
# $2-n: strings
|
|
||||||
#
|
|
||||||
function getitem
|
|
||||||
{
|
|
||||||
typeset -i n=$1
|
|
||||||
shift
|
|
||||||
|
|
||||||
(( n += 1 ))
|
|
||||||
eval echo \${$n}
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# This function calculate the specified directory files checksum and write
|
|
||||||
# to the specified array.
|
|
||||||
#
|
|
||||||
# $1 directory in which the files will be cksum.
|
|
||||||
# $2 file array name which was used to store file cksum information.
|
|
||||||
# $3 attribute array name which was used to store attribute information.
|
|
||||||
#
|
|
||||||
function cksum_files #<dir> <file_array_name> <attribute_array_name>
|
|
||||||
{
|
|
||||||
typeset dir=$1
|
|
||||||
typeset farr_name=$2
|
|
||||||
typeset aarr_name=$3
|
|
||||||
|
|
||||||
[[ ! -d $dir ]] && return
|
|
||||||
typeset oldpwd=$PWD
|
|
||||||
cd $dir
|
|
||||||
typeset files=$(ls file*)
|
|
||||||
|
|
||||||
typeset -i i=0
|
|
||||||
typeset -i n=0
|
|
||||||
while (( i < NUM_FILE )); do
|
|
||||||
typeset f=$(getitem $i $files)
|
|
||||||
eval $farr_name[$i]=\$\(\cksum $f\)
|
|
||||||
|
|
||||||
typeset -i j=0
|
|
||||||
while (( j < NUM_ATTR )); do
|
|
||||||
eval $aarr_name[$n]=\$\(\runat \$f \cksum \
|
|
||||||
attribute.$j\)
|
|
||||||
|
|
||||||
(( j += 1 ))
|
|
||||||
(( n += 1 ))
|
|
||||||
done
|
|
||||||
|
|
||||||
(( i += 1 ))
|
|
||||||
done
|
|
||||||
|
|
||||||
cd $oldpwd
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# This function compare two cksum results array.
|
# This function compare two cksum results array.
|
||||||
#
|
#
|
||||||
|
@ -548,26 +212,6 @@ function compare_cksum #<array1> <array2>
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# This function calculate all the files cksum information in current directory
|
|
||||||
# and output them to the specified file.
|
|
||||||
#
|
|
||||||
# $1 directory from which the files will be cksum.
|
|
||||||
# $2 cksum output file
|
|
||||||
#
|
|
||||||
function record_cksum #<outfile>
|
|
||||||
{
|
|
||||||
typeset dir=$1
|
|
||||||
typeset outfile=$2
|
|
||||||
|
|
||||||
[[ ! -d ${outfile%/*} ]] && usr_exec mkdir -p ${outfile%/*}
|
|
||||||
|
|
||||||
usr_exec cd $dir ; find . -depth -type f -exec cksum {} \\\; | \
|
|
||||||
sort > $outfile
|
|
||||||
usr_exec cd $dir ; find . -depth -type f -xattr -exec runat {} \
|
|
||||||
cksum attribute* \\\; | sort >> $outfile
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# The function create_files creates the directories and files that the script
|
# The function create_files creates the directories and files that the script
|
||||||
# will operate on to test extended attribute functionality.
|
# will operate on to test extended attribute functionality.
|
||||||
|
|
|
@ -151,43 +151,6 @@ function mmp_pool_set_hostid # pool hostid
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
# Return the number of seconds the activity check portion of the import process
|
|
||||||
# will take. Does not include the time to find devices and assemble a config.
|
|
||||||
# Note that the activity check may be skipped, e.g. if the pool and host
|
|
||||||
# hostid's match, but this will return non-zero because mmp_* are populated.
|
|
||||||
function seconds_mmp_waits_for_activity
|
|
||||||
{
|
|
||||||
typeset pool=$1
|
|
||||||
typeset devpath=$2
|
|
||||||
|
|
||||||
typeset seconds=0
|
|
||||||
typeset devices=${#DISK[@]}
|
|
||||||
typeset import_intervals=$(get_tunable MULTIHOST_IMPORT_INTERVALS)
|
|
||||||
typeset import_interval=$(get_tunable MULTIHOST_INTERVAL)
|
|
||||||
typeset tmpfile=$(mktemp)
|
|
||||||
typeset mmp_fail
|
|
||||||
typeset mmp_write
|
|
||||||
typeset mmp_delay
|
|
||||||
|
|
||||||
log_must eval "zdb -e -p $devpath $pool >$tmpfile 2>/dev/null"
|
|
||||||
mmp_fail=$(awk '/mmp_fail/ {print $NF}' $tmpfile)
|
|
||||||
mmp_write=$(awk '/mmp_write/ {print $NF}' $tmpfile)
|
|
||||||
mmp_delay=$(awk '/mmp_delay/ {print $NF}' $tmpfile)
|
|
||||||
rm $tmpfile
|
|
||||||
|
|
||||||
# In order of preference:
|
|
||||||
if [ -n $mmp_fail -a -n $mmp_write ]; then
|
|
||||||
seconds=$((2*mmp_fail*mmp_write/1000))
|
|
||||||
elif [ -n $mmp_delay ]; then
|
|
||||||
# MMP V0: Based on mmp_delay from the best Uberblock
|
|
||||||
seconds=$((import_intervals*devices*mmp_delay/1000000000))
|
|
||||||
else
|
|
||||||
# Non-MMP aware: Based on zfs_multihost_interval and import_intervals
|
|
||||||
seconds=$((import_intervals*import_interval/1000))
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $seconds
|
|
||||||
}
|
|
||||||
|
|
||||||
function import_no_activity_check # pool opts
|
function import_no_activity_check # pool opts
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,13 +88,6 @@ function attempt_during_removal # pool disk callback [args]
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function indirect_vdev_mapping_size # pool
|
|
||||||
{
|
|
||||||
typeset pool=$1
|
|
||||||
zdb -P $pool | grep 'indirect vdev' | \
|
|
||||||
sed -E 's/.*\(([0-9]+) in memory\).*/\1/g'
|
|
||||||
}
|
|
||||||
|
|
||||||
function random_write # file write_size
|
function random_write # file write_size
|
||||||
{
|
{
|
||||||
typeset file=$1
|
typeset file=$1
|
||||||
|
|
|
@ -155,12 +155,6 @@ function cleanup_pool
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_pools
|
|
||||||
{
|
|
||||||
cleanup_pool $POOL2
|
|
||||||
destroy_pool $POOL3
|
|
||||||
}
|
|
||||||
|
|
||||||
function cmp_md5s {
|
function cmp_md5s {
|
||||||
typeset file1=$1
|
typeset file1=$1
|
||||||
typeset file2=$2
|
typeset file2=$2
|
||||||
|
|
|
@ -524,20 +524,6 @@ function get_system_config
|
||||||
echo "}" >>$config
|
echo "}" >>$config
|
||||||
}
|
}
|
||||||
|
|
||||||
function num_jobs_by_cpu
|
|
||||||
{
|
|
||||||
if is_linux; then
|
|
||||||
typeset ncpu=$($NPROC --all)
|
|
||||||
else
|
|
||||||
typeset ncpu=$(psrinfo | $WC -l)
|
|
||||||
fi
|
|
||||||
typeset num_jobs=$ncpu
|
|
||||||
|
|
||||||
[[ $ncpu -gt 8 ]] && num_jobs=$(echo "$ncpu * 3 / 4" | bc)
|
|
||||||
|
|
||||||
echo $num_jobs
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# On illumos this looks like: ":sd3:sd4:sd1:sd2:"
|
# On illumos this looks like: ":sd3:sd4:sd1:sd2:"
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue