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