|
1 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of the License "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 init() |
|
17 { |
|
18 let totalno=0; |
|
19 let passno=0; |
|
20 let failno=0; |
|
21 } |
|
22 |
|
23 # Each named parameter is unset using no option to unset an existing option |
|
24 test_unset2() |
|
25 { |
|
26 let totalno=totalno+1 |
|
27 echo "Test $totalno: unset command to unset with no option to unset patterned name which is existing" |
|
28 cdpath=/dirstest |
|
29 unset cdpath |
|
30 ret=$? |
|
31 if [ $ret = 0 ] |
|
32 then |
|
33 if [ -z $cdpath ] |
|
34 then |
|
35 echo "PASS" |
|
36 let passno=passno+1 |
|
37 else |
|
38 echo "FAIL: Expected zero-length value, returned $cdpath" |
|
39 let failno=failno+1 |
|
40 fi |
|
41 else |
|
42 echo "FAIL: Expected return value 0, returned $ret" |
|
43 let failno=failno+1 |
|
44 fi |
|
45 } |
|
46 |
|
47 |
|
48 # Each named parameter is unset using -m option to unset an existing option |
|
49 test_unset3() |
|
50 { |
|
51 let totalno=totalno+1 |
|
52 echo "Test $totalno: unset command to unset with -m option to unset patterned name which is existing" |
|
53 cdpath=/dirstest |
|
54 unset -m cdpath |
|
55 ret=$? |
|
56 if [ $ret = 0 ] |
|
57 then |
|
58 if [ -z $cdpath ] |
|
59 then |
|
60 echo "PASS" |
|
61 let passno=passno+1 |
|
62 else |
|
63 echo "FAIL: Expected zero-length value, returned $cdpath" |
|
64 let failno=failno+1 |
|
65 fi |
|
66 else |
|
67 echo "FAIL: Expected return value 0, returned $ret" |
|
68 let failno=failno+1 |
|
69 fi |
|
70 } |
|
71 |
|
72 # Each named parameter is unset using -m option to unset an existing pattern in RESTRICTED mode |
|
73 test_unset4() |
|
74 { |
|
75 let totalno=totalno+1 |
|
76 echo "Test $totalno: unset command to unset with -m option to unset patterned name which is existing in RESTRICTED mode" |
|
77 cdpath=/dirstest |
|
78 setopt restricted |
|
79 unset -m cdpath |
|
80 ret=$? |
|
81 if [ $ret = 0 ] |
|
82 then |
|
83 if [ -z $cdpath ] |
|
84 then |
|
85 echo "PASS" |
|
86 let passno=passno+1 |
|
87 else |
|
88 echo "FAIL: Expected zero-length value, returned $cdpath" |
|
89 let failno=failno+1 |
|
90 fi |
|
91 else |
|
92 echo "FAIL: Expected return value 0, returned $ret" |
|
93 let failno=failno+1 |
|
94 fi |
|
95 } |
|
96 |
|
97 # Each named parameter is unset using -m option to unset an nonexisting pattern |
|
98 test_unset5() |
|
99 { |
|
100 let totalno=totalno+1 |
|
101 echo "Test $totalno: unset command to unset with -m option to unset patterned name which is nonexisting" |
|
102 unset -m sdfgsdfg |
|
103 ret=$? |
|
104 if [ $ret = 1 ] |
|
105 then |
|
106 echo "PASS" |
|
107 let passno=passno+1 |
|
108 else |
|
109 echo "FAIL: Expected return value 1, returned $ret" |
|
110 let failno=failno+1 |
|
111 fi |
|
112 } |
|
113 |
|
114 # Each named parameter is unset using no option to unset an invalid parameter name |
|
115 test_unset6() |
|
116 { |
|
117 let totalno=totalno+1 |
|
118 echo "Test $totalno: unset command to unset with no option to unset an invalid parameter name" |
|
119 unset [ |
|
120 ret=$? |
|
121 if [ $ret = 1 ] |
|
122 then |
|
123 echo "PASS" |
|
124 let passno=passno+1 |
|
125 else |
|
126 echo "FAIL: Expected return value 1, returned $ret" |
|
127 let failno=failno+1 |
|
128 fi |
|
129 } |
|
130 |
|
131 # A env variable name parameter is unset |
|
132 test_unset7() |
|
133 { |
|
134 let totalno=totalno+1 |
|
135 echo "Test $totalno: unset command to unset env variable parameter name" |
|
136 unset PATH |
|
137 ret=$? |
|
138 if [ $ret = 0 ] |
|
139 then |
|
140 echo "PASS" |
|
141 let passno=passno+1 |
|
142 else |
|
143 echo "FAIL: Expected return value 1, returned $ret" |
|
144 let failno=failno+1 |
|
145 fi |
|
146 } |
|
147 |
|
148 # A env variable name parameter is unset in restricted mode |
|
149 test_unset8() |
|
150 { |
|
151 let totalno=totalno+1 |
|
152 echo "Test $totalno: unset command to unset env variable parameter name in restricted mode" |
|
153 setopt restricted |
|
154 unset PATH |
|
155 ret=$? |
|
156 if [ $ret = 1 ] |
|
157 then |
|
158 echo "PASS" |
|
159 let passno=passno+1 |
|
160 else |
|
161 echo "FAIL: Expected return value 1, returned $ret" |
|
162 let failno=failno+1 |
|
163 fi |
|
164 } |
|
165 |
|
166 # Export a parameter and then unset it |
|
167 test_unset9() |
|
168 { |
|
169 let totalno=totalno+1 |
|
170 echo "Test $totalno: export a parameter and then unset it" |
|
171 export a=1234 |
|
172 unset a |
|
173 ret=$? |
|
174 |
|
175 if [ $ret = 0 ] |
|
176 then |
|
177 echo "PASS" |
|
178 let passno=passno+1 |
|
179 else |
|
180 echo "FAIL: Expected return value 1, returned $ret" |
|
181 let failno=failno+1 |
|
182 fi |
|
183 } |
|
184 |
|
185 report() |
|
186 { |
|
187 echo "#############################################################################" |
|
188 echo "Total tests : $totalno" |
|
189 echo "Passed : $passno" |
|
190 echo "Failed : $failno" |
|
191 echo "#############################################################################" |
|
192 } |
|
193 |
|
194 |
|
195 init |
|
196 test_unset2 |
|
197 test_unset3 |
|
198 # test_unset4 |
|
199 test_unset5 |
|
200 # test_unset6 |
|
201 test_unset7 |
|
202 # test_unset8 |
|
203 test_unset9 |
|
204 report |