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 # Close 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 # XXX add catch here later
  43 set tag $TNAME.setup
  44 set dfh [get_fh $BASEDIRS]
  45 
  46 proc setparms {} {
  47         uplevel 1 {set stateid ""}
  48         uplevel 1 {set seqid ""}
  49         uplevel 1 {set rflags ""}
  50         uplevel 1 {set res ""}
  51         uplevel 1 {set st ""}
  52         uplevel 1 {set fh ""}
  53         uplevel 1 {set xfh ""}
  54 }
  55 
  56 
  57 # Start testing
  58 # --------------------------------------------------------------
  59 
  60 # a: directory filehandle
  61 set tag $TNAME{a}
  62 set expct "ISDIR|BAD_STATEID"
  63 set ASSERTION "directory filehandle, expect $expct"
  64 putmsg stdout 0 "$tag: $ASSERTION"
  65 set TESTFILE [file join $BASEDIR $tag]
  66 setparms
  67 set fh [openv4 $TESTFILE clientid stateid seqid ]
  68 if {$fh == $NULL} {
  69         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
  70         exit $UNINITIATED
  71 }
  72 set res ""
  73 set st [closetst $dfh $stateid $seqid res]
  74 ckres "Close" $st $expct $res $PASS
  75 if {[removev4 $TESTFILE] == $NULL} {
  76         putmsg stdout 0 "Can not remove $TESTFILE"
  77 }
  78 
  79 # b: removed file filehandle
  80 #set tag $TNAME{b}
  81 #set expct "STALE"
  82 #set ASSERTION "removed file filehandle, expect $expct"
  83 #putmsg stdout 0 "$tag: $ASSERTION"
  84 #putmsg stdout 0 "\tTest UNTESTED need a thread to set directly <cfh>"
  85 #set TESTFILE [file join $BASEDIR $tag]
  86 #setparms
  87 #set fh [openv4 $TESTFILE clientid stateid seqid ]
  88 #if {$fh == $NULL} {
  89 #       putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
  90 #       exit $UNINITIATED
  91 #}
  92 #if {[removev4 $TESTFILE] == $NULL} {
  93 #       putmsg stdout 0 "Can not remove $TESTFILE"
  94 #}
  95 #set res ""
  96 #set st [closetst $fh $stateid $seqid res]
  97 #ckres "Close" $st $expct $res $PASS
  98 
  99 
 100 # c: symlink to dir filehandle
 101 set tag $TNAME{c}
 102 set expct "BAD_STATEID"
 103 set ASSERTION "symlink to dir filehandle, expect $expct"
 104 putmsg stdout 0 "$tag: $ASSERTION"
 105 set TESTFILE [file join $BASEDIR $tag]
 106 setparms
 107 set fh [openv4 $TESTFILE clientid stateid seqid ]
 108 if {$fh == $NULL} {
 109         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 110         exit $UNINITIATED
 111 }
 112 # XXX add catch here later
 113 set xfh [get_fh [env2path SYMLDIR]]
 114 set res ""
 115 set st [closetst $xfh $stateid $seqid res]
 116 ckres "Close" $st $expct $res $PASS
 117 if {[removev4 $TESTFILE] == $NULL} {
 118         putmsg stdout 0 "Can not remove $TESTFILE"
 119 }
 120 
 121 
 122 # d: block file filehandle
 123 set tag $TNAME{d}
 124 set expct "BAD_STATEID"
 125 set ASSERTION "block file filehandle, expect $expct"
 126 putmsg stdout 0 "$tag: $ASSERTION"
 127 set TESTFILE [file join $BASEDIR $tag]
 128 setparms
 129 set fh [openv4 $TESTFILE clientid stateid seqid ]
 130 if {$fh == $NULL} {
 131         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 132         exit $UNINITIATED
 133 }
 134 # XXX add catch here later
 135 set xfh [get_fh [env2path BLKFILE]]
 136 set res ""
 137 set st [closetst $xfh $stateid $seqid res]
 138 ckres "Close" $st $expct $res $PASS
 139 if {[removev4 $TESTFILE] == $NULL} {
 140         putmsg stdout 0 "Can not remove $TESTFILE"
 141 }
 142 
 143 
 144 # e: char file filehandle
 145 set tag $TNAME{e}
 146 set expct "BAD_STATEID"
 147 set ASSERTION "char file filehandle, expect $expct"
 148 putmsg stdout 0 "$tag: $ASSERTION"
 149 set TESTFILE [file join $BASEDIR $tag]
 150 setparms
 151 set fh [openv4 $TESTFILE clientid stateid seqid ]
 152 if {$fh == $NULL} {
 153         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 154         exit $UNINITIATED
 155 }
 156 # XXX add catch here later
 157 set xfh [get_fh [env2path CHARFILE]]
 158 set res ""
 159 set st [closetst $xfh $stateid $seqid res]
 160 ckres "Close" $st $expct $res $PASS
 161 if {[removev4 $TESTFILE] == $NULL} {
 162         putmsg stdout 0 "Can not remove $TESTFILE"
 163 }
 164 
 165 
 166 # f: fifo file filehandle
 167 set tag $TNAME{f}
 168 set expct "BAD_STATEID"
 169 set ASSERTION "fifo file filehandle, expect $expct"
 170 putmsg stdout 0 "$tag: $ASSERTION"
 171 set TESTFILE [file join $BASEDIR $tag]
 172 setparms
 173 set fh [openv4 $TESTFILE clientid stateid seqid ]
 174 if {$fh == $NULL} {
 175         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 176         exit $UNINITIATED
 177 }
 178 # XXX add catch here later
 179 set xfh [get_fh [env2path FIFOFILE]]
 180 set res ""
 181 set st [closetst $xfh $stateid $seqid res]
 182 ckres "Close" $st $expct $res $PASS
 183 if {[removev4 $TESTFILE] == $NULL} {
 184         putmsg stdout 0 "Can not remove $TESTFILE"
 185 }
 186 
 187 
 188 # g: wrong file filehandle 
 189 set tag $TNAME{g}
 190 set expct "BAD_STATEID"
 191 set ASSERTION "wrong file filehandle, expect $expct"
 192 putmsg stdout 0 "$tag: $ASSERTION"
 193 set TESTFILE [file join $BASEDIR $tag]
 194 setparms
 195 # XXX add catch here later
 196 set xfh [get_fh [env2path ROFILE]]
 197 set fh [openv4 $TESTFILE clientid stateid seqid ]
 198 if {$fh == $NULL} {
 199         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 200         exit $UNINITIATED
 201 }
 202 set res ""
 203 set st [closetst $xfh $stateid $seqid res]
 204 ckres "Close" $st $expct $res $PASS
 205 if {[removev4 $TESTFILE] == $NULL} {
 206         putmsg stdout 0 "Can not remove $TESTFILE"
 207 }
 208 
 209 
 210 # h: corrupted filehandle
 211 #set tag $TNAME{h}
 212 #set expct "BADHANDLE"
 213 #set ASSERTION "corrupted filehandle, expect $expct"
 214 #putmsg stdout 0 "$tag: $ASSERTION"
 215 #putmsg stdout 0 "\tTest UNTESTED need a thread to set directly <cfh>"
 216 #set TESTFILE [file join $BASEDIR $tag]
 217 #setparms
 218 #set fh [openv4 $TESTFILE clientid stateid seqid ]
 219 #if {$fh == $NULL} {
 220 #       putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 221 #       exit $UNINITIATED
 222 #}
 223 ## XXX add catch here later
 224 #set xfh [string replace $fh end-7 end "DEADBEEF"]
 225 #set res ""
 226 #set st [closetst $xfh $stateid $seqid res]
 227 #ckres "Close" $st $expct $res $PASS
 228 #if {[removev4 $TESTFILE] == $NULL} {
 229 #       putmsg stdout 0 "Can not remove $TESTFILE"
 230 #}
 231 
 232 
 233 # i: filehandle set to 0s
 234 #set tag $TNAME{i}
 235 #set expct "BADHANDLE"
 236 #set ASSERTION "filehandle set to 0s, expect $expct"
 237 #putmsg stdout 0 "$tag: $ASSERTION"
 238 #putmsg stdout 0 "\tTest UNTESTED need a thread to set directly <cfh>"
 239 #set TESTFILE [file join $BASEDIR $tag]
 240 #setparms
 241 #set fh [openv4 $TESTFILE clientid stateid seqid ]
 242 #if {$fh == $NULL} {
 243 #       putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 244 #       exit $UNINITIATED
 245 #}
 246 ## XXX add catch here later
 247 #set xfh [binary format "S4" {0 0 0 0}]
 248 #set res ""
 249 #set st [closetst $xfh $stateid $seqid res]
 250 #ckres "Close" $st $expct $res $PASS
 251 #if {[removev4 $TESTFILE] == $NULL} {
 252 #       putmsg stdout 0 "Can not remove $TESTFILE"
 253 #}
 254 
 255 # j: filehandle set to 1s
 256 #set tag $TNAME{j}
 257 #set expct "BADHANDLE"
 258 #set ASSERTION "filehandle set to 1s, expect $expct"
 259 #putmsg stdout 0 "$tag: $ASSERTION"
 260 #putmsg stdout 0 "\tTest UNTESTED need a thread to set directly <cfh>"
 261 #set TESTFILE [file join $BASEDIR $tag]
 262 #setparms
 263 #set fh [openv4 $TESTFILE clientid stateid seqid ]
 264 #if {$fh == $NULL} {
 265 #       putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 266 #       exit $UNINITIATED
 267 #}
 268 ## XXX add catch here later
 269 #set xfh [binary format "S4" {65535 65535 65535 65535}]
 270 #set res ""
 271 #set st [closetst $xfh $stateid $seqid res]
 272 #ckres "Close" $st $expct $res $PASS
 273 #if {[removev4 $TESTFILE] == $NULL} {
 274 #       putmsg stdout 0 "Can not remove $TESTFILE"
 275 #}
 276 
 277 
 278 # k: filehandle set to NULL
 279 set tag $TNAME{k}
 280 set expct "NOFILEHANDLE"
 281 set ASSERTION "no filehandle set, expect $expct"
 282 putmsg stdout 0 "$tag: $ASSERTION"
 283 set TESTFILE [file join $BASEDIR $tag]
 284 setparms
 285 set fh [openv4 $TESTFILE clientid stateid seqid ]
 286 if {$fh == $NULL} {
 287         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 288         exit $UNINITIATED
 289 }
 290 # XXX add catch here later
 291 set res ""
 292 set st [closetst "" $stateid $seqid res]
 293 ckres "Close" $st $expct $res $PASS
 294 if {[removev4 $TESTFILE] == $NULL} {
 295         putmsg stdout 0 "Can not remove $TESTFILE"
 296 }
 297 
 298 
 299 
 300 # l: wrong file stateid
 301 set tag $TNAME{l}
 302 set expct "BAD_STATEID"
 303 set ASSERTION "wrong file stateid, expect $expct"
 304 putmsg stdout 0 "$tag: $ASSERTION"
 305 set TESTFILE [file join $BASEDIR $tag]
 306 setparms
 307 set fh [openv4 $TESTFILE clientid stateid seqid ]
 308 if {$fh == $NULL} {
 309         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 310         exit $UNINITIATED
 311 }
 312 set fil2 "close-2-[clock clicks]"
 313 set TSTF2 [file join $BASEDIR $fil2]
 314 set ste2 ""
 315 set sq2 ""
 316 set rf2 ""
 317 set fh2 [opencnftst $dfh $fil2 $clientid ste2 sq2 rf2 ]
 318 if {$fh2 == $NULL} {
 319         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TSTF2."
 320         exit $UNINITIATED
 321 }
 322 set st [openconf4 $fh2 $rf2 ste2 sq2]
 323 if {$st != "OK"} {
 324         putmsg stderr 0 "\t Test UNINITIATED: unable to open_confirm $TSTF2."
 325         exit $UNINITIATED
 326 }
 327 set res ""
 328 set st [closetst $fh $ste2 $seqid res]
 329 ckres "Close" $st $expct $res $PASS
 330 #close file with real info now
 331 set st [closetst $fh $stateid $seqid res]
 332 if {[removev4 $TESTFILE] == $NULL} {
 333         putmsg stdout 0 "Can not remove $TESTFILE"
 334 }
 335 closev4 $TSTF2 $fh2 $ste2 $sq2
 336 unset fil2 TSTF2 sq2 rf2
 337 
 338 
 339 # m: wrong file stateid diff clientid
 340 set tag $TNAME{m}
 341 set expct "BAD_STATEID"
 342 set ASSERTION "wrong file stateid diff clientid, expect $expct"
 343 putmsg stdout 0 "$tag: $ASSERTION"
 344 set TESTFILE [file join $BASEDIR $tag]
 345 setparms
 346 set fh [openv4 $TESTFILE clientid stateid seqid ]
 347 if {$fh == $NULL} {
 348         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 349         exit $UNINITIATED
 350 }
 351 set fil2 "close-2-[clock clicks]"
 352 set TSTF2 [file join $BASEDIR $fil2]
 353 set ste2 ""
 354 set cl2 ""
 355 set sq2 ""
 356 set rf2 ""
 357 set fh2 [openv4 $TSTF2 cl2 ste2 sq2]
 358 if {$fh2 == $NULL} {
 359         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TSTF2."
 360         exit $UNINITIATED
 361 }
 362 set res ""
 363 set st [closetst $fh $ste2 $seqid res]
 364 ckres "Close" $st $expct $res $PASS
 365 #close file with real info now
 366 set st [closetst $fh $stateid $seqid res]
 367 if {[removev4 $TESTFILE] == $NULL} {
 368         putmsg stdout 0 "Can not remove $TESTFILE"
 369 }
 370 closev4 $TSTF2 $fh2 $ste2 $sq2
 371 unset fil2 TSTF2 cl2 sq2 rf2
 372 
 373 
 374 # n1: corrupted stateid (stateid/seqid + 1)
 375 set tag $TNAME{n1}
 376 set expct "BAD_STATEID"
 377 set ASSERTION "corrupted stateid (stateid/seqid + 1), expect $expct"
 378 putmsg stdout 0 "$tag: $ASSERTION"
 379 set TESTFILE [file join $BASEDIR $tag]
 380 setparms
 381 set fh [openv4 $TESTFILE clientid stateid seqid ]
 382 if {$fh == $NULL} {
 383         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 384         exit $UNINITIATED
 385 }
 386 set bseqid [expr [lindex $stateid 0] + 1]
 387 set bad_osid "$bseqid [lindex $stateid 1]"
 388 set res ""
 389 set st [closetst $fh $bad_osid $seqid res]
 390 ckres "Close" $st $expct $res $PASS
 391 if {[removev4 $TESTFILE] == $NULL} {
 392         putmsg stdout 0 "Can not remove $TESTFILE"
 393 }
 394 
 395 # n2: corrupted stateid (trashed-other)
 396 set tag $TNAME{n2}
 397 set expct "BAD_STATEID|STALE_STATEID"
 398 set ASSERTION "corrupted stateid (trashed-other), expect $expct"
 399 putmsg stdout 0 "$tag: $ASSERTION"
 400 set TESTFILE [file join $BASEDIR $tag]
 401 setparms
 402 set fh [openv4 $TESTFILE clientid stateid seqid ]
 403 if {$fh == $NULL} {
 404         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 405         exit $UNINITIATED
 406 }
 407 set newS ""
 408 set oldS [lindex $stateid 1]
 409 set l [string length $oldS]
 410 for {set i 0} {$i < $l} {incr i} {
 411         append newS [string index $oldS end-$i]
 412 }
 413 set bad_osid "[lindex $stateid 0] $newS"
 414 set res ""
 415 set st [closetst $fh $bad_osid $seqid res]
 416 ckres "Close" $st $expct $res $PASS
 417 if {[removev4 $TESTFILE] == $NULL} {
 418         putmsg stdout 0 "Can not remove $TESTFILE"
 419 }
 420 
 421 
 422 # o: stateid set to 0-special-stateid
 423 set tag $TNAME{o}
 424 set expct "BAD_STATEID"
 425 set ASSERTION "Close w/0-special-stateid, expect $expct"
 426 putmsg stdout 0 "$tag: $ASSERTION"
 427 putmsg stdout 0 "\t Test UNTESTED"
 428 putmsg stdout 0 "\t   Temporary commented out due to 4811769 (p4)"
 429 #set TESTFILE [file join $BASEDIR $tag]
 430 #setparms
 431 #set fh [openv4 $TESTFILE clientid stateid seqid ]
 432 #if {$fh == $NULL} {
 433 #       putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 434 #       exit $UNINITIATED
 435 #}
 436 #set ste3 "0 0"
 437 #set res ""
 438 #set st [closetst $fh $ste3 $seqid res]
 439 #ckres "Close" $st $expct $res $PASS
 440 #if {[removev4 $TESTFILE] == $NULL} {
 441 #       putmsg stdout 0 "Can not remove $TESTFILE"
 442 #}
 443 
 444 
 445 # p: stateid set to 1-special-stateid
 446 set tag $TNAME{p}
 447 set expct "BAD_STATEID"
 448 set ASSERTION "Close w/1-special-stateid, expect $expct"
 449 putmsg stdout 0 "$tag: $ASSERTION"
 450 set TESTFILE [file join $BASEDIR $tag]
 451 setparms
 452 set fh [openv4 $TESTFILE clientid stateid seqid ]
 453 if {$fh == $NULL} {
 454         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 455         exit $UNINITIATED
 456 }
 457 set ste3 "1 1"
 458 set res ""
 459 set st [closetst $fh $ste3 $seqid res]
 460 ckres "Close" $st $expct $res $PASS
 461 if {[removev4 $TESTFILE] == $NULL} {
 462         putmsg stdout 0 "Can not remove $TESTFILE"
 463 }
 464 
 465 
 466 # r: simulate retransmitted, seqid increased by 3
 467 set tag $TNAME{r}
 468 set expct "BAD_SEQID"
 469 set ASSERTION "simulate retransmitted, seqid increased by 3, expect $expct"
 470 putmsg stdout 0 "$tag: $ASSERTION"
 471 set TESTFILE [file join $BASEDIR $tag]
 472 setparms
 473 set fh [openv4 $TESTFILE clientid stateid seqid ]
 474 if {$fh == $NULL} {
 475         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 476         exit $UNINITIATED
 477 }
 478 set res ""
 479 incr seqid 3
 480 set st [closetst $fh $stateid $seqid res]
 481 ckres "Close" $st $expct $res $PASS
 482 if {[removev4 $TESTFILE] == $NULL} {
 483         putmsg stdout 0 "Can not remove $TESTFILE"
 484 }
 485 
 486 
 487 # s: previous seqid
 488 set tag $TNAME{s}
 489 set expct "BAD_SEQID"
 490 set ASSERTION "previous seqid, expect $expct"
 491 putmsg stdout 0 "$tag: $ASSERTION"
 492 set TESTFILE [file join $BASEDIR $tag]
 493 setparms
 494 set fh [openv4 $TESTFILE clientid stateid seqid ]
 495 if {$fh == $NULL} {
 496         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 497         exit $UNINITIATED
 498 }
 499 set res ""
 500 incr seqid -1
 501 set st [closetst $fh $stateid $seqid res]
 502 ckres "Close" $st $expct $res $PASS
 503 if {[removev4 $TESTFILE] == $NULL} {
 504         putmsg stdout 0 "Can not remove $TESTFILE"
 505 }
 506 
 507 
 508 # t: seqid old (set to 1)
 509 set tag $TNAME{t}
 510 set expct "BAD_SEQID"
 511 set ASSERTION "seqid old (set to 1), expect $expct"
 512 putmsg stdout 0 "$tag: $ASSERTION"
 513 set TESTFILE [file join $BASEDIR $tag]
 514 setparms
 515 set fh [openv4 $TESTFILE clientid stateid seqid ]
 516 if {$fh == $NULL} {
 517         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 518         exit $UNINITIATED
 519 }
 520 set res ""
 521 incr seqid 1
 522 set st [closetst $fh $stateid $seqid res]
 523 ckres "Close" $st $expct $res $PASS
 524 if {[removev4 $TESTFILE] == $NULL} {
 525         putmsg stdout 0 "Can not remove $TESTFILE"
 526 }
 527 
 528 
 529 # u: seqid set to 0
 530 set tag $TNAME{u}
 531 set expct "BAD_SEQID"
 532 set ASSERTION "seqid set to 0, expect $expct"
 533 putmsg stdout 0 "$tag: $ASSERTION"
 534 set TESTFILE [file join $BASEDIR $tag]
 535 setparms
 536 set fh [openv4 $TESTFILE clientid stateid seqid ]
 537 if {$fh == $NULL} {
 538         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 539         exit $UNINITIATED
 540 }
 541 set res ""
 542 set seqid 0
 543 set st [closetst $fh $stateid $seqid res]
 544 ckres "Close" $st $expct $res $PASS
 545 if {[removev4 $TESTFILE] == $NULL} {
 546         putmsg stdout 0 "Can not remove $TESTFILE"
 547 }
 548 
 549 
 550 # v: seqid set to NULL
 551 set tag $TNAME{v}
 552 set expct "BAD_SEQID"
 553 set ASSERTION "seqid set to NULL, expect $expct"
 554 putmsg stdout 0 "$tag: $ASSERTION"
 555 set TESTFILE [file join $BASEDIR $tag]
 556 setparms
 557 set fh [openv4 $TESTFILE clientid stateid seqid ]
 558 if {$fh == $NULL} {
 559         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 560         exit $UNINITIATED
 561 }
 562 set res ""
 563 set st [closetst $fh $stateid {""} res]
 564 ckres "Close" $st $expct $res $PASS
 565 if {[removev4 $TESTFILE] == $NULL} {
 566         putmsg stdout 0 "Can not remove $TESTFILE"
 567 }
 568 
 569 
 570 # w: seqid corrupted (set to 1234567890)
 571 set tag $TNAME{w}
 572 set expct "BAD_SEQID"
 573 set ASSERTION "seqid (set to 1234567890) corrupted, expect $expct"
 574 putmsg stdout 0 "$tag: $ASSERTION"
 575 set TESTFILE [file join $BASEDIR $tag]
 576 setparms
 577 set fh [openv4 $TESTFILE clientid stateid seqid ]
 578 if {$fh == $NULL} {
 579         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 580         exit $UNINITIATED
 581 }
 582 set res ""
 583 set sq2 1234567890
 584 set st [closetst $fh $stateid $sq2 res]
 585 ckres "Close" $st $expct $res $PASS
 586 if {[removev4 $TESTFILE] == $NULL} {
 587         putmsg stdout 0 "Can not remove $TESTFILE"
 588 }
 589 
 590 # x: close again using stateid from close
 591 set tag $TNAME{x}
 592 set expct "BAD_STATEID|OLD_STATEID"
 593 set ASSERTION "close again using stateid from close, expect $expct"
 594 putmsg stdout 0 "$tag: $ASSERTION"
 595 set TESTFILE [file join $BASEDIR $tag]
 596 setparms
 597 set fh [openv4 $TESTFILE clientid stateid seqid ]
 598 if {$fh == $NULL} {
 599         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 600 } else {
 601         set st [closetst $fh $stateid $seqid res]
 602         if {$st != "OK"} {
 603             putmsg stderr 0 "\t Test UNRESOLVED: failed in 1st close."
 604             putmsg stderr 0 "\t\t status=($st)"
 605         } else {
 606             set csid [lindex [lindex $res 1] 2]
 607             incr seqid
 608             set st [closetst $fh $csid $seqid res]
 609             ckres "Close" $st $expct $res $PASS
 610             if {[removev4 $TESTFILE] == $NULL} {
 611                 putmsg stdout 0 "Can not remove $TESTFILE"
 612             }
 613         }
 614 }
 615 
 616 # z: get NFS4ERR_EXPIRED
 617 set tag $TNAME{z}
 618 set expct "EXPIRED|BAD_STATEID"
 619 set ASSERTION "get NFS4ERR_EXPIRED, expect $expct"
 620 putmsg stdout 0 "$tag: $ASSERTION"
 621 set TESTFILE [file join $BASEDIR $tag]
 622 setparms
 623 set fh [openv4 $TESTFILE clientid stateid seqid ]
 624 if {$fh == $NULL} {
 625         putmsg stderr 0 "\t Test UNINITIATED: unable to open $TESTFILE."
 626         exit $UNINITIATED
 627 }
 628 
 629 # Wait until lease time expires
 630 set SERVER $env(SERVER)
 631 set CLIENT $env(CLIENT)
 632 set tmstr [get_sctime $SERVER $CLIENT]
 633 set Delay [expr ($LEASE_TIME + 5) * 1000]
 634 after $Delay
 635 set res ""
 636 set st [closetst $fh $stateid $seqid res]
 637 set tmstr "$tmstr\nafter $Delay and closetst are done, \
 638                 get system time again"
 639 set tmstr "$tmstr\n[get_sctime $SERVER $CLIENT]"
 640 set ret [ckres "Close" $st $expct $res $PASS]
 641 if {!$ret} {
 642         # if fail, puts related time info on server and client
 643         # and cpu info as well
 644         puts $tmstr
 645         set cpucmd "/usr/sbin/psrinfo -pv"
 646         puts "\nCPU info of server: $SERVER"
 647         puts [exec rsh -n -l root $SERVER "$cpucmd"]
 648         puts "\nCPU info of client: $CLIENT"
 649         puts [exec sh -c "$cpucmd"]
 650 
 651 }
 652 if {[removev4 $TESTFILE] == $NULL} {
 653         putmsg stdout 0 "Can not remove $TESTFILE"
 654 }
 655 
 656 # XXX reconnect if more assertions are added
 657 #
 658 # y: get NFS4ERR_DELAY ???????????
 659 # z: get NFS4ERR_RESOURCE ? should we test it from opentestcases ?
 660 # other assertions to implement (recovery & migration & security)
 661 # : get NFS4ERR_FHEXPIRED (volatile filehandles, recovery)
 662 # : get NFS4ERR_GRACE   (recovery)
 663 # : get NFS4ERR_LEASE_MOVED (migration)
 664 # : get NFS4ERR_MOVED   (migration)
 665 # : get NFS4ERR_SERVERFAULT (recovery)
 666 # : get NFSV$ERR_STALE_STATEID
 667 
 668 
 669 # --------------------------------------------------------------
 670 # disconnect and exit
 671 
 672 Disconnect
 673 exit $PASS
 674