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 # send_setattr_reqs.tcl - loop to send multiple SETATTR requests 
  27 # to generate server side kernel upcall to nfsmapid
  28 #
  29 # Usage: 
  30 #    nfsh send_setattr_reqs.tcl <file_path> <number_of_reqs>
  31 #       file_path - path to the testfile
  32 #       number_of_reqs - the number of requests to be sent. 
  33 
  34 # Get the TESTROOT directory
  35 set TESTROOT $env(TESTROOT)
  36 
  37 source [file join ${TESTROOT} tcl.init]
  38 source [file join ${TESTROOT} testproc]
  39 source [file join ${TESTROOT} lcltools]
  40 
  41 # setting local variables
  42 set TNAME $argv0
  43 
  44 if { $argc != 2 } {
  45    putmsg stderr 0 "$TNAME <file_path> <number_of_reqs>"
  46    putmsg stderr 0 "\tfile_path - path to the testfile"
  47    putmsg stderr 0 "\tnumber_of_reqs - the number of requests to be sent."
  48    exit $UNINITIATED
  49 }
  50 
  51 set TESTFILE [lindex $argv 0]
  52 set LOOP [lindex $argv 1]
  53 
  54 putmsg stdout 0 "\n"
  55 putmsg stdout 0 "$TNAME: sending $LOOP SETATTR requests to server to genereate kernel upcalls to nfsmapid"
  56 
  57 # connect to the test server
  58 Connect
  59 
  60 set comp [ path2comp $TESTFILE $DELM ]
  61 set domain $env(Cdomain)
  62 set stateid {0 0}
  63 set exp "* {Setattr BADOWNER {}}"
  64 
  65 set i 0
  66 while { ${i} < $LOOP } {
  67     set fowner "fakeuser${i}@$domain"
  68     if { [ catch { 
  69        set res [ compound {
  70           Putrootfh; foreach c $comp {Lookup $c};
  71           Setattr $stateid {{owner $fowner}}}]}]} { 
  72        putmsg stderr 0 "\tERROR: rpc call failed for fakeuser${i}@$domain"
  73        putmsg stderr 0 "\tresult: $res"
  74        Disconnect
  75        exit $FAIL
  76     } 
  77 
  78     # get server's reply, check the result
  79     if { ![string match $exp $res] } {
  80        putmsg stderr 0 "\tERROR: unexpected return result for fakeuser${i}@$domain"
  81        putmsg stderr 0 "\tresult: $res"
  82        Disconnect
  83        exit $FAIL
  84     }
  85 
  86     set fgroup "fakegroup${i}@$domain"
  87     if { [ catch { 
  88        set res [compound {
  89           Putrootfh; foreach c $comp {Lookup $c};
  90           Setattr $stateid {{owner_group $fgroup}}}]}]} {
  91        putmsg stderr 0 "\tERROR: rpc call failed for fakegroup${i}@$domain"
  92        putmsg stderr 0 "\tresult: $res"
  93        Disconnect
  94        exit $FAIL
  95     }
  96 
  97     # get server's reply, check the result
  98     if { ![string match $exp $res] } {
  99        putmsg stderr 0 "\tERROR: unexpected return result for fakegroup${i}@$domain"
 100        putmsg stderr 0 "\tresult: $res"
 101        Disconnect
 102        exit $FAIL
 103     }
 104 
 105         incr i
 106 }
 107 
 108 putmsg stdout 0 "$TNAME: test run completed successfully"
 109 
 110 # disconnect and exit
 111 Disconnect
 112 exit $PASS