openenvutils/commandshell/shell/test/scripts/exittest.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 # All tests exits the script/shell on success
       
    15 # So manually execute them
       
    16 #
       
    17 
       
    18 # Exits the shell script on success. Test whether a var is readonly or not after setting it as readonly.
       
    19 test_readonly1()
       
    20 {
       
    21 let totalno=totalno+1
       
    22 echo "Test $totalno: readonly function to make a variable not writeable"
       
    23 readonly r
       
    24 r=1
       
    25 res=$?
       
    26 if [ $res != 1 ]
       
    27 then
       
    28     echo "FAIL: Expected 1, returned $res"
       
    29     let failno=failno+1
       
    30 fi
       
    31 }
       
    32 
       
    33 
       
    34 test_exit1()
       
    35 {
       
    36 let totalno=totalno+1
       
    37 echo "Test $totalno: exit from shell"
       
    38 echo "This test makes you exit from the shel. Watch to check whether the shell exits or not."
       
    39 echo "The exit test result is not reported"
       
    40 echo "Do you want to test it?(y/n)"
       
    41 read var
       
    42 if [ $var = y ]
       
    43 then
       
    44     exit
       
    45 else
       
    46    echo "Try now"
       
    47 fi
       
    48 }
       
    49 
       
    50 util_exit2()
       
    51 {
       
    52 exit
       
    53 }
       
    54 
       
    55 # Exit from function
       
    56 test_exit2()
       
    57 {
       
    58 let totalno=totalno+1
       
    59 echo "Test $totalno: exit from function"
       
    60 util_exit2
       
    61 }
       
    62 
       
    63 
       
    64 # Exit when RCS is unset
       
    65 test_exit3()
       
    66 {
       
    67 let totalno=totalno+1
       
    68 echo "Test $totalno: exit from function"
       
    69 unsetopt RCS
       
    70 exit
       
    71 }
       
    72 
       
    73 # Exit when MONITOR is set
       
    74 test_exit4()
       
    75 {
       
    76 let totalno=totalno+1
       
    77 echo "Test $totalno: exit from function"
       
    78 setopt MONITOR
       
    79 exit
       
    80 }
       
    81 
       
    82 # Exit when MONITOR is unset
       
    83 test_exit4()
       
    84 {
       
    85 let totalno=totalno+1
       
    86 echo "Test $totalno: exit from function"
       
    87 unsetopt MONITOR
       
    88 exit
       
    89 }
       
    90 
       
    91 
       
    92 test_bye1()
       
    93 {
       
    94 let totalno=totalno+1
       
    95 echo "Test $totalno: bye from shell"
       
    96 echo "This test makes you exit from the shel. Watch to check whether the shell exits or not."
       
    97 echo "The bye test result is not reported"
       
    98 echo "Do you want to test it?(y/n)"
       
    99 read var
       
   100 if [ $var = y ]
       
   101 then
       
   102     exit
       
   103 else
       
   104    echo "Try now"
       
   105 fi
       
   106 }
       
   107 
       
   108 test_logout1()
       
   109 {
       
   110 let totalno=totalno+1
       
   111 echo "Test $totalno: logout from shell"
       
   112 echo "This test makes you exit from the shel. Watch to check whether the shell exits or not."
       
   113 echo "The logout test result is not reported"
       
   114 echo "Do you want to test it?(y/n)"
       
   115 read var
       
   116 if [ $var = y ]
       
   117 then
       
   118     exit
       
   119 else
       
   120    echo "Try now"
       
   121 fi
       
   122 }
       
   123 
       
   124 report()
       
   125     {
       
   126     echo "#############################################################################"
       
   127     echo "Total tests : $totalno"
       
   128     echo "Passed      : $passno"
       
   129     echo "Failed      : $failno"
       
   130     echo "#############################################################################"
       
   131     }
       
   132 
       
   133 test_exit1
       
   134 test_exit2
       
   135 test_bye1
       
   136 test_logout1
       
   137 test_readonly
       
   138 report
       
   139