openenvutils/commandshell/shell/test/scripts/setopttest.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 # Set the autocd option for the shell, so that simply typing the dir name will cd to that dir
       
    24 test_setopt1()
       
    25 {
       
    26 let totalno=totalno+1
       
    27 echo "Test $totalno: setopt to automatically cd to a directory without requiring you to type cd"
       
    28 if [ -d cdtest ]
       
    29 then
       
    30      oldcwd=`pwd`
       
    31      setopt auto_cd
       
    32      cdtest
       
    33      ret=$?
       
    34      if [ $ret = 0 ]
       
    35      then
       
    36          if [ $PWD = ${oldcwd}/cdtest ]
       
    37          then
       
    38              echo "PASS"
       
    39              let passno=passno+1
       
    40          else
       
    41              echo "FAIL: Expected \"$PWD\", returned \"${oldcwd}/cdtest\""
       
    42              let failno=failno+1
       
    43              return
       
    44          fi
       
    45          cd ..
       
    46      else
       
    47          echo "FAIL: Expected return value 0, but  returned $ret"
       
    48          let failno=failno+1
       
    49          return
       
    50      fi
       
    51      unsetopt auto_cd
       
    52 else
       
    53      echo "FAIL:cdtest dir missing"
       
    54      let failno=failno+1
       
    55 fi
       
    56 }
       
    57 
       
    58 
       
    59 test_nobeep1()
       
    60 {
       
    61 let totalno=totalno+1
       
    62 echo "Test $totalno: setopt nobeep"
       
    63 setopt nobeep              # i hate beeps
       
    64 ret=$?
       
    65 if [ $ret = 0 ]
       
    66 then
       
    67     echo "PASS"
       
    68     let passno=passno+1
       
    69     unsetopt nobeep
       
    70 else
       
    71     echo "FAIL: Expected 0, returned $ret"
       
    72     let failno=failno+1
       
    73 fi
       
    74 }
       
    75 
       
    76 test_noautomenu1()
       
    77 {
       
    78 let totalno=totalno+1
       
    79 echo "Test $totalno: setopt noautomenu"
       
    80 setopt noautomenu          # don't cycle completions
       
    81 ret=$?
       
    82 if [ $ret = 0 ]
       
    83 then
       
    84     echo "PASS"
       
    85     let passno=passno+1
       
    86     unsetopt noautomenu
       
    87 else
       
    88     echo "FAIL: Expected 0, returned $ret"
       
    89     let failno=failno+1
       
    90 fi
       
    91 }
       
    92 
       
    93 test_autopushd1()
       
    94 {
       
    95 let totalno=totalno+1
       
    96 echo "Test $totalno: setopt autopushd"
       
    97 setopt autopushd           # automatically append dirs to the push/pop list
       
    98 ret=$?
       
    99 if [ $ret = 0 ]
       
   100 then
       
   101     echo "PASS"
       
   102     let passno=passno+1
       
   103     unsetopt autopushd
       
   104 else
       
   105     echo "FAIL: Expected 0, returned $ret"
       
   106     let failno=failno+1
       
   107 fi
       
   108 }
       
   109 
       
   110 test_pushdignoredups1()
       
   111 {
       
   112 let totalno=totalno+1
       
   113 echo "Test $totalno: setopt pushdignoredups"
       
   114 setopt pushdignoredups     # and don't duplicate them
       
   115 ret=$?
       
   116 if [ $ret = 0 ]
       
   117 then
       
   118     echo "PASS"
       
   119     let passno=passno+1
       
   120     unsetopt pushdignoredups
       
   121 else
       
   122     echo "FAIL: Expected 0, returned $ret"
       
   123     let failno=failno+1
       
   124 fi
       
   125 }
       
   126 
       
   127 test_checkjobs1()
       
   128 {
       
   129 let totalno=totalno+1
       
   130 echo "Test $totalno: setopt checkjobs"
       
   131 setopt checkjobs           # warn me about bg processes when exiting
       
   132 ret=$?
       
   133 if [ $ret = 0 ]
       
   134 then
       
   135     echo "PASS"
       
   136     let passno=passno+1
       
   137     unsetopt checkjobs
       
   138 else
       
   139     echo "FAIL: Expected 0, returned $ret"
       
   140     let failno=failno+1
       
   141 fi
       
   142 }
       
   143 
       
   144 test_nohup1()
       
   145 {
       
   146 let totalno=totalno+1
       
   147 echo "Test $totalno: setopt nohup"
       
   148 setopt nohup               # and don't kill them, either
       
   149 ret=$?
       
   150 if [ $ret = 0 ]
       
   151 then
       
   152     echo "PASS"
       
   153     let passno=passno+1
       
   154     unsetopt nohup
       
   155 else
       
   156     echo "FAIL: Expected 0, returned $ret"
       
   157     let failno=failno+1
       
   158 fi
       
   159 }
       
   160 
       
   161 test_listpacked1()
       
   162 {
       
   163 let totalno=totalno+1
       
   164 echo "Test $totalno: setopt listpacked"
       
   165 setopt listpacked          # compact completion lists
       
   166 ret=$?
       
   167 if [ $ret = 0 ]
       
   168 then
       
   169     echo "PASS"
       
   170     let passno=passno+1
       
   171     unsetopt listpacked
       
   172 else
       
   173     echo "FAIL: Expected 0, returned $ret"
       
   174     let failno=failno+1
       
   175 fi
       
   176 }
       
   177 
       
   178 test_listtypes1()
       
   179 {
       
   180 let totalno=totalno+1
       
   181 echo "Test $totalno: setopt listtypes"
       
   182 setopt listtypes           # show types in completion
       
   183 ret=$?
       
   184 if [ $ret = 0 ]
       
   185 then
       
   186     echo "PASS"
       
   187     let passno=passno+1
       
   188     unsetopt listtypes
       
   189 else
       
   190     echo "FAIL: Expected 0, returned $ret"
       
   191     let failno=failno+1
       
   192 fi
       
   193 }
       
   194 
       
   195 test_completeinword1()
       
   196 {
       
   197 let totalno=totalno+1
       
   198 echo "Test $totalno: setopt completeinword"
       
   199 setopt completeinword      # not just at the end
       
   200 ret=$?
       
   201 if [ $ret = 0 ]
       
   202 then
       
   203     echo "PASS"
       
   204     let passno=passno+1
       
   205     unsetopt completeinword
       
   206 else
       
   207     echo "FAIL: Expected 0, returned $ret"
       
   208     let failno=failno+1
       
   209 fi
       
   210 }
       
   211 
       
   212 test_alwaystoend1()
       
   213 {
       
   214 let totalno=totalno+1
       
   215 echo "Test $totalno: setopt alwaystoend"
       
   216 setopt alwaystoend         # when complete from middle, move cursor
       
   217 ret=$?
       
   218 if [ $ret = 0 ]
       
   219 then
       
   220     echo "PASS"
       
   221     let passno=passno+1
       
   222     unsetopt alwaystoend
       
   223 else
       
   224     echo "FAIL: Expected 0, returned $ret"
       
   225     let failno=failno+1
       
   226 fi
       
   227 }
       
   228 
       
   229 test_correct1()
       
   230 {
       
   231 let totalno=totalno+1
       
   232 echo "Test $totalno: setopt correct"
       
   233 setopt correct             # spelling correction
       
   234 ret=$?
       
   235 if [ $ret = 0 ]
       
   236 then
       
   237     echo "PASS"
       
   238     let passno=passno+1
       
   239     unsetopt correct
       
   240 else
       
   241     echo "FAIL: Expected 0, returned $ret"
       
   242     let failno=failno+1
       
   243 fi
       
   244 }
       
   245 
       
   246 test_nopromptcr1()
       
   247 {
       
   248 let totalno=totalno+1
       
   249 echo "Test $totalno: setopt nopromptcr"
       
   250 setopt nopromptcr          # don't add \r which overwrites cmd output with no \n
       
   251 ret=$?
       
   252 if [ $ret = 0 ]
       
   253 then
       
   254     echo "PASS"
       
   255     let passno=passno+1
       
   256     unsetopt nopromptcr
       
   257 else
       
   258     echo "FAIL: Expected 0, returned $ret"
       
   259     let failno=failno+1
       
   260 fi
       
   261 }
       
   262 
       
   263 test_histverify1()
       
   264 {
       
   265 let totalno=totalno+1
       
   266 echo "Test $totalno: setopt histverify"
       
   267 setopt histverify          # when using ! cmds, confirm first
       
   268 ret=$?
       
   269 if [ $ret = 0 ]
       
   270 then
       
   271     echo "PASS"
       
   272     let passno=passno+1
       
   273     unsetopt histverify
       
   274 else
       
   275     echo "FAIL: Expected 0, returned $ret"
       
   276     let failno=failno+1
       
   277 fi
       
   278 }
       
   279 
       
   280 test_interactivecomments1()
       
   281 {
       
   282 let totalno=totalno+1
       
   283 echo "Test $totalno: setopt interactivecomments"
       
   284 setopt interactivecomments # escape commands so i can use them later
       
   285 ret=$?
       
   286 if [ $ret = 0 ]
       
   287 then
       
   288     echo "PASS"
       
   289     let passno=passno+1
       
   290     unsetopt interactivecomments
       
   291 else
       
   292     echo "FAIL: Expected 0, returned $ret"
       
   293     let failno=failno+1
       
   294 fi
       
   295 }
       
   296 
       
   297 test_recexact1()
       
   298 {
       
   299 let totalno=totalno+1
       
   300 echo "Test $totalno: setopt recexact"
       
   301 setopt recexact            # recognise exact, ambiguous matches
       
   302 ret=$?
       
   303 if [ $ret = 0 ]
       
   304 then
       
   305     echo "PASS"
       
   306     let passno=passno+1
       
   307     unsetopt recexact
       
   308 else
       
   309     echo "FAIL: Expected 0, returned $ret"
       
   310     let failno=failno+1
       
   311 fi
       
   312 }
       
   313 
       
   314 test_printexitvalue1()
       
   315 {
       
   316 let totalno=totalno+1
       
   317 echo "Test $totalno: setopt printexitvalue"
       
   318 setopt printexitvalue      # alert me if something's failed
       
   319 ret=$?
       
   320 if [ $ret = 0 ]
       
   321 then
       
   322     echo "PASS"
       
   323     let passno=passno+1
       
   324     unsetopt printexitvalue
       
   325 else
       
   326     echo "FAIL: Expected 0, returned $ret"
       
   327     let failno=failno+1
       
   328 fi
       
   329 }
       
   330 
       
   331 test_glob1()
       
   332 {
       
   333 let totalno=totalno+1
       
   334 echo "Test $totalno: setopt glob"
       
   335 setopt glob                # globbing support
       
   336 ret=$?
       
   337 if [ $ret = 0 ]
       
   338 then
       
   339     echo "PASS"
       
   340     let passno=passno+1
       
   341     unsetopt glob
       
   342 else
       
   343     echo "FAIL: Expected 0, returned $ret"
       
   344     let failno=failno+1
       
   345 fi
       
   346 }
       
   347 
       
   348 test_extendedglob1()
       
   349 {
       
   350 let totalno=totalno+1
       
   351 echo "Test $totalno: setopt extendedglob"
       
   352 setopt extendedglob        # blah blah
       
   353 ret=$?
       
   354 if [ $ret = 0 ]
       
   355 then
       
   356     echo "PASS"
       
   357     let passno=passno+1
       
   358     unsetopt extendedglob
       
   359 else
       
   360     echo "FAIL: Expected 0, returned $ret"
       
   361     let failno=failno+1
       
   362 fi
       
   363 }
       
   364 
       
   365 test_nonomatch1()
       
   366 {
       
   367 let totalno=totalno+1
       
   368 echo "Test $totalno: setopt nonomatch"
       
   369 setopt nonomatch           # pass through any unrecognized patterns to the command
       
   370 ret=$?
       
   371 if [ $ret = 0 ]
       
   372 then
       
   373     {
       
   374     echo "PASS"
       
   375     let passno=passno+1
       
   376     unsetopt nonomatch
       
   377     }
       
   378 else
       
   379     {
       
   380     echo "FAIL: Expected 0, returned $ret"
       
   381     let failno=failno+1
       
   382     }
       
   383 fi
       
   384 }
       
   385 
       
   386 report()
       
   387     {
       
   388     echo "#############################################################################"
       
   389     echo "Total tests : $totalno"
       
   390     echo "Passed      : $passno"
       
   391     echo "Failed      : $failno"
       
   392     echo "#############################################################################"
       
   393     }
       
   394 
       
   395 init
       
   396 
       
   397 # test_setopt1
       
   398 test_nobeep1
       
   399 test_noautomenu1
       
   400 test_autopushd1
       
   401 test_pushdignoredups1
       
   402 test_checkjobs1
       
   403 test_nohup1
       
   404 test_listpacked1
       
   405 test_listtypes1
       
   406 test_completeinword1
       
   407 test_alwaystoend1
       
   408 test_correct1
       
   409 test_nopromptcr1
       
   410 test_histverify1
       
   411 test_interactivecomments1
       
   412 test_recexact1
       
   413 test_printexitvalue1
       
   414 test_glob1
       
   415 test_extendedglob1
       
   416 test_nonomatch1
       
   417 report