openenvutils/commandshell/shell/test/scripts/unhashtest.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 # unhash command to try removing a nonexisting command from hash table
       
    24 test_unhash2()
       
    25 {
       
    26 let totalno=totalno+1
       
    27 echo "Test $totalno: unhash with no options and with a nonexisting hashtable entry"
       
    28 unhash dispdirs 
       
    29 ret=$?
       
    30 if [ $ret = 1 ]
       
    31 then
       
    32      {
       
    33      echo "PASS"
       
    34      let passno=passno+1
       
    35      }
       
    36 else
       
    37      {
       
    38      echo "FAIL: Expected return value 1, but  returned $ret"
       
    39      let failno=failno+1
       
    40      }
       
    41 fi
       
    42 }
       
    43 
       
    44 test_unhash3()
       
    45 {
       
    46 let totalno=totalno+1
       
    47 echo "Test $totalno: unhash with -d option and with a variable which is cdable"
       
    48 setopt cdablevars
       
    49 foo=/dirstest
       
    50 cd foo
       
    51 unhash -d foo
       
    52 ret=$?
       
    53 if [ $ret = 0 ]
       
    54 then
       
    55      {
       
    56      echo "PASS"
       
    57      let passno=passno+1
       
    58      }
       
    59      else
       
    60      {
       
    61      echo "FAIL: Expected return value 0, but  returned $ret"
       
    62      let failno=failno+1
       
    63      }
       
    64 fi
       
    65 unsetopt cdablevars
       
    66 }
       
    67 
       
    68 # unhash command to try removing a nonexisting command from hash table
       
    69 test_unhash4()
       
    70 {
       
    71 let totalno=totalno+1
       
    72 echo "Test $totalno: unhash with -m option and with a nonexisting hashtable entry pattern"
       
    73 unhash -m xdghsd
       
    74 ret=$?
       
    75 if [ $ret = 1 ]
       
    76 then
       
    77      {
       
    78      echo "PASS"
       
    79      let passno=passno+1
       
    80      }
       
    81 else
       
    82      {
       
    83      echo "FAIL: Expected return value 1, but  returned $ret"
       
    84      let failno=failno+1
       
    85      }
       
    86 fi
       
    87 }
       
    88 
       
    89 func1()
       
    90 {
       
    91 }
       
    92 
       
    93 # unhash command to try removing an existing patterned entries from hash table without using correct option -f alongside
       
    94 test_unhash5()
       
    95 {
       
    96 let totalno=totalno+1
       
    97 echo "Test $totalno: unhash with -m option and with an existing hashtable entry pattern for function"
       
    98 unhash -m func1
       
    99 ret=$?
       
   100 if [ $ret = 1 ]
       
   101 then
       
   102      {
       
   103      echo "PASS"
       
   104      let passno=passno+1
       
   105      }
       
   106 else
       
   107      {
       
   108      echo "FAIL: Expected return value 1, but  returned $ret"
       
   109      let failno=failno+1
       
   110      }
       
   111 fi
       
   112 }
       
   113 
       
   114 # unhash command to try removing an existing patterned entries from hash table with right option -f
       
   115 test_unhash6()
       
   116 {
       
   117 let totalno=totalno+1
       
   118 echo "Test $totalno: unhash with -mf option and with an existing hashtable entry pattern for function"
       
   119 unhash -mf func1
       
   120 ret=$?
       
   121 if [ $ret = 0 ]
       
   122 then
       
   123      {
       
   124      echo "PASS"
       
   125      let passno=passno+1
       
   126      }
       
   127 else
       
   128      {
       
   129      echo "FAIL: Expected return value 0, but  returned $ret"
       
   130      let failno=failno+1
       
   131      }
       
   132 fi
       
   133 }
       
   134 
       
   135 report()
       
   136     {
       
   137     echo "#############################################################################"
       
   138     echo "Total tests : $totalno"
       
   139     echo "Passed      : $passno"
       
   140     echo "Failed      : $failno"
       
   141     echo "#############################################################################"
       
   142     }
       
   143 
       
   144 init
       
   145 test_unhash2
       
   146 test_unhash3
       
   147 test_unhash4
       
   148 test_unhash5
       
   149 test_unhash6
       
   150 report