openenvutils/commandshell/shell/test/scripts/fctest.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 # Test: to check the range of history mentioning option 'n'
       
    24 test_fc2()
       
    25 {
       
    26 let totalno=totalno+1
       
    27 echo "Test $totalno: To check the range of history mentioning option n"
       
    28 
       
    29 TestCmd=`fc -ln -1 -5`
       
    30 ret=$?
       
    31 echo "Return value is:$ret"
       
    32 
       
    33 if [ $ret = 0 ]
       
    34 then
       
    35     echo "PASS"
       
    36     let passno=passno+1
       
    37 else
       
    38     echo "FAIL"
       
    39     let failno=failno+1
       
    40 fi
       
    41 
       
    42 }
       
    43 
       
    44 
       
    45 #Test: To check the range of command history with strings
       
    46 test_fc3()
       
    47 {
       
    48 let totalno=totalno+1
       
    49 echo "Test $totalno: To check the command history with strings as options"
       
    50 
       
    51 #pwd
       
    52 #fc -l -1 -3
       
    53 TestCmd=`fc -l "pwd" "fc"`
       
    54 ret=$?
       
    55 
       
    56 echo "Return value is: $ret"
       
    57 
       
    58 if [ $ret = 1 ]
       
    59 then
       
    60 	echo "PASS"
       
    61 	let passno=passno+1
       
    62 else
       
    63 	echo "FAIL"
       
    64 	let failno=failno+1
       
    65 fi
       
    66 }
       
    67 
       
    68 #Test: fc prints command history in reverse order
       
    69 test_fc4()
       
    70 {
       
    71 let totalno=totalno+1
       
    72 echo "Test $totalno: fc prints the command history in reverse order"
       
    73 
       
    74 TestCmd=`fc -lr -1 -3`
       
    75 ret=$?
       
    76 
       
    77 if [ $ret = 0 ]
       
    78 then
       
    79 	echo "PASS"
       
    80 	let passno=passno+1
       
    81 else
       
    82 	echo "FAIL"
       
    83 	let failno=failno+1
       
    84 fi
       
    85 
       
    86 
       
    87 }
       
    88 
       
    89 
       
    90 #Test: fc prints command history matching the pattern entered
       
    91 test_fc5()
       
    92 {
       
    93 let totalno=totalno+1
       
    94 echo "Test $totalno: fc prints command history matching the patteen entered"
       
    95 
       
    96 TestCmd=`fc -lm "cd"`
       
    97 ret=$?
       
    98 
       
    99 if [ $ret = 0 ]
       
   100 then
       
   101 	echo "PASS"
       
   102 	let passno=passno+1
       
   103 else
       
   104 	echo "FAIL"
       
   105 	let failno=failno+1
       
   106 fi
       
   107 
       
   108 
       
   109 }
       
   110 
       
   111 #Test: fc prints command history with date time stamp in dd.mm.yyyy format
       
   112 test_fc6()
       
   113 {
       
   114 let totalno=totalno+1
       
   115 echo "Test $totalno: fc prints command history with date time stamp in dd.mm.yyyy format"
       
   116 
       
   117 TestCmd=`fc -ldfE -1 -7`
       
   118 ret=$?
       
   119 
       
   120 if [ $ret = 0 ]
       
   121 then
       
   122     echo "PASS"
       
   123     let passno=passno+1
       
   124 else
       
   125     echo "FAIL"
       
   126     let failno=failno+1
       
   127 fi
       
   128 
       
   129 
       
   130 }
       
   131 
       
   132 
       
   133 #Test: fc prints command history with date time stamp in yyyy-mm-dd format
       
   134 test_fc7()
       
   135 {
       
   136 let totalno=totalno+1
       
   137 echo "Test $totalno: fc prints command history with date time stamp in yyyy-mm-dd format"
       
   138 
       
   139 TestCmd=`fc -ldfi -1 -7`
       
   140 ret=$?
       
   141 
       
   142 if [ $ret = 0 ]
       
   143 then
       
   144     echo "PASS"
       
   145     let passno=passno+1
       
   146 else
       
   147     echo "FAIL"
       
   148     let failno=failno+1
       
   149 fi
       
   150 
       
   151 
       
   152 }
       
   153 
       
   154 #Test: fc prints command history with date time stamp in yyyy-mm-dd format along with elapsed time
       
   155 test_fc8()
       
   156 {
       
   157 let totalno=totalno+1
       
   158 echo "Test $totalno: fc prints command history with date time stamp in yyyy-mm-dd format along with elapsed time"
       
   159 
       
   160 TestCmd=`fc -ldfiD -1 -7`
       
   161 ret=$?
       
   162 
       
   163 if [ $ret = 0 ]
       
   164 then 
       
   165     echo "PASS"
       
   166     let passno=passno+1
       
   167 else
       
   168     echo "FAIL"
       
   169     let failno=failno+1
       
   170 fi
       
   171 
       
   172 
       
   173 }
       
   174 
       
   175 
       
   176 #Test: fc prints command history into a file
       
   177 test_fc9()
       
   178 {
       
   179 let totalno=totalno+1
       
   180 echo "Test $totalno: fc prints command history into a file"
       
   181 
       
   182 # Setting the command history to 5
       
   183 SAVEHIST=5			
       
   184 TestCmd=`fc -WI CmdHist.txt`
       
   185 ret=$?
       
   186 
       
   187 echo "TC returns $ret"
       
   188 if [ $ret = 0 ]
       
   189 then
       
   190 	echo "PASS"
       
   191 	let passno=passno+1
       
   192 else
       
   193 	echo "FAIL"
       
   194 	let failno=failno+1
       
   195 fi
       
   196 
       
   197 }
       
   198 
       
   199 #Test: fc prints command history into a file with repetition
       
   200 test_fc10()
       
   201 {
       
   202 let totalno=totalno+1
       
   203 echo "Test $totalno: fc prints command history into a file with repetition"
       
   204 
       
   205 # Setting the command history to 5
       
   206 SAVEHIST=5
       
   207 TestCmd=`fc -W CmdHist.txt`
       
   208 ret=$?
       
   209 
       
   210 echo "TC returns $ret"
       
   211 if [ $ret = 0 ]
       
   212 then
       
   213     echo "PASS"
       
   214     let passno=passno+1
       
   215 else
       
   216     echo "FAIL"
       
   217     let failno=failno+1
       
   218 fi
       
   219 
       
   220 }
       
   221 
       
   222 
       
   223 #Test: fc prints command history into a file in append mode
       
   224 test_fc11()
       
   225 {
       
   226 let totalno=totalno+1
       
   227 echo "Test $totalno: fc prints command history into a file in append mode"
       
   228 
       
   229 # Setting the command history to 5
       
   230 SAVEHIST=5
       
   231 TestCmd=`fc -AI CmdHist.txt`
       
   232 ret=$?
       
   233 
       
   234 echo "TC returns $ret"
       
   235 if [ $ret = 0  ]
       
   236 then
       
   237     echo "PASS"
       
   238     let passno=passno+1
       
   239 else
       
   240     echo "FAIL"
       
   241     let failno=failno+1
       
   242 fi
       
   243 
       
   244 }
       
   245 
       
   246 #Test: fc prints command history into a file in append mode with repetition
       
   247 test_fc12()
       
   248 {
       
   249 let totalno=totalno+1
       
   250 echo "Test $totalno: fc prints command history into a file in append mode with repetition"
       
   251 
       
   252 # Setting the command history to 5
       
   253 SAVEHIST=5
       
   254 TestCmd=`fc -A CmdHist.txt`
       
   255 ret=$?
       
   256 
       
   257 echo "TC returns $ret"
       
   258 if [ $ret = 0 ]
       
   259 then
       
   260     echo "PASS"
       
   261     let passno=passno+1
       
   262 else
       
   263     echo "FAIL"
       
   264     let failno=failno+1
       
   265 fi
       
   266 
       
   267 }
       
   268 
       
   269 #Test: fc reads command history from a file with repetition
       
   270 test_fc13()
       
   271 {
       
   272 let totalno=totalno+1
       
   273 echo "Test $totalno: fc reads command history from a file with repetition"
       
   274 
       
   275 # Setting the command history to 5
       
   276 SAVEHIST=5
       
   277 TestCmd=`fc -R CmdHist.txt`
       
   278 ret=$?
       
   279 
       
   280 echo "TC returns $ret"
       
   281 if [ $ret = 0 ]
       
   282 then
       
   283     echo "PASS"
       
   284     let passno=passno+1
       
   285 else
       
   286     echo "FAIL"
       
   287     let failno=failno+1
       
   288 fi
       
   289 
       
   290 }
       
   291 
       
   292 #Test: fc reads command history from a file without repetition 
       
   293 test_fc14()
       
   294 {
       
   295 let totalno=totalno+1
       
   296 echo "Test $totalno: fc reads command history from a file without repetition"
       
   297 
       
   298 # Setting the command history to 5
       
   299 SAVEHIST=5
       
   300 TestCmd=`fc -RI CmdHist.txt`
       
   301 ret=$?
       
   302 
       
   303 echo "TC returns $ret"
       
   304 if [ $ret = 0 ]
       
   305 then
       
   306     echo "PASS"
       
   307     let passno=passno+1
       
   308 else
       
   309     echo "FAIL"
       
   310     let failno=failno+1
       
   311 fi
       
   312 
       
   313 }
       
   314 
       
   315 #Test: fc returns 'Too many arguments' when P is given as option
       
   316 test_fc15()
       
   317 {
       
   318 let totalno=totalno+1
       
   319 echo "Test $totalno: fc returns 'Too many arguments' when P is given as option"
       
   320 
       
   321 TestCmd=`fc -lP -1 -5`
       
   322 ret=$?
       
   323 
       
   324 echo "TC returns $ret"
       
   325 if [ $ret = 1 ]
       
   326 then
       
   327     echo "PASS"
       
   328     let passno=passno+1
       
   329 else
       
   330     echo "FAIL"
       
   331     let failno=failno+1
       
   332 fi
       
   333 
       
   334 }
       
   335 
       
   336 #Test: fc returns 'bad option' on supplying invalid option
       
   337 test_fc16()
       
   338 {
       
   339 let totalno=totalno+1
       
   340 echo "Test $totalno: fc returns 'bad option' on supplying invalid option"
       
   341 
       
   342 TestCmd=`fc -lX -1 -5`
       
   343 ret=$?
       
   344 
       
   345 echo "TC returns $ret"
       
   346 if [ $ret = 0 ]
       
   347 then
       
   348  	echo "FAIL"	
       
   349     let failno=failno+1
       
   350 else
       
   351 	echo "PASS"
       
   352     let passno=passno+1
       
   353 fi
       
   354 
       
   355 }
       
   356 
       
   357 #Test: fc with -p option. This TC is for coverage improvement
       
   358 test_fc17()
       
   359 {
       
   360 let totalno=totalno+1
       
   361 echo "Test $totalno: fc with -p option. This TC is for coverage improvement"
       
   362 
       
   363 TestCmd=`fc -lp -1 -5`
       
   364 ret=$?
       
   365 
       
   366 echo "TC returns $ret"
       
   367 if [ $ret = 0 ]
       
   368 then
       
   369     echo "PASS"
       
   370     let passno=passno+1
       
   371 else
       
   372     echo "FAIL"
       
   373     let failno=failno+1
       
   374 fi
       
   375 
       
   376 }
       
   377 
       
   378 #Test: Try reading command history from a non existing file 
       
   379 test_fc18()
       
   380 {
       
   381 let totalno=totalno+1
       
   382 echo "Test $totalno: Try reading command history from a non existing file"
       
   383 
       
   384 TestCmd=`fc -R NoFile.txt`
       
   385 ret=$?
       
   386 
       
   387 echo "TC returns $ret"
       
   388 if [ $ret = 0 ]
       
   389 then
       
   390     echo "PASS"
       
   391     let passno=passno+1
       
   392 else
       
   393     echo "FAIL"
       
   394     let failno=failno+1
       
   395 fi
       
   396 
       
   397 }
       
   398 
       
   399 postamble()
       
   400 	{
       
   401 	rm CmdHist.txt
       
   402 	}
       
   403 
       
   404 
       
   405 report()
       
   406 	{
       
   407 	echo "---------------------------------------------------------"
       
   408 	echo "Total tests	: $totalno"
       
   409 	echo "Passed tests	: $passno"
       
   410 	echo "Failed tests	: $failno"
       
   411 	echo "---------------------------------------------------------"
       
   412 	}
       
   413 
       
   414 init
       
   415 test_fc2
       
   416 # test_fc3
       
   417  test_fc4   
       
   418  test_fc5
       
   419 test_fc6
       
   420 test_fc7
       
   421 test_fc8
       
   422  test_fc9
       
   423  test_fc10
       
   424  test_fc11
       
   425  test_fc12
       
   426  test_fc13
       
   427  test_fc14
       
   428  test_fc15  #Defect No 44 raised  
       
   429  test_fc16  #Defect No 44 raised
       
   430  test_fc17  #Defect No 43 raised
       
   431 #  test_fc18  #Defect No 44 raised
       
   432 report
       
   433 postamble