sd: remove 'ssd' driver support
[unleashed/tickless.git] / usr / src / lib / libshell / common / tests / treemove.sh
blob9e83e35e50d06f485d6816ee1106935d418ef02a
2 # CDDL HEADER START
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.
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.
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]
19 # CDDL HEADER END
23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # This test checks whether "typeset -m" correctly moves local variables
29 # into a global variable tree.
31 # This was reported as CR #XXXXXXXX ("XXXX"):
32 # -- snip --
33 #XXXX
34 # -- snip --
37 function err_exit
39 print -u2 -n "\t"
40 print -u2 -r ${Command}[$1]: "${@:2}"
41 (( Errors+=1 ))
44 alias err_exit='err_exit $LINENO'
46 integer Errors=0
48 ## test start
49 typeset -C tree1 tree2
51 # add node to tree which uses "typeset -m" to move a local variable
52 # into tree1.subtree["a_node"]
53 function f1
55 nameref tr=$1
56 typeset -A tr.subtree
57 typeset -C node
58 node.one="hello"
59 node.two="world"
60 # move local note into the array
61 false
62 typeset -m tr.subtree["a_node"]=node
63 return 0
66 # Alternative version which uses "nameref" instead of "typeset -m"
67 function f2
69 nameref tr=$1
70 typeset -A tr.subtree
71 nameref node=tr.subtree["a_node"]
72 node.one="hello"
73 node.two="world"
74 return 0
77 f1 tree1
78 f2 tree2
80 [[ "${tree1.subtree["a_node"].one}" == "hello" ]] || err_exit "expected tree1.subtree[\"a_node\"].one == 'hello', got ${tree1.subtree["a_node"].one}"
81 [[ "${tree1.subtree["a_node"].two}" == "world" ]] || err_exit "expected tree1.subtree[\"a_node\"].two == 'world', got ${tree1.subtree["a_node"].two}"
82 [[ "${tree1}" == "${tree2}" ]] || err_exit "tree1 and tree2 differ:$'\n'"
84 # tests done
85 exit $((Errors))