Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
7629 Fix for 7290 neglected to remove some escape sequences
Browse files Browse the repository at this point in the history
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
  • Loading branch information
jwk404 authored and ahrens committed Jan 13, 2017
1 parent ad309d3 commit f5fb56d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 144 deletions.
139 changes: 3 additions & 136 deletions usr/src/test/zfs-tests/include/libtest.shlib
Expand Up @@ -28,9 +28,6 @@

. ${STF_TOOLS}/contrib/include/logapi.shlib

ZFS=${ZFS:-/usr/sbin/zfs}
ZPOOL=${ZPOOL:-/usr/sbin/zpool}

# Determine whether a dataset is mounted
#
# $1 dataset name
Expand Down Expand Up @@ -263,7 +260,7 @@ function create_bookmark
snapexists $fs_vol@$snap || \
log_fail "$fs_vol@$snap must exist."

log_must $ZFS bookmark $fs_vol@$snap $fs_vol#$bkmark
log_must zfs bookmark $fs_vol@$snap $fs_vol#$bkmark
}

function default_mirror_setup
Expand Down Expand Up @@ -558,7 +555,7 @@ function destroy_bookmark
log_fail "'$bkmarkp' does not existed."
fi

log_must $ZFS destroy $bkmark
log_must zfs destroy $bkmark
}

# Return 0 if a snapshot exists; $? otherwise
Expand All @@ -578,7 +575,7 @@ function snapexists
#
function bkmarkexists
{
$ZFS list -H -t bookmark "$1" > /dev/null 2>&1
zfs list -H -t bookmark "$1" > /dev/null 2>&1
return $?
}

Expand Down Expand Up @@ -1585,136 +1582,6 @@ function cleanup_devices #vdevs
return 0
}

#
# Verify the rsh connectivity to each remote host in RHOSTS.
#
# Return 0 if remote host is accessible; otherwise 1.
# $1 remote host name
# $2 username
#
function verify_rsh_connect #rhost, username
{
typeset rhost=$1
typeset username=$2
typeset rsh_cmd="rsh -n"
typeset cur_user=

getent hosts $rhost >/dev/null 2>&1
if (($? != 0)); then
log_note "$rhost cannot be found from" \
"administrative database."
return 1
fi

ping $rhost 3 >/dev/null 2>&1
if (($? != 0)); then
log_note "$rhost is not reachable."
return 1
fi

if ((${#username} != 0)); then
rsh_cmd="$rsh_cmd -l $username"
cur_user="given user \"$username\""
else
cur_user="current user \"`logname`\""
fi

if ! $rsh_cmd $rhost true; then
log_note "rsh to $rhost is not accessible" \
"with $cur_user."
return 1
fi

return 0
}

#
# Verify the remote host connection via rsh after rebooting
# $1 remote host
#
function verify_remote
{
rhost=$1

#
# The following loop waits for the remote system rebooting.
# Each iteration will wait for 150 seconds. there are
# total 5 iterations, so the total timeout value will
# be 12.5 minutes for the system rebooting. This number
# is an approxiate number.
#
typeset -i count=0
while ! verify_rsh_connect $rhost; do
sleep 150
((count = count + 1))
if ((count > 5)); then
return 1
fi
done
return 0
}

#
# Replacement function for /usr/bin/rsh. This function will include
# the /usr/bin/rsh and meanwhile return the execution status of the
# last command.
#
# $1 usrname passing down to -l option of /usr/bin/rsh
# $2 remote machine hostname
# $3... command string
#

function rsh_status
{
typeset ruser=$1
typeset rhost=$2
typeset -i ret=0
typeset cmd_str=""
typeset rsh_str=""

shift; shift
cmd_str="$@"

err_file=/tmp/${rhost}.$$.err
if ((${#ruser} == 0)); then
rsh_str="rsh -n"
else
rsh_str="rsh -n -l $ruser"
fi

$rsh_str $rhost /usr/bin/ksh -c "'$cmd_str; \
print -u 2 \"status=\$?\"'" \
>/dev/null 2>$err_file
ret=$?
if (($ret != 0)); then
cat $err_file
rm -f $std_file $err_file
log_fail "rsh itself failed with exit code $ret..."
fi

ret=$(grep -v 'print -u 2' $err_file | grep 'status=' | \
cut -d= -f2)
(($ret != 0)) && cat $err_file >&2

rm -f $err_file >/dev/null 2>&1
return $ret
}

#
# Get the SUNWstc-fs-zfs package installation path in a remote host
# $1 remote host name
#
function get_remote_pkgpath
{
typeset rhost=$1
typeset pkgpath=""

pkgpath=$(rsh -n $rhost "pkginfo -l SUNWstc-fs-zfs | grep BASEDIR: |\
cut -d: -f2")

echo $pkgpath
}

#/**
# A function to find and locate free disks on a system or from given
# disks as the parameter. It works by locating disks that are in use
Expand Down
Expand Up @@ -142,11 +142,11 @@ i=0
while ((i < ${#bookmark[@]})); do
for opt in "${options[@]}"; do
for prop in ${bookmark_props[@]}; do
eval "$ZFS get $opt $prop ${bookmark[i]} > \
eval "zfs get $opt $prop ${bookmark[i]} > \
$TESTDIR/$TESTFILE0"
ret=$?
if [[ $ret != 0 ]]; then
log_fail "$ZFS get returned: $ret"
log_fail "zfs get returned: $ret"
fi
check_return_value ${bookmark[i]} "$prop" "$opt"
done
Expand Down
Expand Up @@ -112,10 +112,10 @@ function test_options_bookmarks
for dst in ${bookmark[@]}; do
for opt in $opts; do
for prop in $props; do
$ZFS get $opt -- $prop $dst > /dev/null 2>&1
zfs get $opt -- $prop $dst > /dev/null 2>&1
ret=$?
if [[ $ret == 0 ]]; then
log_fail "$ZFS get $opt -- $prop " \
log_fail "zfs get $opt -- $prop " \
"$dst unexpectedly succeeded."
fi
done
Expand Down
Expand Up @@ -103,7 +103,7 @@ for dst in ${bookmark[@]}; do
while (( i < opt_numb )); do
(( item = $RANDOM % ${#options[@]} ))
(( depth_item = $RANDOM % ${#depth_options[@]} ))
log_must eval "$ZFS get -${depth_options[depth_item]} ${options[item]} $bookmark_props $dst > /dev/null 2>&1"
log_must eval "zfs get -${depth_options[depth_item]} ${options[item]} $bookmark_props $dst > /dev/null 2>&1"
(( i += 1 ))
done
done
Expand Down
Expand Up @@ -122,7 +122,7 @@ function setup_snap_env
# before taking a snapshot.
#
if [[ $dtst == $VOL ]]; then
log_must /usr/sbin/lockfs -f $TESTDIR1
log_must lockfs -f $TESTDIR1
fi
log_must zfs snapshot $snap
fi
Expand Down
Expand Up @@ -57,11 +57,11 @@ do
(( i = i + 1 ))
done

\sleep 1
sleep 1

for pid in \$PIDS
do
\wait \$pid
wait \$pid
(( \$? == 127 )) && exit 1
done
exit 0
Expand Down

0 comments on commit f5fb56d

Please sign in to comment.