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 "@(#)verify_common.ksh  1.7     09/08/23 SMI"
  27 #
  28 
  29 #
  30 # This file contains common sharemgr verification functions and is meant to be
  31 # sourced into the test case files.
  32 #
  33 
  34 #
  35 # NAME
  36 #       count_shares
  37 #
  38 # DESCRIPTION
  39 #       Count the number of shares listed by sharemgr
  40 #
  41 function count_shares {
  42         cs_ret_cnt=0
  43 
  44         for cs_group in `$SHAREMGR list -v | $GREP enabled | $AWK '{print $1}'`
  45         do
  46                 cs_cnt=`$SHAREMGR show $cs_group | $WC -l`
  47                 if [ $cs_cnt -gt 0 ]
  48                 then
  49                         cs_ret_cnt=`$EXPR $cs_ret_cnt + $cs_cnt - 1`
  50                 fi
  51         done
  52 
  53         echo $cs_ret_cnt
  54 }
  55 
  56 
  57 #
  58 # NAME
  59 #       unique
  60 #
  61 # DESCRIPTION
  62 #       Delete duplicate entries from the input list.
  63 #
  64 function unique {
  65         unset u_output_list
  66         for u_input in $*
  67         do
  68                 unset u_match
  69                 for u_output in $u_output_list
  70                 do
  71                         if [ "$u_input" = "$u_output" ]
  72                         then
  73                                 u_match="yes"
  74                                 break
  75                         fi
  76                 done
  77                 if [ ! "$u_match" ]
  78                 then
  79                         u_output_list="$u_output_list $u_input"
  80                 fi
  81         done
  82         echo $u_output_list
  83 }
  84 
  85 #
  86 # NAME
  87 #       valid_group
  88 #
  89 # DESCRIPTION
  90 #       Determine if the specified group name is valid (is listed in the
  91 #       global GROUPS variable).
  92 #
  93 function valid_group {
  94         vg_group="$1"
  95 
  96         #
  97         # If the group name isn't null...
  98         #
  99         if [ "$vg_group" ]
 100         then
 101                 #
 102                 # Check it against every group that was created by this
 103                 # test case looking for a match.
 104                 #
 105                 for vg_valid_group in $GROUPS
 106                 do
 107                         if [ "$vg_group" = "$vg_valid_group" ]
 108                         then
 109                                 echo "yes"
 110                                 return
 111                         fi
 112                 done
 113         fi
 114 
 115         echo ""
 116 }
 117 
 118 #
 119 # NAME
 120 #       legacy_share_confirm
 121 #
 122 # DESCRIPTION
 123 #       For the specified group, verify that the shares and options belonging
 124 #       to the group are accurately reflected by the 'legacy' commands &
 125 #       configuration files pertaining to shares.
 126 #
 127 function legacy_share_confirm {
 128         if [ "$1" = "NEG" ]
 129         then
 130                 lsc_pos_neg=$1
 131                 shift
 132         else
 133                 lsc_pos_neg="POS"
 134                 if [ "$1" = "POS" ]
 135                 then
 136                         shift
 137                 fi
 138         fi
 139 
 140         lsc_group="$1"
 141 
 142         if [ ! $LEGACYSHARE ]
 143         then
 144                 return
 145         fi
 146 
 147         tet_infoline "* Verify configuration of shares in group " \
 148             "$lsc_group using legacy methods"
 149 
 150         eval lsc_shares=\"\$SHARES_${lsc_group}\"
 151 
 152         #
 153         # Verify share(s) using /usr/sbin/share
 154         #
 155         lsc_cmd="/usr/sbin/share"
 156         tet_infoline " - $lsc_cmd"
 157         if [ "$report_only" != "TRUE" ]
 158         then
 159                 eval $lsc_cmd > /dev/null 2>&1
 160                 lsc_result=$?
 161         fi
 162         append_cmd $lsc_cmd
 163         # Verify return code is 0"
 164         if [ "$lsc_pos_neg" = "POS" ]
 165         then
 166                 POS_result $lsc_result "$lsc_cmd"
 167         else
 168                 NEG_result $lsc_result "$lsc_cmd"
 169         fi
 170 
 171         eval lsc_exp_state=\"\$EXP_STATE_${lsc_group}\"
 172         for lsc_share in $lsc_shares
 173         do
 174                 lsc_share="`echo $lsc_share | sed 's/|tmp$//'`" # Strip "|tmp"
 175 
 176                 if [ "$lsc_exp_state" = "enabled" ]
 177                 then
 178                         # Verify $lsc_share is shown in 'share' output 
 179                         if [ "$report_only" != "TRUE" ]
 180                         then
 181                                 $LEGACYSHARE | $GREP $lsc_share > /dev/null 2>&1
 182                                 lsc_result=$?
 183                         fi
 184                         if [ "$lsc_pos_neg" = "POS" ]
 185                         then
 186                                 POS_result $lsc_result "$lsc_share shared"
 187                         else
 188                                 NEG_result $lsc_result "$lsc_share not shared"
 189                         fi
 190                         # Verify $lsc_share has options matching $lsc_group"
 191                         verify_share_options nfs
 192                 else
 193                         # Verify $lsc_share is NOT shown in 'share' output"
 194                         if [ "$report_only" != "TRUE" ]
 195                         then
 196                                 $LEGACYSHARE | $GREP $lsc_share > /dev/null 2>&1
 197                                 lsc_result=$?
 198                         fi
 199                         if [ "$lsc_pos_neg" = "POS" ]
 200                         then
 201                                 NEG_result $lsc_result "$lsc_share not shared"
 202                         else
 203                                 POS_result $lsc_result "$lsc_share shared"
 204                         fi
 205                 fi
 206         done
 207 
 208         #
 209         # Verify share(s) using /usr/sbin/dfshares
 210         #
 211         lsc_cmd="$DFSHARES -F nfs"
 212         tet_infoline " - $lsc_cmd"
 213         if [ "$report_only" != "TRUE" ]
 214         then
 215                 eval $lsc_cmd > $dfs_log 2>&1
 216                 lsc_result=$?
 217         fi
 218         append_cmd $lsc_cmd
 219 
 220         if [ "$report_only" = "TRUE" ]
 221         then
 222                 return
 223         fi
 224         # Verify return code is 0"
 225         #
 226         # Need to check if there are any enabled groups with shares, because
 227         # if there are no enabled shares then dfshares will return
 228         # 1 instead of 0 as a return code.
 229         #
 230         # Also, check to see if mountd is running because dfstab will
 231         # fail in this case also.
 232         #
 233         $PGREP -x mountd > /dev/null 2>&1
 234         lsc_mntdrunning=$?
 235         lsc_share_cnt=`count_shares`
 236         if [ $lsc_share_cnt -eq 0 -o $lsc_mntdrunning -ne 0 ]
 237         then
 238                 NEG_result $lsc_result $lsc_cmd
 239         else
 240                 POS_result $lsc_result $lsc_cmd
 241 
 242                 for lsc_share in $lsc_shares
 243                 do
 244                         lsc_share="`echo $lsc_share | sed 's/|tmp$//'`"
 245                         if [ "$lsc_exp_state" = "enabled" ]
 246                         then
 247                                 #
 248                                 # Verify $lsc_share is shown in 
 249                                 # 'dfshares' output"
 250                                 #
 251                                 $GREP "$lsc_share" $dfs_log > /dev/null 2>&1
 252                                 POS_result $? \
 253                                     "$lsc_share should be shown in 'dfsshares' output but isn't"
 254                         else
 255                                 #
 256                                 # Verify $lsc_share is NOT shown in 
 257                                 # 'dfshares' output"
 258                                 #
 259                                 $GREP "$lsc_share" $dfs_log > /dev/null 2>&1
 260                                 NEG_result $? \
 261                                     "$lsc_share should not be shown in 'dfsshares' output but is"
 262                         fi
 263                 done
 264         fi
 265 
 266         #
 267         # Verify share(s) using /etc/dfs/dfstab
 268         #
 269         unset lsc_err
 270         for lsc_share in $lsc_shares
 271         do
 272                 unset lsc_tmp_share
 273                 echo $lsc_share | $GREP "|tmp" >/dev/null 2>&1
 274                 if [ $? -eq 0 ]
 275                 then
 276                         lsc_share="`echo $lsc_share | sed 's/|tmp$//'`"
 277                         lsc_tmp_share="yes"
 278                 fi
 279                 #
 280                 # If not temporary (no way to show yet, but should be
 281                 # added.
 282                 #
 283                 # If the state is disabled the share will still show
 284                 # in the dfstab.  Should ultimately remove the enable
 285                 # check here altogether most likely.
 286                 #
 287                 if [ "$lsc_exp_state" = "enabled" ]
 288                 then
 289                         #
 290                         # Verify $lsc_share is shown in /etc/dfs/dfstab 
 291                         # config file
 292                         #
 293                         $GREP "$lsc_share" $DFSTAB > /dev/null 2>&1
 294                         lsc_retval=$?
 295                         if [ "$lsc_tmp_share" ]
 296                         then
 297                                 NEG_result $lsc_retval \
 298                                     "$DFSTAB contains tmp share $lsc_share but shouldn't"
 299                                 if [ $? -eq 0 ]
 300                                 then
 301                                         lsc_err=1
 302                                 fi
 303                         else
 304                                 POS_result $lsc_retval \
 305                                     "$DFSTAB doesn't contain share $lsc_share but should"
 306                                 if [ $? -ne 0 ]
 307                                 then
 308                                         lsc_err=1
 309                                 fi
 310                         fi
 311                 fi
 312         done
 313 
 314         #
 315         # Print out the contents of the dfstab file if we found any problems
 316         # with it.
 317         #
 318         if [ "$lsc_err" ]
 319         then
 320                 tet_infoline "------------- Contents of $DFSTAB --------------"
 321                 infofile "" $DFSTAB
 322                 tet_infoline "------------------------------------------------"
 323         fi
 324 
 325         #
 326         # Check that the perms are correct on dfstab.
 327         #
 328         # Going to make this as a warning because all tests will fail
 329         # if this is broken.
 330         #
 331         pkgchk -a -P /etc/dfs/dfstab > /dev/null 2>&1
 332         lsc_res=$?
 333         if [ $lsc_res -ne 0 ]
 334         then
 335                 tet_infoline "WARNING - expected attributes are not set correctly"\
 336                         "for /etc/dfs/dfstab"
 337                 pkgchk -a -P /etc/dfs/dfstab > $SHR_TMPDIR/lsc_pkgchk.$$ 2>&1
 338                 infofile "  " $SHR_TMPDIR/lsc_pkgchk.$$
 339                 rm -f $SHR_TMPDIR/lsc_pkgchk.$$
 340         fi
 341 
 342         #
 343         # Verify share(s) using /etc/dfs/sharetab
 344         #
 345         unset lsc_err
 346         for lsc_share in $lsc_shares
 347         do
 348                 lsc_share="`echo $lsc_share | sed 's/|tmp$//'`"
 349                 # if not temporary (no way to show yet, but should be
 350                 # added.
 351                 if [ "$lsc_exp_state" = "enabled" ]
 352                 then
 353                         #
 354                         # Verify $lsc_share is shown in /etc/dfs/sharetab 
 355                         # config file"
 356                         #
 357                         $GREP "$lsc_share" $SHARETAB > /dev/null 2>&1
 358                         POS_result $? "$lsc_share listed in $SHARETAB"
 359                         if [ $? -ne 0 ]
 360                         then
 361                                 lsc_err=1
 362                         fi
 363                 else
 364                         #
 365                         # Verify $lsc_share is NOT shown in 
 366                         # /etc/dfs/sharetab config file
 367                         #
 368                         $GREP "$lsc_share" $SHARETAB > /dev/null 2>&1
 369                         NEG_result $? "$lsc_share not listed in $SHARETAB"
 370                         if [ $? -eq 0 ]
 371                         then
 372                                 lsc_err=1
 373                         fi
 374                 fi
 375         done
 376 
 377         #
 378         # Print out the contents of the sharetab file if we found any problems
 379         # with it.
 380         #
 381         if [ "$lsc_err" ]
 382         then
 383                 tet_infoline "------------ Contents of $SHARETAB -------------"
 384                 infofile "" $SHARETAB
 385                 tet_infoline "------------------------------------------------"
 386         fi
 387 
 388         #
 389         # Check that the perms are correct on sharetab.
 390         #
 391         # Going to make this as a warning because all tests will fail
 392         # if this is broken.
 393         #
 394         lsc_res=`$FIND /etc/dfs/sharetab -perm 0444 | $WC -l`
 395         if [ $lsc_res -eq 0 ]
 396         then
 397                 tet_infoline "WARNING - expected perms (0444) "\
 398                     "not set for sharetab"
 399         fi
 400         lsc_expectedog="rootroot"
 401         lsc_realog=`$LS -l /etc/dfs/sharetab | $AWK '{print $3 $4}'`
 402         if [ "$lsc_expectedog" != "$lsc_realog" ]
 403         then
 404                 tet_infoline "WARNING - owner/group $lsc_expectedog incorrect" \
 405                     "for dfstab $lsc_realog"
 406         fi
 407 }
 408 
 409 #
 410 # NAME
 411 #       verify_groups
 412 #
 413 # DESCRIPTION
 414 #       For all groups specified, verify the state of the groups using both
 415 #       'new' and 'legacy' methods.
 416 #
 417 function verify_groups {
 418         if [ "$1" = "NEG" ]
 419         then
 420                 vg_pos_neg=$1
 421                 shift
 422         else
 423                 vg_pos_neg="POS"
 424                 if [ "$1" = "POS" ]
 425                 then
 426                         shift
 427                 fi
 428         fi
 429 
 430         for v_group in $*
 431         do
 432                 # Some group names may be bogus (non-existent) for negative
 433                 # tests.  Check the group name against the list of 'real'
 434                 # groups (list made by the 'create' function) before attempting
 435                 # verification.
 436                 for v_real_group in $GROUPS
 437                 do
 438                         if [ "$v_group" = "$v_real_group" ]
 439                         then
 440                                 verify_group_state $vg_pos_neg $v_group
 441                                 legacy_share_confirm $v_group
 442                                 break
 443                         fi
 444                 done
 445         done
 446 }
 447 
 448 #
 449 # NAME
 450 #       verify_group_state
 451 #
 452 # DESCRIPTION
 453 #       For the specified group, verify that the state shown by the reporting
 454 #       commands matches the state we expect.
 455 #
 456 function verify_group_state {
 457         if [ "$1" = "NEG" ]
 458         then
 459                 vgs_pos_neg=$1
 460                 shift
 461         else
 462                 vgs_pos_neg="POS"
 463                 if [ "$1" = "POS" ]
 464                 then
 465                         shift
 466                 fi
 467         fi
 468 
 469         vgs_groups="$*"
 470 
 471         #
 472         # * Verify expected enable/disable state for "\
 473         #    "group(s) $vgs_groups"
 474         #
 475 
 476         list -v
 477         logfile=`get_logfile list -v`
 478         for vgs_group in $vgs_groups
 479         do
 480                 eval vgs_exp_state=\$EXP_STATE_${vgs_group}
 481                 #
 482                 # Verify state for '$vgs_group' in "
 483                 #    "'list -v' output is '$vgs_exp_state'"
 484                 #
 485                 $GREP $vgs_group $logfile | \
 486                     $GREP $vgs_exp_state > /dev/null 2>&1
 487                 vgs_result=$?
 488                 if [ "$vgs_pos_neg" = "POS" ]
 489                 then
 490                         POS_result $vgs_result "$vgs_group not in $vgs_exp_state"
 491                 else
 492                         NEG_result $vgs_result "$vgs_group $vgs_exp_state"
 493                 fi
 494         done
 495 }
 496 
 497 #
 498 # NAME
 499 #       verify_trd
 500 #
 501 # SYNOPSIS
 502 #       verify_trd <share> <file containing 'show -v' output>
 503 #
 504 # DESCRIPTION
 505 #       Verify tmp status, resource name, and description for a share.
 506 #       For the specified share, determine if the output of 'show -v'
 507 #       lists the proper:
 508 #               - Persistent (temporary or permanent)
 509 #               - Resource name
 510 #               - Description
 511 #
 512 function verify_trd {
 513         vt_share="$1"
 514         vt_logfile="$2"
 515 
 516         # Separate share name from '|tmp' suffix (if present)
 517         vt_share_strip="`echo $vt_share | sed 's/|tmp//' ` "
 518 
 519         #
 520         # Determine if the persistence (permanent or temporary) of the
 521         # share displayed in 'show -v' output matches what we set up.
 522         #
 523 
 524         if $GREP $vt_share_strip $vt_logfile | $GREP "\*" > /dev/null 2>&1
 525         then
 526                 # 'show -v' indicates temporary share
 527                 vt_tmp_in_show=0
 528         else
 529                 # 'show -v' doesn't indicate temporary share
 530                 vt_tmp_in_show=1
 531         fi
 532 
 533         if echo $vt_share | $GREP "|tmp" > /dev/null 2>&1
 534         then
 535                 # The share had been added as a temporary share
 536                 POS_result $vt_tmp_in_show \
 537                     "Expected '*' before $vs_share_strip in 'show -v' output"
 538         else
 539                 # The share had been added as a permanent share
 540                 NEG_result $vt_tmp_in_show \
 541                     "Didn't expect '*' before $vs_share_strip in 'show -v' output"
 542         fi
 543 
 544         # Get the resource name and description that we remember for this
 545         # share.  The variable names are based on the share name, but use
 546         # double underscores in place of each slash.  The | symbol is removed
 547         # becuase the remembered value removed the pipe symbol from its
 548         # variable name.
 549         vt_share_mod="`echo $vt_share | sed -e 's/\//__/g' -e 's/|//g'`"
 550         eval vt_remembered_rsrc=\"\$RSRC_${vt_share_mod}\"
 551         eval vt_remembered_desc=\"\$DESC_${vt_share_mod}\"
 552 
 553         #
 554         # Extract resource name from 'show -v' output and compare it to the
 555         # value we remember for this share.
 556         #
 557         unset vt_show_rsrc
 558         if $GREP $vt_share_strip $vt_logfile | $GREP "=" >/dev/null 2>&1
 559         then
 560                 vt_show_rsrc="`$GREP $vt_share_strip $vt_logfile | \
 561                     $GREP "=" | $SED 's/^[ |    ]*//g' | $AWK -F= '{print $1}'`"
 562         fi
 563         if [ "$vt_remembered_rsrc" != "$vt_show_rsrc" ]
 564         then
 565                 POS_result 1 \
 566                     "Expected resource name '$vt_remembered_rsrc' but 'show -v' gives '$vt_show_rsrc'"
 567         fi
 568 
 569         #
 570         # Extract description from 'show -v' output and compare it to the
 571         # value we remember for this share.
 572         #
 573         unset vt_show_desc
 574         if $GREP $vt_share_strip $vt_logfile | $GREP "\"$" >/dev/null 2>&1
 575         then
 576                 vt_show_desc="`$GREP $vt_share_strip $vt_logfile | \
 577                     sed 's/\"$//' | sed 's/^.*\"//' `"
 578         fi
 579         if [ "$vt_remembered_desc" != "$vt_show_desc" ]
 580         then
 581                 POS_result 1 \
 582                     "Expected description '$vt_remembered_desc' but 'show -v' gives '$vt_show_desc'"
 583         fi
 584 }
 585 
 586 #
 587 # NAME
 588 #       verify_share
 589 #
 590 # DESCRIPTION
 591 #       Verify that a share(s) is listed in the show output and listed in
 592 #       the specified group if a group is given.
 593 #
 594 # Note:  Steps needed to confirm output of 'sharemgr show' not known
 595 # yet as functional spec doesn't provide the necessary details.
 596 # So this may change, but for now will use the current state of 
 597 # things.
 598 #
 599 function verify_share {
 600         unset vs_share
 601         unset vs_group
 602 
 603 
 604         while getopts g: options
 605         do
 606                 case $options in
 607                 g) vs_group=$OPTARG;;
 608                 esac
 609         done
 610 
 611         vs_sharenotlistgrpmsg="vs_share : \$vs_share not listed in \$vs_group"
 612         vs_sharelistgrpmsg="vs_share : \$vs_share listed in \$vs_group"
 613         vs_sharenotlistmsg="vs_share : \$vs_share not listed"
 614         vs_sharelistmsg="vs_share : \$vs_share listed"
 615         vs_groupnotlistmsg="\$vs_group not listed"
 616         vs_grouplistmsg="\$vs_group listed"
 617 
 618         shift $((OPTIND - 1))
 619         if [ "$1" = "NEG" ]
 620         then
 621                 vs_pos_neg=$1
 622                 shift
 623         else
 624                 vs_pos_neg="POS"
 625                 if [ "$1" = "POS" ]
 626                 then
 627                         shift
 628                 fi
 629         fi
 630 
 631         vs_shares=$*
 632         show -v $vs_group
 633         logfile=`get_logfile show -v $vs_group`
 634         infofile "show -v: " $logfile
 635 
 636         if [ "$report_only" = "TRUE" ]
 637         then
 638                 return
 639         fi
 640 
 641         if [ $vs_group ]
 642         then
 643                 $GREP $vs_group $logfile > /dev/null 2>&1
 644                 if [ $? -ne 0 ]
 645                 then
 646                         eval tet_infoline "FAIL - $vs_groupnotlistmsg"
 647                         tet_result FAIL
 648                 else
 649                         if [ "$verbose" = "TRUE" ]
 650                         then
 651                                 eval tet_infoline "PASS - $vs_grouplistmsg"
 652                         fi
 653 
 654                         #
 655                         # For every share we remember being in this group...
 656                         #
 657                         for vs_share in $vs_shares
 658                         do
 659                                 #
 660                                 # Strip the temporary share indicator off of
 661                                 # the share name (if present).
 662                                 #
 663                                 vs_share_strip="`echo $vs_share | \
 664                                     sed 's/|tmp//' ` "
 665 
 666                                 #
 667                                 # Verify that the share is present in the
 668                                 # output of the 'show' command.
 669                                 #
 670                                 vs_share_line="`$GREP $vs_share_strip $logfile`"
 671                                 if [ "$vs_share_line" ]
 672                                 then
 673                                         vs_result=0
 674 
 675                                         #
 676                                         # Verify persistence (permanent or
 677                                         # temporary, resource name, and
 678                                         # description for the share.
 679                                         #
 680                                         verify_trd "$vs_share" $logfile
 681                                 else
 682                                         vs_result=1
 683                                 fi
 684                                 if [ $vs_pos_neg = "NEG" ]
 685                                 then
 686                                         NEG_result $vs_result \
 687                                            "$vs_sharelistgrpmgs" \
 688                                            "$vs_sharenotlistgrpmsg"
 689                                 else
 690                                         POS_result $vs_result \
 691                                             "$vs_sharenotlistgrpmsg" \
 692                                             "$vs_sharelistmsg"
 693                                 fi
 694                         done
 695                 fi
 696         else
 697                 #
 698                 # No group specified
 699                 #
 700                 for vs_share in $vs_shares
 701                 do
 702                         # Strip appended "|tmp" off $vs_share if present
 703                         vs_share_strip="`echo $vs_share | sed 's/|tmp//' ` "
 704 
 705                         $GREP $vs_share_strip $logfile > /dev/null 2>&1
 706                         vs_result=$?
 707                         if [ $vs_pos_neg = "NEG" ]
 708                         then
 709                                 NEG_result $vs_result "$vs_sharelistmsg" \
 710                                     "$vs_sharenotlistmsg"
 711                         else
 712                                 POS_result $vs_result "$vs_sharenotlistmsg" \
 713                                     "$vs_sharelistmsg"
 714                         fi
 715                 done
 716         fi
 717 
 718         #
 719         # Need to additionally verify that shares listed in a group
 720         # are supposed to be listed in the group
 721         #
 722         vs_shareshownnotmsg="\$share_shown should not be listed in \$vs_group"
 723         vs_shareshownmsg="\$share_shown should be listed in \$vs_group"
 724 
 725         if [ $vs_group ]
 726         then
 727                 vs_grouplist=$vs_group
 728         else
 729                 vs_grouplist=`unique $GROUPS`
 730         fi
 731         for vs_group in $vs_grouplist
 732         do
 733                 unset shares_shown
 734                 unset vs_group_shares
 735 
 736                 eval vs_group_shares=\"\$SHARES_${vs_group}\"
 737                 show $vs_group
 738                 build_group_to_share $logfile
 739                 eval vs_shares_shown=\${gts_${vs_group}[*]}
 740                 for vs_share_shown in $vs_shares_shown
 741                 do
 742                         found=0
 743                         for vs_share in $vs_group_shares
 744                         do
 745                                 # Strip off the '|tmp' appendix from the
 746                                 # share name (if present)
 747                                 vs_share="`echo $vs_share | sed 's/|tmp//' ` "
 748                                 debug=$?
 749                                 if [ $vs_share_shown = $vs_share ]
 750                                 then
 751                                         found=1
 752                                         break;
 753                                 fi
 754                         done
 755                         if [ $found -eq 0 ]
 756                         then
 757                                 eval tet_infoline "FAIL - $vs_shareshownnotmsg"
 758                                 tet_result FAIL
 759                         else 
 760                                 if [ "$verbose" = "TRUE" ]
 761                                 then
 762                                         eval tet_infoline \
 763                                             "PASS $vs_shareshownmsg"
 764                                 fi
 765                         fi
 766                 done
 767         done
 768 }
 769 
 770 #
 771 # NAME
 772 #       verify_group_delete
 773 #
 774 # DESCRIPTION
 775 #       verify that the group is not listed or listed, depending on the POS
 776 #       NEG option, in the output of sharemgr list
 777 #
 778 # NOTE : POS is the default
 779 #
 780 function verify_group_delete {
 781         if [ "$1" = "NEG" ]
 782         then
 783                 vgd_pos_neg=$1
 784                 shift
 785         else
 786                 vgd_pos_neg="POS"
 787                 if [ "$1" = "POS" ]
 788                 then
 789                         shift
 790                 fi
 791         fi
 792 
 793         vgd_group=$1
 794         
 795         # Verify group '$d_group' is not shown in 'list' output"
 796         list
 797         logfile=`get_logfile list`
 798         $GREP $vgd_group $logfile > /dev/null 2>&1
 799         vgd_result=$?
 800         #
 801         # Note : The reverse of POS and NEG functions are being called
 802         # because grep returning 1 is really a positive result for this
 803         # case.
 804         #
 805         if [ "$vgd_pos_neg" = "POS" ]
 806         then
 807                 NEG_result $vgd_result "$vgd_group listed, was not deleted" \
 808                     "$vgd_group not listed, was deleted"
 809         else
 810                 POS_result $vgd_result "$vgd_group not listed, was deleted" \
 811                     "$vgd_group listed, was not deleted"
 812         fi
 813 }
 814 
 815 #
 816 # NAME
 817 #       verify_share_options
 818 #
 819 # DESCRIPTION
 820 #       Confirm that the options listed in the LEGACYSHARE command and sharemgr
 821 #       match up properly.  Can pass a specific protocol for checking.
 822 #       NOTE : This is using 2 variables set in the calling function :
 823 #               $lsc_group
 824 #               $lsc_share
 825 #
 826 function verify_share_options {
 827         if [ $1 ]
 828         then
 829                 vso_prot=$1
 830         else
 831                 vso_prot="all"
 832         fi
 833         
 834         # Verify $lsc_share has options matching $lsc_group"
 835         show -p -P $vso_prot $lsc_group
 836         logfile=`get_logfile show -p -P $vso_prot $lsc_group`
 837         append_cmd $LEGACYSHARE
 838         if [ "$report_only" = "TRUE" ]
 839         then
 840                 return
 841         fi
 842 
 843         vso_lsc_options=`$LEGACYSHARE | $GREP $lsc_share | \
 844             $AWK '{print $3}' | sed s/\"//g | tr "," " "`
 845         vso_sc_options=`$GREP -w $lsc_group $logfile | $GREP $vso_prot | \
 846             eval sed -e 's/${vso_prot}=\(//' -e 's/$lsc_group//' -e 's/\)//' \
 847             -e 's/\"//g'`
 848         if [ "$vso_sc_options" ]
 849         then
 850                 #
 851                 # For each option that is set to true in sc_otions check
 852                 # for a corresponding option in the share output.
 853                 #
 854                 for vso_sc_opt in $vso_sc_options
 855                 do
 856                         echo $vso_sc_opt | $GREP "true" > /dev/null 2>&1
 857                         if [ $? -eq 0 ]
 858                         then
 859                                 vso_sc_opt=`echo $vso_sc_opt | \
 860                                     $AWK -F"=" '{print $1}'`
 861                                 echo $vso_lsc_options | \
 862                                     $GREP $vso_sc_opt > /dev/null 2>&1
 863                                 POS_result $? \
 864                                     "$vso_sc_opt in $vso_lsc_options list"
 865                         else
 866                                 echo $vso_lsc_options | $GREP $vso_sc_opt >\
 867                                     /dev/null 2>&1
 868                                 POS_result $? \
 869                                     "$vso_sc_opt in $vso_lsc_options list"
 870                         fi
 871                 done
 872                 #
 873                 # For each option that is in the share list make sure there
 874                 # is a true option setting in the sc_options list.
 875                 #
 876                 for vso_lsc_opt in $vso_lsc_options
 877                 do
 878                         vso_lsc_opt_found=1
 879                         for vso_sc_opt in $vso_sc_options
 880                         do
 881                                 echo $vso_sc_opt | $GREP $vso_lsc_opt > \
 882                                     /dev/null 2>&1
 883                                 if [ $? -eq 0 ]
 884                                 then
 885                                         echo $vso_lsc_opt | $GREP "=" > \
 886                                             /dev/null 2>&1
 887                                         if [ $? -eq 0 ]
 888                                         then
 889                                                 vso_lsc_opt_found=0
 890                                                 POS_result $vso_lsc_opt_found \
 891                                                     "$vso_lsc_opt in $vso_sc_options"
 892                                         else
 893                                                 echo $vso_sc_opt | $GREP \
 894                                                     "true" > /dev/null 2>&1
 895                                                 POS_result $? \
 896                                                     "$vso_lsc_opt true for $vsc_sc_opt"
 897                                         fi
 898                                         break
 899                                 fi
 900                         done
 901                 done
 902         else
 903                 if [ "$vso_lsc_options" != "rw" ]
 904                 then
 905                         tet_infoline "FAIL - Legacy share shows options "\
 906                             "$vso_lsc_options and sharemgr shows no options"
 907                         tet_result FAIL
 908                 fi
 909         fi
 910 }
 911 
 912 #
 913 # NAME
 914 #       build_group_to_share
 915 #
 916 # DESCRIPTION
 917 #       builds a group to share array list based on the current
 918 #       configuration.
 919 #
 920 function build_group_to_share {
 921         unset gts_lastelement
 922         unset ga_lastelement
 923         unset group_arry
 924         share_out=$1
 925 
 926         gts_lastelement=0
 927         ga_lastelement=0
 928         while IFS="\n" read line
 929         do
 930                 if [ "${line%${line#?}}" != "   " ]
 931                 then
 932                         cur_group=${line}
 933                         eval set -A group_arry ${group_arry[*]} $cur_group
 934                         ga_lastelement=`$EXPR $ga_lastelement + 1`
 935                         eval unset gts_${cur_group}
 936                 else
 937                         eval set -A gts_${cur_group} \${gts_${cur_group}[*]} \${line}
 938                         gts_lastelement=`$EXPR $gts_lastelement + 1`
 939                 fi
 940         done < $share_out
 941 }
 942 
 943 #
 944 # NAME
 945 #       verify_ctl_properties
 946 #
 947 # DESCRIPTION
 948 #       Verify the given (if none given, all) properties for the protocol
 949 #       specified (if no protocol given the use the default protocol).
 950 #
 951 #
 952 function verify_ctl_properties {
 953         if [ "$1" = "NEG" ]
 954         then
 955                 vcp_pos_neg=$1
 956                 shift
 957         else
 958                 vcp_pos_neg="POS"
 959                 if [ "$1" = "POS" ]
 960                 then
 961                         shift
 962                 fi
 963         fi
 964 
 965         if [ "$1" = "-P" ]
 966         then
 967                 vcp_protocol=$2
 968                 shift 2
 969         else
 970                 vcp_protocol=$default_protocols
 971         fi
 972 
 973         if [ "$1" ]
 974         then
 975                 vcp_properties="$*"
 976         else
 977                 eval vcp_properites=\"\$CTLPROPS_${vcp_protocol}\"
 978         fi
 979 
 980         for vcp_chk_prop in $vcp_properties
 981         do
 982                 eval vcp_chk_prop_val=\$CTLPROP_${vcp_protocol}_${vcp_chk_prop}
 983                 get_ctl $vcp_chk_prop -P $vcp_protocol
 984                 vcp_CHK_PROP_VAL=`cat $logfile | $AWK -F'=' '{print $2}'`
 985 
 986                 if [ "$vcp_chk_prop_val" != "$vcp_CHK_PROP_VAL" ]
 987                 then
 988                         tet_infoline "FAIL - Set value for $vcp_chk_prop of"\
 989                             "$vcp_CHK_PROP_VAL does not equal expected value "\
 990                             "of $vcp_chk_prop_val"
 991                         tet_result FAIL
 992                 else
 993                         if [ "$verbose" = "TRUE" ]
 994                         then
 995                                 tet_infoline "PASS - Set value for "\
 996                                     "$vcp_chk_prop of $vcp_CHK_PROP_VAL "\
 997                                     "does equals expected value of "\
 998                                     "$vcp_chk_prop_val"
 999                         fi
1000                 fi
1001         done
1002 }