openenvutils/commandshell/shell/test/scripts/dirstest.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 # Inititalise counters for Total tests, passes, fails.
       
    15 #
       
    16 
       
    17 preamble()
       
    18 	{
       
    19 	if [ ! -d TestDir ]
       
    20 	then
       
    21 		mkdir TestDir
       
    22 	fi
       
    23 	}
       
    24 
       
    25 init()
       
    26 	{
       
    27 	let totalno=0;
       
    28 	let passno=0;
       
    29 	let failno=0;
       
    30 	}
       
    31 
       
    32 
       
    33 #Test: Tests dirs with -v option
       
    34 test_dirs1()
       
    35 {
       
    36 	let totalno=totalno+1
       
    37 	echo "Test $totalno: dirs with -v option"
       
    38 	if [ -d TestDir ]
       
    39 	then
       
    40 		pushd TestDir
       
    41 		ret=$?
       
    42 		if [ $ret = 0 ]
       
    43 		then
       
    44 			dirs -v
       
    45 			ret=$?
       
    46 			if [ $ret = 0 ]
       
    47 			then
       
    48 				echo "PASS"
       
    49 				let passno=passno+1
       
    50 			else
       
    51 				echo "dirs failed with -v option"
       
    52 				echo "FAIL"
       
    53 				let failno=failno+1
       
    54 			fi 
       
    55 		else
       
    56 			echo "pushd failed with error $ret"
       
    57 			let failno=failno+1
       
    58 		fi
       
    59 	else
       
    60 		echo "TestDir is not created"
       
    61 		echo "FAIL"
       
    62 		let failno=failno+1 
       
    63 	fi
       
    64 	
       
    65 	popd
       
    66 }
       
    67 
       
    68 #Test: Delete the directory stack with -c option
       
    69 test_dirs2()
       
    70 {
       
    71 	let totalno=totalno+1
       
    72     echo "Test $totalno: Delete the directory stack with -c option"
       
    73 	
       
    74 	dirs -c
       
    75 	ret=$?
       
    76 	
       
    77 	if [ $ret = 0 ]
       
    78 	then
       
    79                 echo "PASS"
       
    80                 echo "directory stack deleted"
       
    81                 let passno=passno+1
       
    82             else
       
    83                 echo "dirs failed with -c option"
       
    84                 echo "FAIL"
       
    85                 let failno=failno+1
       
    86             fi		
       
    87 
       
    88 }
       
    89 
       
    90 
       
    91 #Test: Test dirs with -p and +n option
       
    92 test_dirs3()
       
    93 {
       
    94     let totalno=totalno+1
       
    95     echo "Test $totalno: Test dirs with -p and +n option"
       
    96 
       
    97     dirs -p 2
       
    98     ret=$?
       
    99 
       
   100     if [ $ret = 0 ]
       
   101     		then
       
   102                 echo "PASS"
       
   103                 let passno=passno+1
       
   104             else
       
   105                 echo "dirs failed with -p option"
       
   106                 echo "FAIL"
       
   107                 let failno=failno+1
       
   108             fi
       
   109 
       
   110 }
       
   111 
       
   112 #Test: Test dirs with -v and +n option
       
   113 test_dirs4()
       
   114 {
       
   115     let totalno=totalno+1
       
   116     echo "Test $totalno: Test dirs with -v and +n option"
       
   117 
       
   118     dirs -v 1
       
   119     ret=$?
       
   120 
       
   121     if [ $ret = 0 ]
       
   122     then
       
   123                 echo "PASS"
       
   124                 let passno=passno+1
       
   125             else
       
   126                 echo "dirs failed with -v and  option"
       
   127                 echo "FAIL"
       
   128                 let failno=failno+1
       
   129             fi
       
   130 
       
   131 }
       
   132 
       
   133 
       
   134 report()
       
   135 	{
       
   136 	echo "#############################################################################"
       
   137 	echo "Total tests : $totalno"
       
   138 	echo "Passed      : $passno"
       
   139 	echo "Failed      : $failno"
       
   140 	echo "#############################################################################"
       
   141 	}
       
   142 
       
   143 
       
   144 postamble()
       
   145 	{
       
   146 	rmdir TestDir 
       
   147 	}
       
   148 
       
   149 
       
   150 preamble
       
   151 init
       
   152 
       
   153  test_dirs1
       
   154  test_dirs2
       
   155  test_dirs3
       
   156  test_dirs4
       
   157 
       
   158 report
       
   159 postamble