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 2008 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # convert all global environment variables to TCL
  27 
  28 #*********************************************************************
  29 # proc ext_eval (extended eval)
  30 # Allows the evaluation of <expression> as if done in caller, catching
  31 # errors. If successful, returns the output of the evaluation.
  32 # If error, displays <error_str> and evaluate <action>.
  33 
  34 proc ext_eval {expression {error_str "ERROR: $output"} {action {exit $result}}} {
  35     set result [catch {uplevel $expression} output]
  36     if {$result != 0} {
  37         puts stderr "$error_str"
  38         if {[string length $action] > 0} {
  39                 eval {$action}
  40         }
  41     }
  42     return $result
  43 }
  44 
  45 
  46 # Note: hardcoded return correct code in case environment not set
  47 set uninit 6
  48 
  49 # test result codes
  50 ext_eval {set ::PASS $env(PASS)}                \
  51         "ERROR uninitialized environment" "exit $uninit"
  52 ext_eval {set ::FAIL $env(FAIL)}                \
  53         "ERROR uninitialized environment" "exit $uninit"
  54 ext_eval {set ::UNRESOLVED $env(UNRESOLVED)}    \
  55         "ERROR uninitialized environment" "exit $uninit"
  56 ext_eval {set ::NOTINUSE $env(NOTINUSE)}        \
  57         "ERROR uninitialized environment" "exit $uninit"
  58 ext_eval {set ::UNSUPPORTED $env(UNSUPPORTED)}  \
  59         "ERROR uninitialized environment" "exit $uninit"
  60 ext_eval {set ::UNTESTED $env(UNTESTED)}        \
  61         "ERROR uninitialized environment" "exit $uninit"
  62 ext_eval {set ::UNINITIATED $env(UNINITIATED)}  \
  63         "ERROR uninitialized environment" "exit $uninit"
  64 ext_eval {set ::NORESULT $env(NORESULT)}        \
  65         "ERROR uninitialized environment" "exit $uninit"
  66 ext_eval {set ::WARNING $env(WARNING)}          \
  67         "ERROR uninitialized environment" "exit $uninit"
  68 ext_eval {set ::TIMED_OUT $env(TIMED_OUT)}      \
  69         "ERROR uninitialized environment" "exit $uninit"
  70 ext_eval {set ::OTHER $env(OTHER)}              \
  71         "ERROR uninitialized environment" "exit $uninit"
  72 
  73 # test variables
  74 ext_eval {set ::TESTROOT $env(TESTROOT)}        \
  75         "ERROR uninitialized environment" "exit $uninit"
  76 ext_eval {set ::SERVER $env(SERVER)}            \
  77         "ERROR uninitialized environment" "exit $uninit"
  78 ext_eval {set ::BASEDIR $env(BASEDIR)}          \
  79         "ERROR uninitialized environment" "exit $uninit"
  80 ext_eval {set ::ROOTDIR $env(ROOTDIR)}          \
  81         "ERROR uninitialized environment" "exit $uninit"
  82 ext_eval {set ::MNTPTR $env(MNTPTR)}          \
  83         "ERROR uninitialized environment" "exit $uninit"
  84 ext_eval {set ::NOTICEDIR $env(NOTICEDIR)}          \
  85         "ERROR uninitialized environment" "exit $uninit"
  86 ext_eval {set ::TMPDIR $env(TMPDIR)}            \
  87         "ERROR uninitialized environment" "exit $uninit"
  88 ext_eval {set ::PORT $env(PORT)}                \
  89         ""                              {set ::PORT \"2049\"; return 0}
  90 ext_eval {set ::TRANSPORT $env(TRANSPORT)}      \
  91         ""                              {set ::TRANSPORT \"tcp\"; return 0}
  92 ext_eval {set ::DELM $env(DELM)}                \
  93         ""                              {set ::DELM \"/\"; return 0}
  94 ext_eval {set ::DEBUG $env(DEBUG)}              \
  95         "" {set ::DEBUG 0; return 0}
  96 
  97 ext_eval {set ::BASEDIRS [path2comp $::BASEDIR $::DELM]} \
  98         "ERROR invalid BASEDIR" "exit $uninit"
  99 
 100 #assume lease time 90 seconds if env var not available
 101 ext_eval {set ::LEASE_TIME $env(LEASE_TIME)}    \
 102         ""                              {set ::LEASE_TIME 90; return 0}
 103 
 104 
 105 set ::IsZFS [ string equal $env(TestZFS) "1" ]
 106 
 107 set ::NULL 0
 108