openenvutils/commandshell/shell/test/scripts/settest.sh
changeset 0 2e3d3ce01487
child 1 0fdb7f6b0309
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     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 
       
    24 test_set2()
       
    25 {
       
    26 let totalno=totalno+1
       
    27 echo "Test $totalno:"
       
    28 set -s q p r
       
    29 ret=$?
       
    30 if [ $ret = 0 ]
       
    31 then
       
    32     echo "PASS"
       
    33     let passno=passno+1
       
    34 else
       
    35     echo "FAIL: Expected 0, returned $ret"
       
    36     let failno=failno+1
       
    37 fi
       
    38 
       
    39 }
       
    40 
       
    41 test_set3()
       
    42 {
       
    43 let totalno=totalno+1
       
    44 echo "Test $totalno:"
       
    45 set +s x z c
       
    46 ret=$?
       
    47 if [ $ret = 0 ]
       
    48 then
       
    49     echo "PASS"
       
    50     let passno=passno+1
       
    51 else
       
    52     echo "FAIL: Expected 0, returned $ret"
       
    53     let failno=failno+1
       
    54 fi
       
    55 }
       
    56 
       
    57 test_set4()
       
    58 {
       
    59 let totalno=totalno+1
       
    60 echo "Test $totalno:"
       
    61 set -A array -x -- foo
       
    62 ret=$?
       
    63 if [ $ret = 0 ]
       
    64 then
       
    65     echo "PASS"
       
    66     let passno=passno+1
       
    67 else
       
    68     echo "FAIL: Expected 0, returned $ret"
       
    69     let failno=failno+1
       
    70 fi
       
    71 }
       
    72 
       
    73 test_set5()
       
    74 {
       
    75 let totalno=totalno+1
       
    76 echo "Test $totalno:"
       
    77 set -
       
    78 ret=$?
       
    79 if [ $ret = 0 ]
       
    80 then
       
    81     echo "PASS"
       
    82     let passno=passno+1
       
    83 else
       
    84     echo "FAIL: Expected 0, returned $ret"
       
    85     let failno=failno+1
       
    86 fi
       
    87 }
       
    88 
       
    89 
       
    90 test_set6()
       
    91 {
       
    92 let totalno=totalno+1
       
    93 echo "Test $totalno:"
       
    94 set --
       
    95 ret=$?
       
    96 if [ $ret = 0 ]
       
    97 then
       
    98     echo "PASS"
       
    99     let passno=passno+1
       
   100 else
       
   101     echo "FAIL: Expected 0, returned $ret"
       
   102     let failno=failno+1
       
   103 fi
       
   104 }
       
   105 
       
   106 test_set7()
       
   107 {
       
   108 let totalno=totalno+1
       
   109 echo "Test $totalno:"
       
   110 set -x
       
   111 ret=$?
       
   112 
       
   113 if [ $ret = 0 ]
       
   114 then
       
   115     echo "PASS"
       
   116     let passno=passno+1
       
   117 else
       
   118     echo "FAIL: Expected 0, returned $ret"
       
   119     let failno=failno+1
       
   120 fi
       
   121 }
       
   122 
       
   123 test_set8()
       
   124 {
       
   125 let totalno=totalno+1
       
   126 echo "Test $totalno:"
       
   127 set +x
       
   128 ret=$?
       
   129 if [ $ret = 0 ]
       
   130 then
       
   131     echo "PASS"
       
   132     let passno=passno+1
       
   133 else
       
   134     echo "FAIL: Expected 0, returned $ret"
       
   135     let failno=failno+1
       
   136 fi
       
   137 }
       
   138 
       
   139 test_set9()
       
   140 {
       
   141 let totalno=totalno+1
       
   142 echo "Test $totalno:"
       
   143 set +
       
   144 ret=$?
       
   145 if [ $ret = 0 ]
       
   146 then
       
   147     echo "PASS"
       
   148     let passno=passno+1
       
   149 else
       
   150     echo "FAIL: Expected 0, returned $ret"
       
   151     let failno=failno+1
       
   152 fi
       
   153 }
       
   154 
       
   155 test_set10()
       
   156 {
       
   157 let totalno=totalno+1
       
   158 echo "Test $totalno:"
       
   159 set +A array --
       
   160 ret=$?
       
   161 if [ $ret = 0 ]
       
   162 then
       
   163     echo "PASS"
       
   164     let passno=passno+1
       
   165 else
       
   166     echo "FAIL: Expected 0, returned $ret"
       
   167     let failno=failno+1
       
   168 fi
       
   169 }
       
   170 
       
   171 
       
   172 test_set11()
       
   173 {
       
   174 let totalno=totalno+1
       
   175 echo "Test $totalno:"
       
   176 set -A array --
       
   177 ret=$?
       
   178 if [ $ret = 0 ]
       
   179 then
       
   180     echo "PASS"
       
   181     let passno=passno+1
       
   182 else
       
   183     echo "FAIL: Expected 0, returned $ret"
       
   184     let failno=failno+1
       
   185 fi
       
   186 }
       
   187 
       
   188 test_set12()
       
   189 {
       
   190 let totalno=totalno+1
       
   191 echo "Test $totalno:"
       
   192 setopt ksh_arrays
       
   193 set -A array -x foo
       
   194 ret=$?
       
   195 if [ $ret = 0 ]
       
   196 then
       
   197     echo "PASS"
       
   198     let passno=passno+1
       
   199 else
       
   200     echo "FAIL: Expected 0, returned $ret"
       
   201     let failno=failno+1
       
   202 fi
       
   203 unsetopt ksh_arrays
       
   204 } 
       
   205 
       
   206 test_set13()
       
   207 {
       
   208 
       
   209 let totalno=totalno+1
       
   210 echo "Test $totalno:"
       
   211 setopt ksh_arrays
       
   212 set +A array -x foo
       
   213 ret=$?
       
   214 if [ $ret = 0 ]
       
   215 then
       
   216     echo "PASS"
       
   217     let passno=passno+1
       
   218 else
       
   219     echo "FAIL: Expected 0, returned $ret"
       
   220     let failno=failno+1
       
   221 fi
       
   222 unsetopt ksh_arrays
       
   223 }
       
   224 
       
   225 test_set14()
       
   226 {
       
   227 let totalno=totalno+1
       
   228 echo "Test $totalno:"
       
   229 
       
   230 setopt ksh_arrays
       
   231 set +A array -s a v c
       
   232 ret=$?
       
   233 if [ $ret = 0 ]
       
   234 then
       
   235     echo "PASS"
       
   236     let passno=passno+1
       
   237 else
       
   238     echo "FAIL: Expected 0, returned $ret"
       
   239     let failno=failno+1
       
   240 fi
       
   241 unsetopt ksh_arrays
       
   242 }
       
   243 
       
   244 test_set15()
       
   245 {
       
   246 let totalno=totalno+1
       
   247 echo "Test $totalno:"
       
   248 setopt ksh_arrays
       
   249 set +A array +s a v c
       
   250 ret=$?
       
   251 if [ $ret = 0 ]
       
   252 then
       
   253     echo "PASS"
       
   254     let passno=passno+1
       
   255 else
       
   256     echo "FAIL: Expected 0, returned $ret"
       
   257     let failno=failno+1
       
   258 fi
       
   259 unsetopt ksh_arrays
       
   260 }
       
   261 
       
   262 test_set16()
       
   263 {
       
   264 let totalno=totalno+1
       
   265 echo "Test $totalno:"
       
   266 setopt ksh_arrays
       
   267 set -A array +s a v c
       
   268 ret=$?
       
   269 if [ $ret = 0 ]
       
   270 then
       
   271     echo "PASS"
       
   272     let passno=passno+1
       
   273 else
       
   274     echo "FAIL: Expected 0, returned $ret"
       
   275     let failno=failno+1
       
   276 fi
       
   277 unsetopt ksh_arrays
       
   278 }
       
   279 
       
   280 # Set the options for the shell and/or set the positional parameters, or declare and set an array
       
   281 test_set17()
       
   282 {
       
   283 let totalno=totalno+1
       
   284 echo "Test $totalno: set command to set positional parameters"
       
   285 . ./util_set17.sh x y z
       
   286 ret=$?
       
   287 if [ $ret = 0 ]
       
   288 then
       
   289     echo "PASS"
       
   290     let passno=passno+1
       
   291 else
       
   292     echo "FAIL: Expected 0, returned $ret"
       
   293     let failno=failno+1
       
   294 fi
       
   295 }
       
   296 
       
   297 report()
       
   298     {
       
   299     echo "#############################################################################"
       
   300     echo "Total tests : $totalno"
       
   301     echo "Passed      : $passno"
       
   302     echo "Failed      : $failno"
       
   303     echo "#############################################################################"
       
   304     }
       
   305 
       
   306 init
       
   307 test_set2
       
   308 test_set3
       
   309 test_set4
       
   310 test_set5
       
   311 test_set6
       
   312 test_set7
       
   313 test_set8
       
   314 test_set9
       
   315 test_set10
       
   316 test_set11
       
   317 test_set12
       
   318 test_set13
       
   319 test_set14
       
   320 test_set15
       
   321 test_set16
       
   322 test_set17
       
   323 report