1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # ident "@(#)share_common.ksh   1.6     09/08/25 SMI"
  27 #
  28 
  29 #
  30 # This file contains common functions and is meant to be sourced into
  31 # the test case files.
  32 #
  33 
  34 CHECKENV=${TET_ROOT}/../checkenv/bin/checkenv
  35 [[ -z $TESTDIR ]] && TESTDIR="/SHARE_tests"
  36 set -A MP ${TESTDIR}/td1 ${TESTDIR}/td2 ${TESTDIR}/td3 ${TESTDIR}/td4 ${TESTDIR}/td5
  37 
  38 #
  39 # If you need more groups make sure to add them to the TG array!
  40 # and note unless added here or before startup is called the
  41 # new groups will no be tested for in use.
  42 #
  43 set -A TG test_group_1 test_group_2 test_group_3 test_group_4
  44 
  45 #
  46 # Output files used to verify information
  47 #
  48 CMD_SUMMARY_FILE=$SHR_TMPDIR/sharemgr_cmd_summary.$$
  49 DFSTAB=/etc/dfs/dfstab
  50 SHARETAB=/etc/dfs/sharetab
  51 LOGDIR=$SHR_TMPDIR/sharemgr_logs
  52 dfs_log=${LOGDIR}/dfsshare
  53 l_log=${LOGDIR}/sharemgr_list
  54 s_log=${LOGDIR}/sharemgr_show
  55 sharectl_orig=${LOGDIR}/sharectl_orig.log
  56 
  57 whence -p stc_genutils > /dev/null 2>&1
  58 if (( $? != 0 )); then
  59         print -u2 "share_common: stc_genutils command not found!"
  60         exit 1
  61 fi
  62 STC_GENUTILS=$(stc_genutils path)
  63 . $STC_GENUTILS/include/nfs-util.kshlib
  64 
  65 . ${TET_SUITE_ROOT}/sharefs-tests/include/commands
  66 . ${TET_SUITE_ROOT}/sharefs-tests/lib/utils_common
  67 . ${TET_SUITE_ROOT}/sharefs-tests/lib/verify_common
  68 
  69 
  70 #
  71 # NAME
  72 #       print_test_case
  73 #
  74 # DESCRIPTION
  75 #       Print the test case name to the results formated to fit with
  76 #       60 characters.
  77 #
  78 function print_test_case {
  79         unset ptc_short_info
  80         ptc_info="Test case $*"
  81 
  82         tet_infoline "======================================================="
  83 
  84         if [ `echo $ptc_info | $WC -c` -gt 60 ]
  85         then
  86                 #
  87                 # Split the line
  88                 #
  89                 ptc_ltrcnt=0
  90                 for ptc_word in $ptc_info
  91                 do
  92                         ptc_wordsz=`echo $ptc_word | $WC -c`
  93                         ptc_ltrcnt=`$EXPR $ptc_ltrcnt + $ptc_wordsz + 1`
  94                         if [ $ptc_ltrcnt -gt 60 ]
  95                         then
  96                                 tet_infoline "$ptc_short_info"
  97                                 ptc_short_info=" $ptc_word"
  98                                 ptc_ltrcnt=`$EXPR $ptc_wordsz`
  99                         else
 100                                 ptc_short_info="$ptc_short_info $ptc_word"
 101                         fi
 102                 done
 103                 if [ $ptc_ltrcnt -gt 0 ]
 104                 then
 105                         tet_infoline "$ptc_short_info"
 106                 fi
 107         else
 108                 tet_infoline "$ptc_info"
 109         fi
 110 
 111         tet_infoline "======================================================="
 112 }
 113 
 114 #
 115 # NAME
 116 #       remove_group_from_list
 117 #
 118 # SYNOPSIS
 119 #       remove_group_from_list <group>
 120 #
 121 # DESCRIPTION
 122 #       Remove the specified group from the global GROUPS variable.
 123 #
 124 function remove_group_from_list {
 125         rgfl_rm_group="$1"
 126         unset rgfl_group_list
 127 
 128         for rgfl_group in $GROUPS
 129         do
 130                 if [ "$rgfl_rm_group" != "$rgfl_group" ]
 131                 then
 132                         rgfl_group_list="$rgfl_group_list $rgfl_group"
 133                 fi
 134         done
 135         GROUPS="$rgfl_group_list"
 136 }
 137 
 138 #
 139 # NAME
 140 #       remove_protocol_from_list
 141 #
 142 # SYNOPSIS
 143 #       remove_protocol_from_list protocol group
 144 #
 145 # Description
 146 #       Remove the specified protocol from the global PROTOCOL list for the 
 147 #       specified group.
 148 #
 149 function remove_protocol_from_list {
 150         rpfl_rm_protocol=$1
 151         rpfl_group=$2
 152         unset rpfl_protocol_list
 153 
 154         eval rpfl_list=\"\$PROTOCOLS_${rpfl_group}\"
 155         for rpfl_protocol in $rpfl_list
 156         do
 157                 if [ "$rpfl_rm_protocol" != "$rpfl_protocol" ]
 158                 then
 159                         rpfl_protocol_list="$rpfl_protocol_list $rpfl_protocol"
 160                 fi
 161         done
 162 
 163         eval PROTOCOLS_${rpfl_group}=\"$rpfl_protocol_list\"
 164 }
 165 
 166 #
 167 # NAME
 168 #       which_group
 169 #
 170 # DESCRIPTION
 171 #       For a given share, determine which group it currently belongs to.
 172 #
 173 function which_group {
 174         wg_target_share="$1"
 175         unset wg_match_group
 176 
 177         #
 178         # For every group created by this test case, determine if the
 179         # specified share belongs to that group.
 180         #
 181         for wg_group in $GROUPS
 182         do
 183                 eval wg_shares=\"\$SHARES_${wg_group}\"
 184 
 185                 #
 186                 # Step through every share in the current group, looking for
 187                 # a match.
 188                 #
 189                 for wg_share in $wg_shares
 190                 do
 191                         if [ "$wg_share" = "$wg_target_share" ]
 192                         then
 193                                 wg_match_group="$wg_group"
 194                                 break
 195                         fi
 196                 done
 197 
 198                 if [ "$wg_match_group" ]
 199                 then
 200                         break
 201                 fi
 202         done
 203 
 204         echo $wg_match_group
 205 }
 206 
 207 #
 208 # NAME
 209 #       list
 210 #
 211 # DESCRIPTION
 212 #       Execute 'sharemgr list' command and verify output.
 213 #       l_options = options to proved to the list command
 214 #
 215 function list {
 216         unset l_options
 217         cmdlvl=0
 218 
 219         while getopts P:v options
 220         do
 221                 case $options in
 222                 P)      l_options="$l_options -P $OPTARG";;
 223                 v)      l_options="$l_options -v";;
 224                 esac
 225         done
 226         shift $((OPTIND - 1))
 227         if [ "$1" = "NEG" ]
 228         then
 229                 l_pos_neg=$1
 230                 shift
 231         else
 232                 l_pos_neg="POS"
 233                 if [ "$1" = "POS" ]
 234                 then
 235                         shift
 236                 fi
 237         fi
 238 
 239         logfile=`get_logfile list ${l_options}`
 240         if [ -f $logfile ]
 241         then
 242                 return
 243         fi
 244         l_cmd="${cmd_prefix}${SHAREMGR} list $l_options"
 245         tet_infoline "  - $l_cmd"
 246         if [ "$report_only" != "TRUE" ]
 247         then
 248                 eval ${l_cmd}${cmd_postfix} > $logfile 2>&1
 249                 l_retval=$?
 250         fi
 251         append_cmd $l_cmd${cmd_postfix}
 252 
 253         if [ $l_pos_neg = "POS" ]
 254         then
 255                 POS_result $l_retval "$l_cmd"
 256         else
 257                 NEG_result $l_retval "$l_cmd"
 258         fi
 259 }
 260 
 261 
 262 #
 263 # NAME
 264 #       show
 265 #
 266 # DESCRIPTION
 267 #       Execute 'sharemgr show' command
 268 #
 269 function show {
 270         unset s_options
 271         cmdlvl=0
 272 
 273         while getopts P:vp options
 274         do
 275                 case $options in
 276                 P)      s_options="$s_options -P $OPTARG";;
 277                 p)      s_options="$s_options -p";;
 278                 v)      s_options="$s_options -v";;
 279                 esac
 280         done
 281         shift $((OPTIND - 1))
 282 
 283         if [ "$1" = "NEG" ]
 284         then
 285                 s_pos_neg=$1
 286                 shift
 287         else
 288                 s_pos_neg="POS"
 289                 if [ "$1" = "POS" ]
 290                 then
 291                         shift
 292                 fi
 293         fi
 294 
 295         s_group="$*"
 296 
 297         #
 298         # This will have to be updated if multiple groups are
 299         # given to show.
 300         #
 301         logfile=`get_logfile show ${s_options} ${s_group}`
 302         if [ -f $logfile ]
 303         then
 304                 return
 305         fi
 306         s_cmd="${cmd_prefix}${SHAREMGR} show $s_options $s_group"
 307         tet_infoline " - ${s_cmd}${cmd_postfix}"
 308         if [ "$report_only" != "TRUE" ]
 309         then
 310                 eval $s_cmd${cmd_postfix} > $logfile 2>&1
 311                 s_result=$?
 312         fi
 313         append_cmd ${s_cmd}${cmd_postfix}
 314 
 315         # o Verify return code is 0"
 316         if [ $s_pos_neg = "POS" ]
 317         then
 318                 POS_result $s_result "$s_cmd"
 319         else
 320                 NEG_result $s_result "$s_cmd"
 321         fi
 322 }
 323 
 324 #
 325 # NAME
 326 #       clear_remembered_info
 327 #
 328 # SYNOPSIS
 329 #       clear_remembered_info <share_group_name> [protocol] [properties]
 330 #
 331 # DESCRIPTION
 332 #       Clear (unset) variables used to remember protocol and property
 333 #       settings for the specified share group.
 334 #
 335 function clear_remembered_info {
 336         cri_group="$1"
 337         shift
 338 
 339         for cri_item in $*
 340         do
 341                 if [ "$cri_item" = "protocol" ]
 342                 then
 343                         eval unset PROTOCOLS_${cri_group}
 344                 elif [ "$cri_item" = "properties" ]
 345                 then
 346                         # Get list of property variables currently defined
 347                         # for this group and unset each of them.
 348                         for cri_property in `set | \
 349                             $GREP "^PROPERTY_${cri_group}" | $SED 's/=.*//'`
 350                         do
 351                                 unset $cri_property
 352                         done
 353                 fi
 354         done
 355 }
 356 
 357 #
 358 # NAME
 359 #       remember_protocol_settings
 360 #
 361 # SYNOPSIS
 362 #       remember_protocol_settings <group> <create or set> <protocol args>
 363 #
 364 # DESCRIPTION
 365 #       When a 'sharemgr create' or 'sharemgr set' command is executed, this
 366 #       function is called to determine if the protocol setting is being
 367 #       modified by the command.  If so, update the global variable used to
 368 #       track what the current protocol value should be for this group.
 369 #
 370 function remember_protocol_settings {
 371         rps_group="$1"
 372         rps_op="$2"
 373         shift 2
 374         rps_args="$*"
 375         unset rps_protocol
 376 
 377         #
 378         # Walk through the arguments for the 'sharemgr create' or
 379         # 'sharemgr set' command.  If it contains a '-P' option to set
 380         # the protocol for the group, set the global protocol variable for
 381         # that group to match.
 382         #
 383         unset rps_specific_protocols
 384         while [ $# -gt 0 ]
 385         do
 386                 case $1 in
 387                 "-P")   rps_specific_protocols="yes"
 388                         shift
 389                         rps_protocol="$1"
 390                         if [ "$rps_op" = "create" ]
 391                         then
 392                                 if [ "$1" = '""' ]
 393                                 then
 394                                         # No protocols for group
 395                                         eval unset PROTOCOLS_${rps_group}
 396                                         $SHARES_${wg_group}
 397                                 else
 398                                         # Add protocol to group
 399                                         eval PROTOCOLS_${rps_group}=\"\$PROTOCOLS_${rps_group} $rps_protocol\"
 400                                 fi
 401                         fi;;
 402                 "-S")
 403                         #
 404                         # Treat this like an additional protocol for
 405                         # later checking.
 406                         #
 407                         rps_specific_protocols="yes"
 408                         shift
 409                         rps_protocol_name="${rps_protocol}:$1"
 410                         rps_protocol="${rps_protocol}$1"
 411                         # Add Security mode to group
 412                         if [ "$rps_op" = "unset" ]
 413                         then
 414                                 echo "$*" | $GREP "\-p" > /dev/null 2>&1
 415                                 if [ $? -ne 0 ]
 416                                 then
 417                                         remove_protocol_from_list \
 418                                             $rps_protocol_name $rps_group
 419                                 fi
 420                         else
 421                                 rps_tmp=\"\$PROTOCOLS_${rps_group}\"
 422                                 echo "$rps_tmp" | \
 423                                     $GREP "$rps_protocol_name" > /dev/null
 424                                 if [ $? -ne 0 ]
 425                                 then
 426                                         eval PROTOCOLS_${rps_group}=\"\$PROTOCOLS_${rps_group} $rps_protocol_name\"
 427                                 fi
 428                         fi
 429                         ;;
 430                 "-p")
 431                         #
 432                         # Setting or clearing properties for protocol
 433                         #
 434                         shift
 435                         rps_property="`echo $1 | $SED 's/=.*//'`"
 436                         # rps_value="`echo $1 | $SED s/^.*=//'`"
 437                         rps_value="`echo $1 | $SED s/^.*=//`"
 438                         if [ "$rps_op" = "unset" ]
 439                         then
 440                                 eval unset PROPERTY_${rps_group}_${rps_protocol}_${rps_property}
 441                         else
 442                                 #
 443                                 # create or set operations will always set a
 444                                 # value (even if null).
 445                                 #
 446                                 eval PROPERTY_${rps_group}_${rps_protocol}_${rps_property}=\"$rps_value\"
 447                         fi;;
 448                 esac
 449                 shift
 450         done
 451 
 452         #
 453         # If this is a 'create' command and no protocols were specified, the
 454         # default is for the group to have all default protocols.
 455         #
 456         if [ ! "$rps_specific_protocols" -a "$rps_op" = "create" ]
 457         then
 458                 eval PROTOCOLS_${rps_group}=\"$def_protocols\"
 459         fi
 460 }
 461 
 462 #
 463 # NAME
 464 #       compare_protocol_properties
 465 #
 466 # SYNOPSIS
 467 #       compare_protocol_properties group protocol <protocol name=value pairs>
 468 #
 469 # DESCRIPTION
 470 #       This function is provided with a group name, a protocol for that
 471 #       group, and a list of property name/value pairs obtained from the
 472 #       'sharemgr show -p' command for the group/protocol.  Compare all
 473 #       of the properties against those we think should be in place.
 474 #
 475 function compare_protocol_properties {
 476         cpp_group="$1"
 477         cpp_protocol="$2"
 478         shift 2
 479         cpp_pairs="$*"
 480         cpp_retval=0
 481 
 482         #
 483         # First walk through all of the properties that the 'show -p' command
 484         # indicates are set.
 485         #
 486         unset cpp_checked_props
 487         for cpp_pair in $cpp_pairs
 488         do
 489                 # Extract the property name
 490                 cpp_prop_name="`echo $cpp_pair | $SED 's/=.*//'`"
 491                 # Extract the property value and eliminate double quotes
 492                 cpp_prop_value="`echo $cpp_pair | $SED 's/.*=//' | \
 493                     $SED 's/\"//g'`"
 494 
 495                 if set | $GREP \
 496                     "^PROPERTY_${cpp_group}_${cpp_protocol}_${cpp_prop_name}" \
 497                     >/dev/null 2>&1
 498                 then
 499                         eval cpp_remembered_value=\"\$PROPERTY_${cpp_group}_${cpp_protocol}_${cpp_prop_name}\"
 500                         if [ "$cpp_prop_value" != "$cpp_remembered_value" ]
 501                         then
 502                                 tet_infoline "ERR $cpp_protocol property" \
 503                                     "$cpp_prop_name is \"$cpp_prop_value\"," \
 504                                     "expected \"$cpp_remembered_value\""
 505                                 cpp_retval=1
 506                         fi
 507                 else
 508                         tet_infoline "ERR $cpp_protocol property" \
 509                             "$cpp_prop_name should not be set but is shown" \
 510                             "in 'show -p' output"
 511                         cpp_retval=1
 512                 fi
 513                 cpp_checked_props="$cpp_checked_props $cpp_prop_name"
 514 
 515         done
 516 
 517         #
 518         # Now make sure that all of the properties that we remember having
 519         # been set for this protocol were reported by 'show -p'.
 520         #
 521         for cpp_remembered_prop in `set | grep "^PROPERTY_${cpp_group}_${cpp_protocol}_" | $SED 's/=.*//'`
 522         do
 523                 cpp_name=`echo $cpp_remembered_prop | $SED 's/.*_//'`
 524                 unset cpp_prop_name_match
 525                 for cpp_checked_prop in $cpp_checked_props
 526                 do
 527                         if [ "$cpp_name" = "$cpp_checked_prop" ]
 528                         then
 529                                 cpp_prop_name_match="yes"
 530                                 break
 531                         fi
 532                 done
 533                 if [ ! "$cpp_prop_name_match" ]
 534                 then
 535                         eval cpp_value=\"\$$cpp_remembered_prop\"
 536                         tet_infoline "ERR expected property $cpp_name to be" \
 537                             "'$cpp_value' but 'show -p' doesn't show that" \
 538                             "property"
 539                         cpp_retval=1
 540                 fi
 541         done
 542 
 543         return $cpp_retval
 544 }
 545 
 546 #
 547 # NAME
 548 #       protocol_property_verification
 549 #
 550 # SYNOPSIS
 551 #       protocol_property_verification <group>
 552 #
 553 # DESCRIPTION
 554 #       Execute the 'sharemgr show -p' command for the specified group to
 555 #       retrieve the protocols and properties that sharemgr says are set for
 556 #       that group.  Compare all of the protocols/properties reported by
 557 #       'show -p' against those we think should be in place for the specified
 558 #       group.
 559 #
 560 function protocol_property_verification {
 561         ppv_group="$1"
 562         ppv_retval=0
 563 
 564         #
 565         # Execute 'sharemgr show -p' command for the group and extract the
 566         # line of output that corresponds to the specified group.
 567         #
 568         eval debug_var=\"\$PROTOCOLS_${ppv_group}\"
 569         logfile=`get_logfile show -p`
 570         ppv_cmd="$SHAREMGR show -p"
 571         tet_infoline "  - $ppv_cmd"
 572         $ppv_cmd > $logfile 2>&1
 573         ppv_group_line="`$AWK ' { if ( $1 == group ) { print } } ' group=$ppv_group $logfile`"
 574 
 575         if [ ! "$ppv_group_line" ]
 576         then
 577                 POS_result 1 \
 578                     "Unable to locate group '$ppv_group' in output of '$ppv_cmd'"
 579                 return 1
 580         fi
 581 
 582         #
 583         # This is a really ugly sed line used to so that we can break up a
 584         # line that looks like:
 585         #       test_group_1 nfs=() nfs:dh=(ro="thistle:cawdor" rw="*")
 586         # so that we can get at the information for each individual protocol.
 587         # There's got to be a better way...
 588         #
 589         set `echo $ppv_group_line | $SED -e 's/=()//g' -e 's/\" /\"|/g' \
 590             -e 's/) / /g' -e 's/)//g' -e 's/=(/|/g'`
 591         shift
 592         ppv_tmp_line="$*"
 593 
 594         #
 595         # Walk through each protocol and associated properties reported by
 596         # 'show -p'
 597         #
 598         eval ppv_remembered_protocols=\"\$PROTOCOLS_${ppv_group}\"
 599         unset ppv_checked_protocols
 600         for ppv_show_proto_info in $ppv_tmp_line
 601         do
 602                 # The protocol info fields are currently separated by
 603                 # pipe characters as a result of the ugly sed command
 604                 # above.  Replace those with spaces and then place the resulting
 605                 # string in $* so we can access each field individually.
 606                 #
 607                 set `echo $ppv_show_proto_info | $SED 's/|/ /g'`
 608                 ppv_show_protocol="$1"
 609                 shift
 610 
 611                 #
 612                 # Check the protocol from 'show -p' against the protocol(s)
 613                 # that we think should be set for this share group.
 614                 #
 615                 unset ppv_protocol_match
 616                 for ppv_compare_group in $ppv_remembered_protocols
 617                 do
 618                         if [ "$ppv_compare_group" = "$ppv_show_protocol" ]
 619                         then
 620                                 ppv_protocol_match="yes"
 621                                 ppv_checked_protocols="$ppv_checked_protocols $ppv_show_protocol"
 622                                 break
 623                         fi
 624                 done
 625 
 626                 #
 627                 # If we expected this protocol, go compare the property settings
 628                 #
 629                 if [ "$ppv_protocol_match" ]
 630                 then
 631                         #
 632                         # Take out the first colon if present due to a security
 633                         # protocol.
 634                         #
 635                         ppv_show_protocol=`echo $ppv_show_protocol | $SED 's/://'`
 636                         compare_protocol_properties $ppv_group $ppv_show_protocol $*
 637                         if [ $? -ne 0 ]
 638                         then
 639                                 POS_result 1 \
 640                                     "Property verification failed for group $ppv_group protocol $ppv_show_protocol"
 641                                 ppv_retval=1
 642                         fi
 643                 else
 644                         POS_result 1 \
 645                             "Protocol $ppv_show_protocol shown by 'show -p' but shouldn't be set for group $ppv_group"
 646                         ppv_retval=1
 647                 fi
 648         done
 649 
 650         #
 651         # We have checked every protocol reported by 'show -p' against those
 652         # we have stored.  Now we need to check every protocol we have
 653         # stored against those displayed by 'show -p' to make sure the show
 654         # command is not missing any of them.
 655         #
 656         for ppv_remembered_protocol in $ppv_remembered_protocols
 657         do
 658                 unset ppv_protocol_match
 659                 for ppv_checked_protocol in $ppv_checked_protocols
 660                 do
 661                         if [ "$ppv_checked_protocol" = "$ppv_remembered_protocol" ]
 662                         then
 663                                 ppv_protocol_match="yes"
 664                         fi
 665                 done
 666                 if [ ! "$ppv_protocol_match" ]
 667                 then
 668                         POS_result 1 \
 669                             "Group $ppv_group should have protocol $ppv_remembered_protocol set but 'show -p' doesn't show it"
 670                         ppv_retval=1
 671                 fi
 672         done
 673 
 674         return $ppv_retval
 675 }
 676 
 677 #
 678 # NAME
 679 #       create
 680 #
 681 # SYNOPSIS
 682 #       create [POS or NEG] <group> [options for 'sharemgr create' command]
 683 #
 684 # DESCRIPTION
 685 #       Execute 'sharemgr create' command and verify if the group was created
 686 #       and has the expected options.
 687 #
 688 # RETURN VALUE
 689 #       This function passes on the return value of the 'sharemgr create'
 690 #       command.  So, even if called with 'NEG', a failure by the command
 691 #       will result in non-zero status being returned.
 692 #
 693 function create {
 694         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
 695         then
 696                 CUR_RESULT=`get_tet_result`
 697                 if [ "$CUR_RESULT" != "PASS" ]
 698                 then
 699                         tet_infoline "The current state of the test case is"
 700                         tet_infoline "not PASS. Skipping the create subcommand."
 701                         tet_infoline "This can be overridden by setting the"
 702                         tet_infoline "environment variable"
 703                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
 704                         return
 705                 fi
 706         elif [ "$1" = "NO_RESULT_CHK" ]
 707         then
 708                 shift
 709         fi
 710 
 711         cmdlvl=0
 712         unset c_negtext
 713 
 714         if [ "$1" = "NEG" ]
 715         then
 716                 c_pos_neg=$1
 717                 shift
 718         else
 719                 c_pos_neg="POS"
 720                 if [ "$1" = "POS" ]
 721                 then
 722                         shift
 723                 fi
 724         fi
 725 
 726         c_group="$1"
 727         shift
 728         c_options="$*"
 729 
 730         # Parse options
 731         unset c_opt_n
 732         quasi_getopt c $c_options
 733 
 734         #
 735         # Determine if the info message for this command should indicate
 736         # that it is a dry run.
 737         #
 738         unset c_dr_text
 739         if [ "$c_opt_n" ]
 740         then
 741                 c_dr_text=" Dry run:"
 742         fi
 743 
 744         tet_infoline "*${c_dr_text} Create share group ($c_group) - $c_pos_neg"
 745 
 746         # Build the create command.
 747         c_cmd="${cmd_prefix}${SHAREMGR} create $c_options $c_group"
 748 
 749         logfile=`get_logfile create ${c_options}`
 750         # Execute the create command
 751         tet_infoline "  - $c_cmd"
 752         if [ "$report_only" != "TRUE" ]
 753         then
 754                 clean_logs
 755                 eval $c_cmd${cmd_postfix} > $logfile 2>&1
 756                 c_retval=$?
 757         fi
 758 
 759         # Append command to list of commands executed by this test case.
 760         append_cmd $c_cmd${cmd_postfix}
 761 
 762         if [ "$report_only" = "TRUE" ]
 763         then
 764                 return
 765         fi
 766 
 767         if [ "$verbose" = "TRUE" ]
 768         then
 769                 tet_infoline "Return code is $c_retval"
 770         fi
 771 
 772         #
 773         # Update variables used to remember configuration settings if the
 774         # create command succeeded and this is not a dry run.
 775         #
 776         if [ $c_retval -eq 0 -a ! "$c_opt_n" ]
 777         then
 778                 #
 779                 # Just in case we are adding multiple groups
 780                 #
 781                 for cgroup in ${c_group}
 782                 do
 783                         fnd=0
 784                         for group in $GROUPS
 785                         do
 786                                 if [ "$c_group" = "$group" ]
 787                                 then
 788                                         fnd=1
 789                                         break;
 790                                 fi
 791                         done
 792                         if [ $fnd -eq 0 ]
 793                         then
 794                                 GROUPS="$GROUPS $c_group"
 795                         fi
 796                         #
 797                         # Only update the various variables used to keep track
 798                         # of information related to this share group if the
 799                         # create operation was expected to pass.  If the
 800                         # create command was expected to fail, we may have
 801                         # been passed an invalid group name (e.g. contains
 802                         # reserved characters) that will cause the shell
 803                         # variable names (which incorporate the group name)
 804                         # to be invalid and cause the shell to exit abnormally.
 805                         #
 806                         if [ "$c_pos_neg" = "POS" ]
 807                         then
 808                                 eval unset SHARES_${cgroup}
 809                                 remember_protocol_settings $c_group create \
 810                                     $c_options
 811                         fi
 812                 done
 813         fi
 814 
 815         if [ "$c_pos_neg" = "POS" ]
 816         then
 817                 POS_result $c_retval "$c_cmd"
 818                 #
 819                 # Verify configuration changes if the command succeeded and
 820                 # this is not a dry run.
 821                 #
 822                 if [ $c_retval -eq 0 -a ! "$c_opt_n" ]
 823                 then
 824                         #
 825                         # o Verify group '$c_group' is shown in " \
 826                         #    "list output."
 827                         #
 828                         list -v
 829                         logfile=`get_logfile list -v`
 830                         $GREP $c_group $logfile > /dev/null 2>&1
 831                         c_result=$?
 832                         if [ $c_pos_neg = "NEG" ]
 833                         then
 834                                 NEG_result $c_result \
 835                                     "$c_group found in list" \
 836                                     "$c_group not found in list"
 837                         else
 838                                 POS_result $c_result \
 839                                     "$c_group not found in list" \
 840                                     "$c_group found in list"
 841                         fi
 842 
 843                         eval EXP_STATE_${c_group}=\"enabled\"
 844                         verify_group_state $c_group
 845                         protocol_property_verification $c_group
 846                 fi
 847         else
 848                 NEG_result $c_retval "$c_cmd" "$c_cmd"
 849         fi
 850 
 851         return $c_retval
 852 }
 853 
 854 
 855 #
 856 # NAME
 857 #       delete
 858 #
 859 # SYNOPSIS
 860 #       delete [POS or NEG] <group> [options for 'sharemgr delete' command]
 861 #
 862 # DESCRIPTION
 863 #       Execute 'sharemgr delete' command and verify that the group was
 864 #       deleted.
 865 #
 866 # RETURN VALUE
 867 #       This function passes on the return value of the 'sharemgr delete'
 868 #       command.  So, even if called with 'NEG', a failure by the command
 869 #       will result in non-zero status being returned.
 870 #
 871 function delete {
 872         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
 873         then
 874                 CUR_RESULT=`get_tet_result`
 875                 if [ "$CUR_RESULT" != "PASS" ]
 876                 then
 877                         tet_infoline "The current state of the test case is"
 878                         tet_infoline "not PASS. Skipping the delete subcommand."
 879                         tet_infoline "This can be overridden by setting the"
 880                         tet_infoline "environment variable"
 881                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
 882                         return
 883                 fi
 884         elif [ "$1" = "NO_RESULT_CHK" ]
 885         then
 886                 shift
 887         fi
 888 
 889         cmdlvl=0
 890         unset d_negtext
 891 
 892         if [ "$1" = "NEG" ]
 893         then
 894                 d_pos_neg=$1
 895                 d_negtext="- should fail"
 896                 shift
 897         else
 898                 d_pos_neg="POS"
 899                 if [ "$1" = "POS" ]
 900                 then
 901                         shift
 902                 fi
 903         fi
 904 
 905         #
 906         # If a protocol has been specified then the 'sharemgr delete' command
 907         # will just remove that protocol from the group.  If no protocol is
 908         # specified then the entire group will be deleted.
 909         #
 910         unset d_capture_protocol
 911         unset d_delete_protocol
 912         for d_arg in $*
 913         do
 914                 if [ "$d_capture_protocol" ]
 915                 then
 916                         d_delete_protocol="$d_arg"
 917                         break
 918                 elif [ "$d_arg" = "-P" ]
 919                 then
 920                         d_capture_protocol="yes"
 921                 fi
 922         done
 923 
 924         d_group="$1"
 925         shift
 926         d_options="$*"
 927 
 928         # Parse options
 929         unset d_opt_n
 930         quasi_getopt d $d_options
 931 
 932         #
 933         # Determine if the info message for this command should indicate
 934         # that it is a dry run.
 935         #
 936         unset d_dr_text
 937         if [ "$d_opt_n" ]
 938         then
 939                 d_dr_text=" Dry run:"
 940         fi
 941 
 942         d_valid_group=`valid_group $d_group`
 943 
 944         tet_infoline "*${d_dr_text} Delete share group ($d_group) - $d_pos_neg"
 945 
 946         #
 947         # Clear out the 'expected state' and 'share list' for the group to
 948         # be deleted.  (NOTE:  These two lines had been commented out for
 949         # reasons not remembered; uncommented them as we should be clearing
 950         # out these values.)
 951         #
 952         eval unset EXP_STATE_${d_group}
 953         eval unset SHARES_${d_group}
 954 
 955         logfile=`get_logfile delete ${d_options}`
 956         # Build and execute the 'sharemgr delete' command.
 957         d_cmd="${cmd_prefix}${SHAREMGR} delete $d_options $d_group"
 958         tet_infoline "  - $d_cmd"
 959         if [ "$report_only" != "TRUE" ]
 960         then
 961                 clean_logs
 962                 eval $d_cmd${cmd_postfix} > $logfile 2>&1
 963                 d_retval=$?
 964         fi
 965 
 966         # Append command to list of commands executed by this test case.
 967         append_cmd $d_cmd${cmd_postfix}
 968 
 969         if [ $d_pos_neg = "POS" ]
 970         then
 971                 POS_result $d_retval "$d_cmd"
 972         else
 973                 NEG_result $d_retval "$d_cmd"
 974         fi
 975 
 976         #
 977         # If the delete command succeeded, clear the remembered protocol &
 978         # properties associated with the group and then delete the group
 979         # from the GROUPS list.  Skip if this was a dry run.
 980         #
 981         if [ $d_retval -eq 0 -a ! "$d_opt_n" ]
 982         then
 983                 if [ "$d_delete_protocol" ]
 984                 then
 985                         #
 986                         # Protocol $d_delete_protocol has been deleted from
 987                         # the group but the group should still exist.  Remove
 988                         # $d_delete_protocol from the list of protocols we
 989                         # expect for this group.
 990                         #
 991                         eval d_tmp1=\"\$PROTOCOLS_${d_group}\"
 992                         eval unset PROTOCOLS_${d_group}
 993                         for d_protocol in $d_tmp1
 994                         do
 995                                 if [ "$d_protocol" != "$d_delete_protocol" ]
 996                                 then
 997                                         eval PROTOCOLS_${d_group}=\"\$PROTOCOLS_${d_group} $d_protocol\"
 998                                 fi
 999                         done
1000                         clear_remembered_info $d_group protocol properties
1001                         #
1002                         # Verify that the group is still there (pass NEG
1003                         # argument as, while the command succeeded, we don't
1004                         # expect the group to have been deleted).
1005                         #
1006                         verify_group_delete NEG $d_group
1007                 else
1008                         #
1009                         # The group has been deleted.   Clear out the 'expected
1010                         # state' and 'share list' for the group to be deleted.
1011                         eval unset EXP_STATE_${d_group}
1012                         eval unset SHARES_${d_group}
1013                         clear_remembered_info $d_group protocol properties
1014                         remove_group_from_list $d_group
1015 
1016                         #
1017                         # Verify '$d_group' is not shown in 'list' output
1018                         #       or (dependent on d_pos_neg)
1019                         # Verify $d_group is still shown in 'list' output
1020                         #
1021                         verify_group_delete $d_pos_neg $d_group
1022                 fi
1023         fi
1024 
1025         return $d_retval
1026 }
1027 
1028 #
1029 # NAME
1030 #       disable
1031 #
1032 # DESCRIPTION
1033 #       Execute 'sharemgr disable' command and verify that the specified
1034 #       group(s) have indeed been disabled.
1035 #
1036 # RETURN VALUE
1037 #       This function passes on the return value of the 'sharemgr disable'
1038 #       command.  So, even if called with 'NEG', a failure by the command
1039 #       will result in non-zero status being returned.
1040 #
1041 function disable {
1042         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
1043         then
1044                 CUR_RESULT=`get_tet_result`
1045                 if [ "$CUR_RESULT" != "PASS" ]
1046                 then
1047                         tet_infoline "The current state of the test case is"
1048                         tet_infoline "not PASS. Skipping the disable subcommand."
1049                         tet_infoline "This can be overridden by setting the"
1050                         tet_infoline "environment variable"
1051                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
1052                         return
1053                 fi
1054         elif [ "$1" = "NO_RESULT_CHK" ]
1055         then
1056                 shift
1057         fi
1058 
1059         cmdlvl=0
1060 
1061         if [ "$1" = "NEG" ]
1062         then
1063                 dis_pos_neg=$1
1064                 shift
1065         else
1066                 dis_pos_neg="POS"
1067                 if [ "$1" = "POS" ]
1068                 then
1069                         shift
1070                 fi
1071         fi
1072 
1073         dis_options="$1"
1074         shift
1075         dis_groups="$*"         # Group(s) to be disabled.
1076 
1077         # Parse options
1078         unset dis_opt_n
1079         quasi_getopt dis $dis_options
1080 
1081         #
1082         # Determine if the info message for this command should indicate
1083         # that it is a dry run.
1084         #
1085         unset dis_dr_text
1086         if [ "$dis_opt_n" ]
1087         then
1088                 dis_dr_text=" Dry run:"
1089         fi
1090 
1091         tet_infoline "*$dis_dr_text Disable share group(s) ($dis_groups) - $dis_pos_neg"
1092 
1093         logfile=`get_logfile disable ${dis_options}`
1094         # Build and execute disable command
1095         dis_cmd="${cmd_prefix} ${SHAREMGR} disable $dis_options $dis_groups"
1096         tet_infoline "  - $dis_cmd"
1097         if [ "$report_only" != "TRUE" ]
1098         then
1099                 clean_logs
1100                 eval $dis_cmd${cmd_postfix} > $logfile 2>&1
1101                 dis_result=$?
1102         fi
1103 
1104         # Append command to list of commands executed by this test case.
1105         append_cmd $dis_cmd${cmd_postfix}
1106 
1107         if [ "$dis_pos_neg" = "POS" ]
1108         then
1109                 # o Verify return code is 0"
1110                 POS_result $dis_result "$dis_cmd"
1111 
1112                 # Update the state information we keep for this group if this
1113                 # is not a dry run.
1114                 if [ ! "$dis_opt_n" ]
1115                 then
1116                         for dis_group in $dis_groups
1117                         do
1118                                 eval EXP_STATE_$dis_group=\"disabled\"
1119                         done
1120                 fi
1121         else
1122                 # Verify return code != 0"
1123                 NEG_result $dis_result "$dis_cmd"
1124                 #
1125                 # Need to reverse the pos_neg for the verification bit.
1126                 #
1127                 dis_pos_neg=POS;
1128         fi
1129 
1130         if [ "$dis_groups" -a ! "$dis_opt_n" ]
1131         then
1132                 verify_groups $dis_pos_neg $dis_groups
1133         fi
1134 
1135         return $dis_result
1136 }
1137 
1138 
1139 #
1140 # NAME
1141 #       enable
1142 #
1143 # DESCRIPTION
1144 #       Execute 'sharemgr enable' command and verify that the specified
1145 #       group(s) have indeed been enabled.
1146 #
1147 # RETURN VALUE
1148 #       This function passes on the return value of the 'sharemgr enable'
1149 #       command.  So, even if called with 'NEG', a failure by the command
1150 #       will result in non-zero status being returned.
1151 #
1152 function enable {
1153         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
1154         then
1155                 CUR_RESULT=`get_tet_result`
1156                 if [ "$CUR_RESULT" != "PASS" ]
1157                 then
1158                         tet_infoline "The current state of the test case is"
1159                         tet_infoline "not PASS. Skipping the enable subcommand."
1160                         tet_infoline "This can be overridden by setting the"
1161                         tet_infoline "environment variable"
1162                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
1163                         return
1164                 fi
1165         elif [ "$1" = "NO_RESULT_CHK" ]
1166         then
1167                 shift
1168         fi
1169 
1170         unset en_all
1171         cmdlvl=0
1172 
1173         if [ "$1" = "NEG" ]
1174         then
1175                 en_pos_neg=$1
1176                 shift
1177         else
1178                 en_pos_neg="POS"
1179                 if [ "$1" = "POS" ]
1180                 then
1181                         shift
1182                 fi
1183         fi
1184 
1185         en_options="$1"
1186         shift
1187         en_groups="$*"  # Group(s) to enable.  May include non-existent group(s)
1188                         # for negative tests.
1189 
1190         # Parse options
1191         unset en_opt_n
1192         quasi_getopt en $en_options
1193 
1194         #
1195         # Determine if the info message for this command should indicate
1196         # that it is a dry run.
1197         #
1198         unset en_dr_text
1199         if [ "$en_opt_n" ]
1200         then
1201                 en_dr_text=" Dry run:"
1202         fi
1203 
1204         tet_infoline "*$en_dr_text Enable share groups ($en_groups) - $en_pos_neg"
1205 
1206         logfile=`get_logfile enable`
1207         # Build and execute command.
1208         en_cmd="${cmd_prefix}${SHAREMGR} enable $en_options $en_groups"
1209         tet_infoline "  - $en_cmd"
1210         if [ "$report_only" != "TRUE" ]
1211         then
1212                 clean_logs
1213                 eval $en_cmd${cmd_postfix} > $logfile 2>&1
1214                 en_result=$?
1215         fi
1216 
1217         # Append command to list of commands executed by this test case.
1218         append_cmd $en_cmd${cmd_postfix}
1219 
1220         if [ "$en_pos_neg" = "POS" ]
1221         then
1222                 #
1223                 # For a positive test case we expect zero exit status and for
1224                 # the state of each group to be set to 'enabled'.
1225                 # Verify return code is 0"
1226                 #
1227                 POS_result $en_result "$en_cmd"
1228                 if [ ! "$en_opt_n" ]
1229                 then
1230                         for en_group in $en_groups
1231                         do
1232                                 eval EXP_STATE_$en_group=\"enabled\"
1233                         done
1234                 fi
1235         else
1236                 #
1237                 # For a negative test case we expect non-zero exit status and
1238                 # for the state of the group(s) to be unchanged.
1239                 # Verify return code != 0"
1240                 #
1241                 NEG_result $en_result "$en_cmd"
1242                 #
1243                 # Need to reverse the positive/negative for the verify groups.
1244                 #
1245                 en_pos_neg=POS
1246         fi
1247 
1248         #
1249         # Verify the state of each group following the enable command.
1250         #
1251         if [ "$en_groups" -a ! "$en_opt_n" ]
1252         then
1253                 verify_groups $en_pos_neg $en_groups
1254         fi
1255 
1256         return $en_result
1257 }
1258 
1259 #
1260 # NAME
1261 #       quasi_getopt
1262 #
1263 # SYNOPSIS
1264 #       quasi_getopt prefix arg arg arg...
1265 #
1266 # DESCRIPTION
1267 #       A quasi-getopts function to handle cases where multiple arguments to
1268 #       a command are passed together in one variable.  For example, arguments
1269 #       to 'sharemgr add' could contain:
1270 #               -r "resource_name" -d "description text" -t
1271 #       passed together in one shell variable with the quotes intact.  When
1272 #       parsing an options list like this, you'd expect to get:
1273 #               -r
1274 #               resource_name
1275 #               -d
1276 #               description text
1277 #               -t
1278 #       but when the multiple arguments are passed together in one shell
1279 #       variable, the shell will parse the line like:
1280 #               -r
1281 #               "resource_name"
1282 #               -d
1283 #               "description
1284 #               text"
1285 #               -t
1286 #       This function is used to parse like the first example, whereas built-in
1287 #       shell functions will do the second.  When passed a set of arguments it
1288 #       will set variables as follows:
1289 #               -x              Set <prefix>_opt_x to a white space (' ')
1290 #               -x <value>        Set <prefix>_opt_x to <value>
1291 #       The calling function can then determine what options/values were
1292 #       invoked by checking the <prefix>_opt_<option> variable for each
1293 #       option.  If the variable is not set then that option was not
1294 #       invoked.  If the variable is set to a single white space then the
1295 #       option was invoked with no following argument.  If the variable is
1296 #       set to anything other than a single white space, then the option
1297 #       was invoked with the argument listed in the <prefix>_opt_<option>
1298 #       variable.
1299 #
1300 #       Be aware that this function eliminates any double quotes it finds
1301 #       in arguments.
1302 #
1303 function quasi_getopt {
1304         qg_prefix=$1    # Prefix for variable names to be used
1305         shift
1306 
1307         unset qg_opt
1308 
1309         #
1310         # Step through each argument
1311         #
1312         for qg_arg in $*
1313         do
1314                 if echo $qg_arg | grep "^-" >/dev/null 2>&1
1315                 then
1316                         # Remove the '-' to get single-character argument
1317                         qg_opt="`echo $qg_arg | sed 's/^-//' `"
1318                         # Initially, set the variable associated with the
1319                         # current option to ' ' so that the calling function
1320                         # can tell that the option was invoked.
1321                         eval ${qg_prefix}_opt_${qg_opt}=\" \"
1322                 elif [ "$qg_opt" ]
1323                 then
1324                         #
1325                         # The current argument is not a switch (doesn't start
1326                         # with '-') so append the arg to the value that we're
1327                         # building for the current option after stripping any
1328                         # double quotes out.
1329                         #
1330                         qg_tmp=`echo $qg_arg | sed 's/"//g' ` # Strip any quotes
1331                         eval qg_tmp2=\"\$${qg_prefix}_opt_${qg_opt}\"
1332                         if [ "$qg_tmp2" = " " ]
1333                         then
1334                                 eval ${qg_prefix}_opt_${qg_opt}=\"$qg_tmp\"
1335                         else
1336                                 eval ${qg_prefix}_opt_${qg_opt}=\"\$qg_tmp2 $qg_tmp\"
1337                         fi
1338                 fi
1339         done
1340 }
1341 
1342 #
1343 # NAME
1344 #       add_share
1345 #
1346 # SYNOPSIS
1347 #       add_share [POS or NEG] <group> <options> <shares>
1348 #
1349 # DESCRIPTION
1350 #       Execute 'sharemgr add-share' command and verify that the share(s)
1351 #       were added to the expected group.
1352 #
1353 # RETURN VALUE
1354 #       This function passes on the return value of the 'sharemgr add-share'
1355 #       command.  So, even if called with 'NEG', a failure by the command
1356 #       will result in non-zero status being returned.
1357 #
1358 function add_share {
1359         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
1360         then
1361                 CUR_RESULT=`get_tet_result`
1362                 if [ "$CUR_RESULT" != "PASS" ]
1363                 then
1364                         tet_infoline "The current state of the test case is"
1365                         tet_infoline "not PASS. Skipping the add subcommand."
1366                         tet_infoline "This can be overridden by setting the"
1367                         tet_infoline "environment variable"
1368                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
1369                         return
1370                 fi
1371         elif [ "$1" = "NO_RESULT_CHK" ]
1372         then
1373                 shift
1374         fi
1375 
1376         cmdlvl=0
1377         as_result=0
1378 
1379         if [ "$1" = "NEG" ]
1380         then
1381                 as_pos_neg=$1
1382                 shift
1383         else
1384                 as_pos_neg="POS"
1385                 if [ "$1" = "POS" ]
1386                 then
1387                         shift
1388                 fi
1389         fi
1390 
1391         as_group=$1
1392         as_options="$2"
1393         shift 2
1394         as_shares="$*"
1395 
1396         #
1397         # If the default protocol is smb then need
1398         # to add a dummy resource name to the options
1399         # as this is required with the smb protocol.
1400         #
1401         if [[ -n "$as_group" && $as_options != *-r* ]]
1402         then
1403                 eval as_protocols=\"\$PROTOCOLS_$as_group\"
1404                 if [[ $as_protocols == *smb* ]]
1405                 then
1406                         as_rname=${as_shares##/*/}
1407                         eval as_options=\"$as_options -r res_name_$as_rname\"
1408                 fi
1409         fi
1410 
1411         # Parse options
1412         unset as_opt_d as_opt_n as_opt_r as_opt_t
1413         quasi_getopt as $as_options
1414 
1415         #
1416         # Determine if the info message for this command should indicate
1417         # that it is a dry run.
1418         #
1419         unset as_dr_text
1420         if [ "$as_opt_n" ]
1421         then
1422                 as_dr_text=" Dry run:"
1423         fi
1424 
1425         tet_infoline "* -$as_dr_text Add share(s) ($as_shares) to group " \
1426             "($as_group) - $as_pos_neg"
1427 
1428         logfile=`get_logfile add-share ${as_options}`
1429         # Build and execute command
1430         as_partial_cmd=""
1431         for as_share in $as_shares
1432         do
1433                 as_partial_cmd="$as_partial_cmd -s $as_share"
1434         done
1435         as_cmd="${cmd_prefix}${SHAREMGR} add-share $as_options $as_partial_cmd $as_group"
1436         tet_infoline "  - $as_cmd"
1437         if [ "$report_only" != "TRUE" ]
1438         then
1439                 clean_logs
1440                 eval $as_cmd${cmd_postfix} > $logfile 2>&1
1441                 as_result=$?
1442         fi
1443 
1444         # Append command to list of commands executed by this test case.
1445         append_cmd $as_cmd${cmd_postfix}
1446 
1447         # Verify results of command.
1448         if [ "$as_pos_neg" = "POS" ]
1449         then
1450                 POS_result $as_result "$as_cmd"
1451                 #
1452                 # If the 'add-share' command succeeded, and this is not a dry
1453                 # run, save information about the share we just added for
1454                 # later reference.
1455                 #
1456                 if [ $? -eq 0 -a ! "$as_opt_n" ]
1457                 then
1458                         #
1459                         # If the shares are temporary, append "|tmp" to each
1460                         # share name so that we can distinguish them from
1461                         # permanent shares.
1462                         #
1463                         if [ "$as_opt_t" ]
1464                         then
1465                                 unset as_shares_tmp
1466                                 for as_share in $as_shares
1467                                 do
1468                                         as_shares_tmp="$as_shares_tmp ${as_share}|tmp"
1469                                 done
1470                                 as_shares="$as_shares_tmp"
1471                         fi
1472 
1473                         #
1474                         # Add the share(s) to the list of active shares for the
1475                         # group.
1476                         #
1477                         eval SHARES_${as_group}=\"\$SHARES_${as_group} $as_shares\"
1478 
1479                         # If the '-d' flag was given, remember the description.
1480                         if [ "$as_opt_d" ]
1481                         then
1482                                 for as_share in $as_shares
1483                                 do
1484                                         as_share_mod="`echo $as_share | \
1485                                             sed -e 's/\//__/g' -e 's/|//g'`"
1486                                         if [ "$as_opt_d" = " " ]
1487                                         then
1488                                                 eval unset DESC_${as_share_mod}
1489                                         else
1490                                                 eval DESC_${as_share_mod}=\"$as_opt_d\"
1491                                         fi
1492                                 done
1493                         fi
1494 
1495                         # If the '-r' flag was given, remember the resource
1496                         # name.
1497                         if [ "$as_opt_r" ]
1498                         then
1499                                 for as_share in $as_shares
1500                                 do
1501                                         as_share_mod="`echo $as_share | \
1502                                             sed -e 's/\//__/g' -e 's/|//g'`"
1503                                         if [ "$as_opt_r" = " " ]
1504                                         then
1505                                                 eval unset RSRC_${as_share_mod}
1506                                         else
1507                                                 eval RSRC_${as_share_mod}=\"$as_opt_r\"
1508                                         fi
1509                                 done
1510                         fi
1511                 fi
1512         else
1513                 NEG_result $as_result "$as_cmd"
1514         fi
1515 
1516         #
1517         # If this was not a dry run, verify that the share has been
1518         # added through 'sharemgr' and legacy methods (if appropriate).
1519         #
1520         if [ ! "$as_opt_n" ]
1521         then
1522                 if [ $as_group ]
1523                 then
1524                         verify_share -g $as_group $as_pos_neg $as_shares
1525                         legacy_share_confirm $as_group
1526                 else
1527                         verify_share $as_pos_neg $as_shares
1528                 fi
1529         fi
1530 
1531         return $as_result
1532 }
1533 
1534 
1535 #
1536 # NAME
1537 #       set_share
1538 #
1539 # DESCRIPTION
1540 #       Execute 'sharemgr set-share' command and verify that the share(s)
1541 #       options were set as expected.
1542 #
1543 # RETURN VALUE
1544 #       This function passes on the return value of the 'sharemgr set-share'
1545 #       command.  So, even if called with 'NEG', a failure by the command
1546 #       will result in non-zero status being returned.
1547 #
1548 function set_share {
1549         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
1550         then
1551                 CUR_RESULT=`get_tet_result`
1552                 if [ "$CUR_RESULT" != "PASS" ]
1553                 then
1554                         tet_infoline "The current state of the test case is"
1555                         tet_infoline "not PASS. Skipping the set subcommand."
1556                         tet_infoline "This can be overridden by setting the"
1557                         tet_infoline "environment variable"
1558                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
1559                         return
1560                 fi
1561         elif [ "$1" = "NO_RESULT_CHK" ]
1562         then
1563                 shift
1564         fi
1565 
1566         cmdlvl=0
1567 
1568         if [ "$1" = "NEG" ]
1569         then
1570                 ss_pos_neg=$1
1571                 shift
1572         else
1573                 ss_pos_neg="POS"
1574                 if [ "$1" = "POS" ]
1575                 then
1576                         shift
1577                 fi
1578         fi
1579 
1580         ss_share="$1"
1581         shift
1582         ss_options="$*"
1583 
1584         # Parse options
1585         unset ss_opt_d ss_opt_r ss_opt_n
1586         quasi_getopt ss $ss_options
1587 
1588         #
1589         # Determine if the info message for this command should indicate
1590         # that it is a dry run.
1591         #
1592         unset ss_dr_text
1593         if [ "$ss_opt_n" ]
1594         then
1595                 ss_dr_text=" Dry run:"
1596         fi
1597 
1598         ss_group=`which_group $ss_share`
1599 
1600         tet_infoline "*$ss_dr_text Set options for share ($ss_share) - " \
1601             "$ss_pos_neg"
1602 
1603         logfile=`get_logfile set-share ${ss_options}`
1604         # Build and execute command
1605         ss_cmd="${cmd_prefix}${SHAREMGR} set-share $ss_options -s $ss_share $ss_group"
1606         tet_infoline "  - $ss_cmd"
1607         if [ "$report_only" != "TRUE" ]
1608         then
1609                 clean_logs
1610                 eval $ss_cmd${cmd_postfix} > $logfile 2>&1
1611                 ss_retval=$?
1612         fi
1613 
1614         # Append command to list of commands executed by this test case.
1615         append_cmd $ss_cmd${cmd_postfix}
1616 
1617         # Verify return code is 0"
1618         if [ "$ss_pos_neg" = "POS" ]
1619         then
1620                 POS_result $ss_retval "$ss_cmd"
1621         else
1622                 NEG_result $ss_retval "$ss_cmd"
1623         fi
1624 
1625         #
1626         # If the command was successful, and this is not a dry run, update
1627         # the test's copy of the description and/or resource name as
1628         # appropriate.
1629         #
1630         if [ $ss_retval = 0 -a ! "$s_opt_n" ]
1631         then
1632                 ss_share_mod="`echo $ss_share | sed 's/\//__/g'`"
1633                 if [ "$ss_opt_d" ]
1634                 then
1635                         if [ "$ss_opt_d" = " " ]
1636                         then
1637                                 eval unset DESC_${ss_share_mod}
1638                         else
1639                                 eval DESC_${ss_share_mod}=\"$ss_opt_d\"
1640                         fi
1641                 fi
1642 
1643                 if [ "$ss_opt_r" ]
1644                 then
1645                         if [ "$ss_opt_r" = " " ]
1646                         then
1647                                 eval unset RSRC_${ss_share_mod}
1648                         else
1649                                 eval RSRC_${ss_share_mod}=\"$ss_opt_d\"
1650                         fi
1651                 fi
1652         fi
1653         verify_share $ss_pos_neg $ss_share
1654 
1655         return $ss_retval
1656 }
1657 
1658 #
1659 # NAME
1660 #       set_security
1661 #
1662 # DESCRIPTION
1663 #       Execute 'sharemgr set' command and verify that the share(s)
1664 #       options were set as expected.
1665 #
1666 # RETURN VALUE
1667 #       This function passes on the return value of the 'sharemgr set'
1668 #       command.  So, even if called with 'NEG', a failure by the command
1669 #       will result in non-zero status being returned.
1670 function set_security {
1671         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
1672         then
1673                 CUR_RESULT=`get_tet_result`
1674                 if [ "$CUR_RESULT" != "PASS" ]
1675                 then
1676                         tet_infoline "The current state of the test case is"
1677                         tet_infoline "not PASS. Skipping the set security"
1678                         tet_infoline "subcommand."
1679                         tet_infoline "This can be overridden by setting the"
1680                         tet_infoline "environment variable"
1681                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
1682                         return
1683                 fi
1684         elif [ "$1" = "NO_RESULT_CHK" ]
1685         then
1686                 shift
1687         fi
1688 
1689         cmdlvl=0
1690 
1691         if [ "$1" = "NEG" ]
1692         then
1693                 ssec_pos_neg=$1
1694                 shift
1695         else
1696                 ssec_pos_neg="POS"
1697                 if [ "$1" = "POS" ]
1698                 then
1699                         shift
1700                 fi
1701         fi
1702 
1703         ssec_group="$1"
1704         shift
1705         ssec_options="$*"
1706 
1707         # Parse options
1708         unset ssec_opt_n
1709         quasi_getopt ssec $ssec_options
1710 
1711         #
1712         # Determine if the info message for this command should indicate
1713         # that it is a dry run.
1714         #
1715         unset ssec_dr_text
1716         if [ "$ssec_opt_n" ]
1717         then
1718                 ssec_dr_text=" Dry run:"
1719         fi
1720 
1721         tet_infoline "*$ssec_dr_text Set security options for group " \
1722             "($ssec_group) $ssec_pos_neg"
1723 
1724         logfile=`get_logfile set_security ${ssec_options}`
1725         # Build and execute command
1726         ssec_cmd="${cmd_prefix}${SHAREMGR} set-security $ssec_options $ssec_group"
1727         tet_infoline "  - $ssec_cmd"
1728         if [ "$report_only" != "TRUE" ]
1729         then
1730                 clean_logs
1731                 eval $ssec_cmd${cmd_postfix} > $logfile 2>&1
1732                 ssec_retval=$?
1733         fi
1734 
1735         # Append command to list of commands executed by this test case.
1736         append_cmd $ssec_cmd${cmd_postfix}
1737 
1738         #
1739         # Remember the changes we just made if the command succeeded and
1740         # we're not doing a dry run.
1741         #
1742         if [ $ssec_retval -eq 0 -a ! "$ssec_opt_n" ]
1743         then
1744                 remember_protocol_settings $ssec_group set-security $ssec_options
1745         fi
1746 
1747         # o Verify return code is 0"
1748         if [ "$ssec_pos_neg" = "POS" ]
1749         then
1750                 POS_result $ssec_retval "$s_cmd"
1751                 protocol_property_verification $ssec_group
1752         else
1753                 NEG_result $ssec_retval "$ssec_cmd"
1754         fi
1755 
1756         return $ssec_retval
1757 }
1758 
1759 #
1760 # NAME
1761 #       set_
1762 #
1763 # DESCRIPTION
1764 #       Execute 'sharemgr set' command and verify that the share(s)
1765 #       options were set as expected.
1766 #
1767 # RETURN VALUE
1768 #       This function passes on the return value of the 'sharemgr set'
1769 #       command.  So, even if called with 'NEG', a failure by the command
1770 #       will result in non-zero status being returned.
1771 function set_ {
1772         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
1773         then
1774                 CUR_RESULT=`get_tet_result`
1775                 if [ "$CUR_RESULT" != "PASS" ]
1776                 then
1777                         tet_infoline "The current state of the test case is"
1778                         tet_infoline "not PASS. Skipping the set subcommand."
1779                         tet_infoline "This can be overridden by setting the"
1780                         tet_infoline "environment variable"
1781                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
1782                         return
1783                 fi
1784         elif [ "$1" = "NO_RESULT_CHK" ]
1785         then
1786                 shift
1787         fi
1788 
1789         cmdlvl=0
1790 
1791         if [ "$1" = "NEG" ]
1792         then
1793                 s_pos_neg=$1
1794                 shift
1795         else
1796                 s_pos_neg="POS"
1797                 if [ "$1" = "POS" ]
1798                 then
1799                         shift
1800                 fi
1801         fi
1802 
1803         s_group="$1"
1804         shift
1805         s_options="$*"
1806 
1807         # Parse options
1808         unset s_opt_n
1809         quasi_getopt s $s_options
1810 
1811         #
1812         # Determine if the info message for this command should indicate
1813         # that it is a dry run.
1814         #
1815         unset s_dr_text
1816         if [ "$s_opt_n" ]
1817         then
1818                 s_dr_text=" Dry run:"
1819         fi
1820 
1821         tet_infoline "*$s_dr_text Set options for group ($s_group) - $s_pos_neg"
1822 
1823         logfile=`get_logfile set ${s_options}`
1824         # Build and execute command
1825         s_cmd="${cmd_prefix}${SHAREMGR} set $s_options $s_group"
1826         tet_infoline "  - $s_cmd"
1827         if [ "$report_only" != "TRUE" ]
1828         then
1829                 clean_logs
1830                 eval $s_cmd${cmd_postfix} > $logfile 2>&1
1831                 s_retval=$?
1832         fi
1833 
1834         # Append command to list of commands executed by this test case.
1835         append_cmd $s_cmd${cmd_postfix}
1836 
1837         # If the command succeeded, and this is not a dry run, update the
1838         # test's versions of the protocol settings.
1839         if [ $s_retval -eq 0 -a ! "$s_opt_n" ]
1840         then
1841                 remember_protocol_settings $s_group set $s_options
1842         fi
1843 
1844         # Verify return code is 0"
1845         if [ "$s_pos_neg" = "POS" ]
1846         then
1847                 POS_result $s_retval "$s_cmd"
1848                 protocol_property_verification $s_group
1849         else
1850                 NEG_result $s_retval "$s_cmd"
1851         fi
1852 
1853         return $set_retval
1854 }
1855 
1856 #
1857 # NAME
1858 #       unset
1859 #
1860 # DESCRIPTION
1861 #       Execute 'sharemgr unset' command and verify that the share(s)
1862 #       options were cleared as expected.
1863 #
1864 # RETURN VALUE
1865 #       This function passes on the return value of the 'sharemgr unset'
1866 #       command.  So, even if called with 'NEG', a failure by the command
1867 #       will result in non-zero status being returned.
1868 function unset_ {
1869         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
1870         then
1871                 CUR_RESULT=`get_tet_result`
1872                 if [ "$CUR_RESULT" != "PASS" ]
1873                 then
1874                         tet_infoline "The current state of the test case is"
1875                         tet_infoline "not PASS. Skipping the unset subcommand."
1876                         tet_infoline "This can be overridden by setting the"
1877                         tet_infoline "environment variable"
1878                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
1879                         return
1880                 fi
1881         elif [ "$1" = "NO_RESULT_CHK" ]
1882         then
1883                 shift
1884         fi
1885 
1886         cmdlvl=0
1887 
1888         if [ "$1" = "NEG" ]
1889         then
1890                 us_pos_neg=$1
1891                 shift
1892         else
1893                 us_pos_neg="POS"
1894                 if [ "$1" = "POS" ]
1895                 then
1896                         shift
1897                 fi
1898         fi
1899 
1900         us_group="$1"
1901         shift
1902         us_options="$*"
1903 
1904         # Parse options
1905         unset us_opt_n
1906         quasi_getopt us $us_options
1907 
1908         #
1909         # Determine if the info message for this command should indicate
1910         # that it is a dry run.
1911         #
1912         unset us_dr_text
1913         if [ "$us_opt_n" ]
1914         then
1915                 us_dr_text=" Dry run:"
1916         fi
1917 
1918         tet_infoline "*$us_dr_text Unset options for group ($us_group) - " \
1919             "$us_pos_neg"
1920 
1921         logfile=`get_logfile unset ${us_options}`
1922         # Build and execute command
1923         us_cmd="${cmd_prefix}${SHAREMGR} unset $us_options $us_group"
1924         tet_infoline "  - $us_cmd"
1925         if [ "$report_only" != "TRUE" ]
1926         then
1927                 clean_logs
1928                 eval $us_cmd${cmd_postfix} > $logfile 2>&1
1929                 us_retval=$?
1930         fi
1931 
1932         # Append command to list of commands executed by this test case.
1933         append_cmd $us_cmd${cmd_postfix}
1934 
1935         # If the command succeeded, and this was not a dry run, update our
1936         # remembered settings for this group
1937         if [ $us_retval -eq 0 -a ! "$us_opt_n" ]
1938         then
1939                 remember_protocol_settings $us_group unset $us_options
1940         fi
1941 
1942         # o Verify return code is 0"
1943         if [ "$us_pos_neg" = "POS" ]
1944         then
1945                 POS_result $us_retval "$us_cmd"
1946                 protocol_property_verification $us_group
1947         else
1948                 NEG_result $us_retval "$us_cmd"
1949         fi
1950 
1951         return $us_retval
1952 }
1953 
1954 #
1955 # NAME
1956 #       remove_share
1957 #
1958 # SYNOPSIS
1959 #       move_remove_share [POS or NEG] <options> <group> <list of shares>
1960 #
1961 # DESCRIPTION
1962 #       Wrapper for the move_remove_share function for the remove-share
1963 #       operation.
1964 #
1965 # RETURN VALUE
1966 #       This function passes on the return value of the 'sharemgr remove-share'
1967 #       command.  So, even if called with 'NEG', a failure by the command
1968 #       will result in non-zero status being returned.
1969 #
1970 function remove_share {
1971         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
1972         then
1973                 CUR_RESULT=`get_tet_result`
1974                 if [ "$CUR_RESULT" != "PASS" ]
1975                 then
1976                         tet_infoline "The current state of the test case is"
1977                         tet_infoline "not PASS. Skipping the remove subcommand."
1978                         tet_infoline "This can be overridden by setting the"
1979                         tet_infoline "environment variable"
1980                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
1981                         return
1982                 fi
1983         elif [ "$1" = "NO_RESULT_CHK" ]
1984         then
1985                 shift
1986         fi
1987 
1988         cmdlvl=0
1989 
1990         if [ "$1" = "NEG" ]
1991         then
1992                 rs_pos_neg="$1"
1993                 shift
1994         else
1995                 rs_pos_neg="POS"
1996                 if [ "$1" = "POS" ]
1997                 then
1998                         shift
1999                 fi
2000         fi
2001 
2002         rs_group_arg="$1"
2003         rs_options="$2"
2004         shift 2
2005         rs_shares="$*"
2006 
2007         move_remove_share $rs_pos_neg "remove-share" "$rs_options" \
2008             "$rs_group_arg" "$rs_shares"
2009         return $?
2010 }
2011 
2012 #
2013 # NAME
2014 #       move_share
2015 #
2016 # SYNOPSIS
2017 #       move_remove_share [POS or NEG] <group> <options> <list of shares>
2018 #
2019 # DESCRIPTION
2020 #       Wrapper for the move_remove_share function for the move-share operation.
2021 #
2022 # RETURN VALUE
2023 #       This function passes on the return value of the 'sharemgr move-share'
2024 #       command.  So, even if called with 'NEG', a failure by the command
2025 #       will result in non-zero status being returned.
2026 #
2027 function move_share {
2028         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
2029         then
2030                 CUR_RESULT=`get_tet_result`
2031                 if [ "$CUR_RESULT" != "PASS" ]
2032                 then
2033                         tet_infoline "The current state of the test case is"
2034                         tet_infoline "not PASS. Skipping the move subcommand."
2035                         tet_infoline "This can be overridden by setting the"
2036                         tet_infoline "environment variable"
2037                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
2038                         return
2039                 fi
2040         elif [ "$1" = "NO_RESULT_CHK" ]
2041         then
2042                 shift
2043         fi
2044 
2045         cmdlvl=0
2046 
2047         if [ "$1" = "NEG" ]
2048         then
2049                 ms_pos_neg="$1"
2050                 shift
2051         else
2052                 ms_pos_neg="POS"
2053                 if [ "$1" = "POS" ]
2054                 then
2055                         shift
2056                 fi
2057         fi
2058 
2059         ms_group_arg="$1"
2060         ms_options="$2"
2061         shift 2
2062         ms_shares="$*"
2063 
2064         # Parse options
2065         unset ms_opt_n
2066         quasi_getopt ms $ms_options
2067 
2068         #
2069         # Determine if the info message for this command should indicate
2070         # that it is a dry run.
2071         #
2072         unset ms_dr_text
2073         if [ "$ms_opt_n" ]
2074         then
2075                 ms_dr_text=" Dry run:"
2076         fi
2077 
2078         move_remove_share $ms_pos_neg "move-share" "$ms_options" \
2079             "$ms_group_arg" "$ms_shares"
2080         return $?
2081 }
2082 
2083 #
2084 # NAME
2085 #       move_remove_share
2086 #
2087 # SYNOPSIS
2088 #       move_remove_share [POS or NEG] <'move-share' or 'remove-share'> \
2089 #         <group> <options> <list of shares>
2090 #
2091 # DESCRIPTION
2092 #       Execute a 'move-share' or 'remove-share' sharemgr command
2093 #
2094 # RETURN VALUE
2095 #       This function passes on the return value of the 'sharemgr move'
2096 #       or 'sharemgr remove' command.  So, even if called with 'NEG', a
2097 #       failure by the command will result in non-zero status being returned.
2098 #
2099 function move_remove_share {
2100         if [ "$1" = "NEG" ]
2101         then
2102                 mrs_pos_neg="$1"
2103                 shift
2104         else
2105                 mrs_pos_neg="POS"
2106                 if [ "$1" = "POS" ]
2107                 then
2108                         shift
2109                 fi
2110         fi
2111 
2112         mrs_subcmd="$1"         # 'move-share' or 'remove-share'
2113         mrs_options="$2"        # Options for 'move-share' or 'remove-share'
2114         mrs_group_arg="$3"      # For 'move-share', the group to move the
2115                                 # shares to.  For 'remove-share', the group
2116                                 # to remove the shares from.
2117         shift 3
2118         mrs_shares="$*"         # List of shares to move.
2119                                 # unset mrs_ogroups
2120         unset mrs_agroups       # List of (real) groups affected by
2121                                 # the move.
2122 
2123         # Parse options
2124         unset mrs_opt_n
2125         quasi_getopt mrs $mrs_options
2126 
2127         #
2128         # Determine if the info message for this command should indicate
2129         # that it is a dry run.
2130         #
2131         unset mrs_dr_text
2132         if [ "$mrs_opt_n" ]
2133         then
2134                 mrs_dr_text=" Dry run:"
2135         fi
2136 
2137         if [ "$mrs_subcmd" = "move-share" ]
2138         then
2139                 tet_infoline "*$mrs_dr_text Move shares ($mrs_shares) to " \
2140                     "group ($mrs_group_arg) - $mrs_pos_neg"
2141         else
2142                 tet_infoline "*$mrs_dr_text Remove shares ($mrs_shares) from " \
2143                     "group ($mrs_group_arg) - $mrs_pos_neg"
2144         fi
2145 
2146         #
2147         # If one or more share names have been provided (might not be for
2148         # negative test cases) then set the shares argument we'll use on
2149         # the command line.  If not, clear the shares argument.
2150         #
2151         if [ "$mrs_shares" ]
2152         then
2153                 mrs_share_args="-s $mrs_shares"
2154         else
2155                 unset mrs_share_args
2156         fi
2157 
2158         logfile=`get_logfile $msr_subcmd`
2159         #
2160         # Build the command, execute it, and append it to the list of
2161         # commands executed by the current test case.
2162         #
2163         mrs_cmd="${cmd_prefix}${SHAREMGR} $mrs_subcmd $mrs_options $mrs_share_args $mrs_group_arg"
2164         tet_infoline "  - $mrs_cmd"
2165         if [ "$report_only" != "TRUE" ]
2166         then
2167                 clean_logs
2168                 eval $mrs_cmd${cmd_postfix} > $logfile 2>&1
2169                 mrs_retval=$?
2170         fi
2171         append_cmd $mrs_cmd${cmd_postfix}
2172 
2173         #
2174         # Expect different return codes depending on if this is a positive
2175         # or negative test case.
2176         #
2177         if [ "$mrs_pos_neg" = "POS" ]
2178         then
2179                 POS_result $mrs_retval "$mrs_cmd"
2180         else
2181                 NEG_result $mrs_retval "$mrs_cmd"
2182         fi
2183 
2184         if [ "$mrs_pos_neg" = "POS" -a ! "$mrs_opt_n" ]
2185         then
2186                 #
2187                 # For each share, remove them from the list corresponding to
2188                 # their 'old' group.  If this is a 'move' command rather than a
2189                 # 'remove' command, add them to the list for their 'new' group.
2190                 #
2191                 for mrs_share in $mrs_shares
2192                 do
2193                         if [ "$mrs_subcmd" = "remove-share" ]
2194                         then
2195                                 # Shares specified for a 'remove-share' command
2196                                 # will come from the group specified.
2197                                 if [ "$mrs_group_arg" ]
2198                                 then
2199                                         mrs_old_groups="$mrs_group_arg"
2200                                 else
2201                                         mrs_old_groups=`which_group $mrs_share`
2202                                         mrs_group_arg="$mrs_old_groups"
2203                                 fi
2204                         else
2205                                 # Shares specified for a 'move-share' command
2206                                 # come from any defined group.
2207                                 mrs_old_groups="$GROUPS"
2208                         fi
2209 
2210                         #
2211                         # Determine if the group name is valid (it might not be
2212                         # for a negative test case).  If so, add it to the list
2213                         # of groups affected by the command.
2214                         #
2215                         mrs_valid="`valid_group $mrs_group_arg`"
2216                         if [ "$mrs_valid" ]
2217                         then
2218                                 mrs_agroups="$mrs_group_arg"
2219                         fi
2220 
2221                         for mrs_old_group in $mrs_old_groups
2222                         do
2223                                 unset mrs_new_list
2224                                 unset mrs_match
2225 
2226                                 # XXX Can't wrap the following:
2227                                 eval mrs_old_group_shares=\"\$SHARES_${mrs_old_group}\"
2228                                 for mrs_old_group_share in \
2229                                     $mrs_old_group_shares
2230                                 do
2231                                         if [ "$mrs_share" = \
2232                                             "$mrs_old_group_share" ]
2233                                         then
2234                                                 mrs_match="$mrs_share"
2235                                         else
2236                                                 # XXX Can't wrap the following:
2237                                                 mrs_new_list="$mrs_new_list $mrs_old_group_share"
2238                                         fi
2239                                 done
2240 
2241                                 if [ "$mrs_match" ]
2242                                 then
2243                                         # This was the 'old' group the share
2244                                         # belonged to.
2245                                         # XXX Can't wrap the following:
2246                                         mrs_agroups="$mrs_agroups $mrs_old_group"
2247                                         if [ "$mrs_valid" ]
2248                                         then
2249                                                 #
2250                                                 # If the 'old' group is a valid
2251                                                 # group, update its list of
2252                                                 # shares.
2253                                                 # This line is over 80
2254                                                 # charaters in length, but
2255                                                 # splitting it causes eval
2256                                                 # to not be happy
2257                                                 #
2258                                                 eval SHARES_${mrs_old_group}=\"$mrs_new_list\"
2259                                         fi
2260                                         break
2261                                 fi
2262                         done
2263 
2264                         #
2265                         # If this is a 'move-share' command, and the target
2266                         # group name is valid, add the current share to the
2267                         # list of shares in the target group.
2268                         #
2269                         if [ "$mrs_subcmd" = "move-share" ]
2270                         then
2271                                 # If the new group is valid, add this share to
2272                                 # the list of shares in that group.
2273                                 if [ "$mrs_valid" ]
2274                                 then
2275                                         #
2276                                         # Wrapping the following line causes
2277                                         # eval to be unhappy.
2278                                         #
2279                                         eval SHARES_${mrs_group_arg}=\"\$SHARES_${mrs_group_arg} $mrs_share\"
2280                                 fi
2281                         fi
2282                 done
2283         fi
2284 
2285         #
2286         # Validate the current shares in all defined groups following the
2287         # operation.  We do this even if the command was a dry run or expected
2288         # to fail in order to insure that the command did not mess them up.
2289         #
2290         for mrs_check_group in `unique $GROUPS`
2291         do
2292                 tet_infoline "* Verify configuration of shares in group" \
2293                     "$mrs_check_group using sharemgr commands."
2294                 show $mrs_check_group
2295                 eval mrs_group_shares=\"\$SHARES_${mrs_check_group}\"
2296                 # Verify show output for group " \
2297                 # "$mrs_check_group displays these shares: $mrs_group_shares"
2298                 verify_share -g $mrs_check_group $mrs_group_shares
2299                 legacy_share_confirm $mrs_check_group
2300         done
2301 
2302         return $mrs_retval
2303 }
2304 
2305 #
2306 # NAME
2307 #       set_ctl
2308 #
2309 # SYNOPSIS
2310 #       take one or more properties and set them for the default protocol
2311 #
2312 # DESCRIPTION
2313 #       Use the default protocol variable to determine the protocol that the
2314 #       sharectl set command will use to set the provided properties to the
2315 #       given values.  The first argument is will optionally be the POS/NEG
2316 #       indicating the expected outcome of the call to sharectl set.  The
2317 #       second argument will be the property followed by the value for that
2318 #       argument.  If the value is ctl_reset then the argment will be taken
2319 #       from the stored configuration.  These type of argument coupling will
2320 #       proceed through until the last argument without a value, provided to
2321 #       override the default protocol setting.
2322 #
2323 #       The information for each property will also, be stored
2324 #       in as expected configuration for later verification via the
2325 #       sharectl get interface.
2326 #
2327 # RETURN VALUE
2328 #       This function passes on the return value of the sharectl set call.
2329 #
2330 function set_ctl {
2331         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
2332         then
2333                 CUR_RESULT=`get_tet_result`
2334                 if [ "$CUR_RESULT" != "PASS" ]
2335                 then
2336                         tet_infoline "The current state of the test case is"
2337                         tet_infoline "not PASS. Skipping the set subcommand."
2338                         tet_infoline "This can be overridden by setting the"
2339                         tet_infoline "environment variable"
2340                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
2341                         return
2342                 fi
2343         elif [ "$1" = "NO_RESULT_CHK" ]
2344         then
2345                 shift
2346         fi
2347 
2348         if [ "$1" = "NEG" ]
2349         then
2350                 sctl_pos_neg="$1"
2351                 shift
2352         else
2353                 sctl_pos_neg="POS"
2354                 if [ "$1" = "POS" ]
2355                 then
2356                         shift
2357                 fi
2358         fi
2359 
2360         tet_infoline "* sharectl set property information"
2361 
2362         unset sctl_options
2363         unset sctl_properties
2364         unset sctl_values
2365         sctl_protocol="$def_protocols"
2366         sctl_nextarg=$1
2367         while [ "$sctl_nextarg" ]
2368         do
2369                 shift
2370                 sctl_value=$1
2371                 if [ "$sctl_value" ]
2372                 then
2373                         if [ "$sctl_value" = "ctl_reset" ]
2374                         then
2375                                 sctl_value=`get_ctl_default $sctl_nextarg`
2376                         fi
2377                         sctl_options="$sctl_options -p ${sctl_nextarg}=${sctl_value}"
2378                         sctl_properties="$sctl_properties ${sctl_nextarg}"
2379                         set -A sctl_values ${sctl_values[*]} \"${sctl_value}\"
2380                         shift
2381                 else
2382                         sctl_protocol=$sctl_nextarg
2383                 fi
2384                 sctl_nextarg=$1
2385         done
2386 
2387         # Build the create command.
2388         sctl_cmd="${cmd_prefix}${SHARECTL} set $sctl_options $sctl_protocol"
2389 
2390         logfile=`get_logfile sharectl set ${sctl_options}`
2391         tet_infoline "  - $sctl_cmd"
2392         if [ "$report_only" != "TRUE" ]
2393         then
2394                 nfsd_pid=`$PGREP nfsd`
2395                 clean_logs
2396                 eval $sctl_cmd${cmd_postfix} > $logfile 2>&1
2397                 sctl_retval=$?
2398         fi
2399 
2400         # Append command to list of commands executed by this test case.
2401         append_cmd $c_cmd${cmd_postfix}
2402 
2403         if [ "$report_only" = "TRUE" ]
2404         then
2405                 return
2406         fi
2407 
2408         if [ $sctl_pos_neg = "POS" ]
2409         then
2410                 #
2411                 # Report on the return code.
2412                 #
2413                 POS_result $sctl_retval "$sctl_cmd"
2414 
2415                 #
2416                 # Go through and update all the stored information for
2417                 # each property.
2418                 #
2419                 sctl_cntr=0
2420                 for sctl_property in $sctl_properties
2421                 do
2422                         eval CTLPROP_${sctl_protocol}_${sctl_property}=${sctl_values[${sctl_cntr}]}
2423                         sclt_cntr=`expr $sctl_cntr + 1`
2424                 done
2425                 #
2426                 # if the return code was valid then verify the results
2427                 # for each property.
2428                 #
2429                 if [ $sctl_retval -eq 0 ]
2430                 then
2431                         for scsl_property in $sctl_properties
2432                         do
2433                                 verify_ctl_properties -P $sctl_protocol \
2434                                     $sctl_property
2435                         done
2436                 fi
2437         else
2438                 NEG_result $sctl_retval "$sctl_cmd"
2439         fi
2440 
2441         return $sctl_retval
2442 }
2443 
2444 
2445 #
2446 # NAME
2447 #       get_ctl
2448 #
2449 # SYNOPSIS
2450 #       take one or more (or zero) properties and get the property values
2451 #
2452 # DESCRIPTION
2453 #       Will take as the first agrument the POS/NEG as optional.
2454 #
2455 # RETURN VALUE
2456 #       This function passes on the return value of the sharectl get call.
2457 #
2458 function get_ctl {
2459         if [ "$1" != "NO_RESULT_CHK" -a "$sharemgr_NO_RESULT_CHK" != "TRUE" ]
2460         then
2461                 CUR_RESULT=`get_tet_result`
2462                 if [ "$CUR_RESULT" != "PASS" ]
2463                 then
2464                         tet_infoline "The current state of the test case is"
2465                         tet_infoline "not PASS. Skipping the get subcommand."
2466                         tet_infoline "This can be overridden by setting the"
2467                         tet_infoline "environment variable"
2468                         tet_infoline "sharemgr_NO_RESULT_CHK to TRUE"
2469                         return
2470                 fi
2471         elif [ "$1" = "NO_RESULT_CHK" ]
2472         then
2473                 shift
2474         fi
2475 
2476         if [ "$1" = "NEG" ]
2477         then
2478                 gctl_pos_neg="$1"
2479                 shift
2480         else
2481                 gctl_pos_neg="POS"
2482                 if [ "$1" = "POS" ]
2483                 then
2484                         shift
2485                 fi
2486         fi
2487 
2488         tet_infoline "* sharectl get property information"
2489 
2490         unset gctl_options
2491         unset gctl_properties
2492         gctl_protocol="$def_protocols"
2493         gctl_nextarg=$1
2494         while [ "$gctl_nextarg" ]
2495         do
2496                 if [ "$gctl_nextarg" = "-P" ]
2497                 then
2498                         gctl_protocol=$2
2499                         shift
2500                 else
2501                         gctl_options="$gctl_options -p ${gctl_nextarg}"
2502                 fi
2503                 shift
2504                 gctl_nextarg=$1
2505         done
2506 
2507         # Build the create command.
2508         gctl_cmd="${cmd_prefix}${SHARECTL} get $gctl_options $gctl_protocol"
2509 
2510         logfile=`get_logfile sharectl get ${gctl_options}`
2511         tet_infoline "  - $gctl_cmd"
2512         if [ "$report_only" != "TRUE" ]
2513         then
2514                 nfsd_pid=`$PGREP nfsd`
2515                 clean_logs
2516                 eval $gctl_cmd${cmd_postfix} > $logfile 2>&1
2517                 gctl_retval=$?
2518         fi
2519 
2520         if [ $gctl_pos_neg = "POS" ]
2521         then
2522                 POS_result $gctl_retval "$l_cmd"
2523         else
2524                 NEG_result $gctl_retval "$l_cmd"
2525         fi
2526 
2527         return $gctl_retval
2528 }