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 2006 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # Open_confirm testing.
  27 
  28 # TESTROOT directory; must be set in the environment already
  29 set TESTROOT $env(TESTROOT)
  30 
  31 source [file join ${TESTROOT} tcl.init]
  32 source [file join ${TESTROOT} testproc]
  33 source [file join ${TESTROOT} lcltools]
  34 
  35 # setting local variables
  36 set TNAME $argv0
  37 
  38 # connect to the test server
  39 Connect
  40 
  41 
  42 # set clientid with server
  43 set tag $TNAME.setup
  44 set clientid ""
  45 set res ""
  46 set cverf ""
  47 if {[setclient [clock clicks] "o.[pid]" clientid cverf res] == "OK"} {
  48         if {[setclientconf $clientid $cverf res] != "OK"} {
  49                 putmsg stdout 0 "ERROR: cannot setclientid"
  50                 return $UNINITIATED
  51         }
  52 } else {
  53         return $UNINITIATED
  54 }
  55 
  56 # XXX add catch here later
  57 set dfh [get_fh $BASEDIRS]
  58 
  59 proc setparms {} {
  60         uplevel 1 {set stateid ""}
  61         uplevel 1 {set seqid ""}
  62         uplevel 1 {set rflags ""}
  63         uplevel 1 {set res ""}
  64         uplevel 1 {set st ""}
  65 }
  66 
  67 
  68 # Start testing
  69 # --------------------------------------------------------------
  70 
  71 # a: normal file
  72 set tag $TNAME{a}
  73 set expct "OK"
  74 set ASSERTION "normal file, expect $expct"
  75 putmsg stdout 0 "$tag: $ASSERTION"
  76 set filename "$tag"
  77 set TESTFILE [file join $BASEDIR $tag]
  78 setparms
  79 set fh [opencnftst $dfh $filename $clientid stateid seqid rflags]
  80 if {$fh == $NULL} {
  81         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
  82         exit $UNINITIATED
  83 }
  84 set st [openconf4 $fh $rflags stateid seqid res]
  85 ckres "Open_confirm" $st $expct $res $PASS
  86 closev4 $TESTFILE $fh $stateid $seqid
  87 
  88 
  89 # b: normal file, open retransmitted
  90 set tag $TNAME{b}
  91 set expct "OK"
  92 set ASSERTION "normal file, open retransmitted, expect $expct"
  93 putmsg stdout 0 "$tag: $ASSERTION"
  94 set filename "$tag"
  95 set TESTFILE [file join $BASEDIR $tag]
  96 setparms
  97 set fh [opencnftst $dfh $filename $clientid stateid seqid rflags]
  98 if {$fh == $NULL} {
  99         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 100         exit $UNINITIATED
 101 }
 102 incr seqid 3
 103 set fh [opencnftst $dfh $filename $clientid stateid seqid rflags]
 104 if {$fh == $NULL} {
 105         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 106         exit $UNINITIATED
 107 }
 108 set st [openconf4 $fh $rflags stateid seqid res]
 109 ckres "Open_confirm" $st $expct $res $PASS
 110 closev4 $TESTFILE $fh $stateid $seqid
 111 
 112 
 113 # c: normal file, openconfirm retransmitted
 114 set tag $TNAME{c}
 115 set expct "OK"
 116 set ASSERTION "normal file, openconfirm retransmitted, expect $expct"
 117 putmsg stdout 0 "$tag: $ASSERTION"
 118 set filename "$tag"
 119 set TESTFILE [file join $BASEDIR $tag]
 120 setparms
 121 set fh [opencnftst $dfh $filename $clientid stateid seqid rflags]
 122 if {$fh == $NULL} {
 123         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 124         exit $UNINITIATED
 125 }
 126 set ste2 $stateid
 127 set st [openconf4 $fh $rflags ste2 seqid res]
 128 incr seqid -1
 129 set st [openconf4 $fh $rflags stateid seqid res]
 130 ckres "Open_confirm" $st $expct $res $PASS
 131 closev4 $TESTFILE $fh $stateid $seqid
 132 
 133 
 134 # f: seqid set to max value
 135 set tag $TNAME{f}
 136 set expct "OK"
 137 set ASSERTION "seqid set to max value, expect $expct"
 138 putmsg stdout 0 "$tag: $ASSERTION"
 139 set filename "$tag"
 140 set TESTFILE [file join $BASEDIR $tag]
 141 setparms
 142 # max unsigned 32 bit value - 2
 143 set seqid [string range "[expr pow(2,32) - 2]" 0 end-2]
 144 set fh [opencnftst $dfh $filename $clientid stateid seqid rflags]
 145 if {$fh == $NULL} {
 146         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 147         exit $UNINITIATED
 148 }
 149 # max unsigned 32 bit value - 1
 150 set seqid [string range "[expr pow(2,32) - 1]" 0 end-2]
 151 set st [openconf4 $fh $rflags stateid seqid res]
 152 ckres "Open_confirm" $st $expct $res $PASS
 153 # seqid in server should be 0 now
 154 set seqid 0
 155 closev4 $TESTFILE $fh $stateid $seqid
 156 
 157 
 158 # --------------------------------------------------------------
 159 # disconnect and exit
 160 Disconnect
 161 exit $PASS