openenvutils/commandshell/shell/test/scripts/findtest2.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 total=0;
       
    19     let pass=0;
       
    20     let fail=0;
       
    21 
       
    22     if [ ! -d c:\\findtest ]
       
    23     then
       
    24 		mkdir c:\\findtest
       
    25     fi
       
    26 	cd c:\\findtest
       
    27 	cat "fddsfsduf  dsofisdf ndsljfs d" > test1.txt
       
    28 	cat "fddsfsduf  dsofdsfsdf  dfds
       
    29 	          dfsd isdf ndsljfs d" > test2.txt
       
    30 	cat "fddsfsduf " > test3.txt
       
    31 	if [ ! -d .\\test4 ]
       
    32 	then
       
    33 		mkdir .\\test4
       
    34 	fi
       
    35 	cd test4
       
    36 	cat "fddsfsduf  dsofisdf ndsljfs d" > test41.txt
       
    37 	cat "fddsfsduf  dsofdsfsdf  dfds
       
    38 	          dfsd isdf ndsljfs d" > test42.txt
       
    39 	cat "fddsfsduf " > test43.txt
       
    40 	cd
       
    41 	
       
    42 }
       
    43 report()
       
    44 {
       
    45     
       
    46     echo "Changing the directory back";
       
    47     echo "--------------------Find test results------------------------"
       
    48     echo " TOTAL TESTS : $total"
       
    49     echo " TOTAL PASS  : $pass"
       
    50     echo " TOTAL FAIL  : $fail"
       
    51     echo "------------------------------------------------------------"
       
    52 }
       
    53 test_find17()
       
    54 {
       
    55 	let total+=1;
       
    56 	echo "test_find17 :find with primaries ; find  ./test4/test41.txt -links 2 ";
       
    57 	find c:\\findtest\\test4\\test41.txt -links 2
       
    58 	ret=$?
       
    59 	if [ $ret -eq 0 ]
       
    60 	then
       
    61 		echo " PASS ";
       
    62 		let pass+=1;
       
    63 	else
       
    64 		echo "Fail"
       
    65 		echo "Expected 0 Returned $ret"
       
    66 		let fail+=1;
       
    67 	fi
       
    68 }
       
    69 test_find18()
       
    70 {
       
    71 	let total+=1;
       
    72 	echo "test_find18 :find with primaries ; find  ./test4 -ls  ";
       
    73 	find c:\\findtest\\test4 -ls
       
    74 	ret=$?
       
    75 	if [ $ret -eq 0 ]
       
    76 	then
       
    77 		echo " PASS ";
       
    78 		let pass+=1;
       
    79 	else
       
    80 		echo "Fail"
       
    81 		echo "Expected 0 Returned $ret"
       
    82 		let fail+=1;
       
    83 	fi
       
    84 }
       
    85 test_find19()
       
    86 {
       
    87 	let total+=1;
       
    88 	echo "test_find19 :find with primaries ; find  ./test4 -ls  ";
       
    89 	find c:\\findtest\\test4 -ls
       
    90 	ret=$?
       
    91 	if [ $ret -eq 0 ]
       
    92 	then
       
    93 		echo " PASS ";
       
    94 		let pass+=1;
       
    95 	else
       
    96 		echo "Fail"
       
    97 		echo "Expected 0 Returned $ret"
       
    98 		let fail+=1;
       
    99 	fi
       
   100 }
       
   101 test_find20()
       
   102 {
       
   103 	let total+=1;
       
   104 	echo "test_find20 :find with primaries ; find  . -maxdepth 1  ";
       
   105 	find . -maxdepth 1
       
   106 	ret=$?
       
   107 	if [ $ret -eq 0 ]
       
   108 	then
       
   109 		echo " PASS ";
       
   110 		let pass+=1;
       
   111 	else
       
   112 		echo "Fail"
       
   113 		echo "Expected 0 Returned $ret"
       
   114 		let fail+=1;
       
   115 	fi
       
   116 }
       
   117 
       
   118 test_find21()
       
   119 {
       
   120 	let total+=1;
       
   121 	echo "test_find21 :find with primaries ; find  . -mindepth 1  ";
       
   122 	find . -mindepth 1
       
   123 	ret=$?
       
   124 	if [ $ret -eq 0 ]
       
   125 	then
       
   126 		echo " PASS ";
       
   127 		let pass+=1;
       
   128 	else
       
   129 		echo "Fail"
       
   130 		echo "Expected 0 Returned $ret"
       
   131 		let fail+=1;
       
   132 	fi
       
   133 }
       
   134 test_find22()
       
   135 {
       
   136 	let total+=1;
       
   137 	echo "test_find22 :find with primaries ; find  ./test3.txt  -mtime 1  ";
       
   138 	find c:\\findtest\\test3.txt -mtime 1
       
   139 	ret=$?
       
   140 	if [ $ret -eq 0 ]
       
   141 	then
       
   142 		echo " PASS ";
       
   143 		let pass+=1;
       
   144 	else
       
   145 		echo "Fail"
       
   146 		echo "Expected 0 Returned $ret"
       
   147 		let fail+=1;
       
   148 	fi
       
   149 }
       
   150 test_find23()
       
   151 {
       
   152 	let total+=1;
       
   153 	echo "test_find23 :find with primaries ; find  ./test1.txt -atime 1";
       
   154 	find c:\\findtest\\test1.txt -atime 1
       
   155 	ret=$?
       
   156 	if [ $ret -eq 0 ]
       
   157 	then
       
   158 		echo " PASS ";
       
   159 		let pass+=1;
       
   160 	else
       
   161 		echo "Fail"
       
   162 		echo "Expected 0 Returned $ret"
       
   163 		let fail+=1;
       
   164 	fi
       
   165 }
       
   166 test_find24()
       
   167 {
       
   168 	let total+=1;
       
   169 	echo "test_find24 :find with primaries ; find  ./test4/  -name \"test4*\"  ";
       
   170 	find c:\\findtest\\test4\\ -name "test4*"
       
   171 	ret=$?
       
   172 	if [ $ret -eq 0 ]
       
   173 	then
       
   174 		echo " PASS ";
       
   175 		let pass+=1;
       
   176 	else
       
   177 		echo "Fail"
       
   178 		echo "Expected 0 Returned $ret"
       
   179 		let fail+=1;
       
   180 	fi
       
   181 }
       
   182 test_find25()
       
   183 {
       
   184 	let total+=1;
       
   185 	echo "test_find25 :find with primaries ; find  ./test3.txt  -newer test1.txt*  ";
       
   186 	find c:\\findtest\\test3.txt -newer c:\\findtest\\test1.txt
       
   187 	ret=$?
       
   188 	if [ $ret -eq 0 ]
       
   189 	then
       
   190 		echo " PASS ";
       
   191 		let pass+=1;
       
   192 	else
       
   193 		echo "Fail"
       
   194 		echo "Expected 0 Returned $ret"
       
   195 		let fail+=1;
       
   196 	fi
       
   197 }
       
   198 test_find26()
       
   199 {
       
   200 	let total+=1;
       
   201 	echo "test_find26 :find with primaries ; find  ./test4/  -path \"*\"  ";
       
   202 	find c:\\findtest\\test4\\ -path  "*"
       
   203 	ret=$?
       
   204 	if [ $ret -eq 0 ]
       
   205 	then
       
   206 		echo " PASS ";
       
   207 		let pass+=1;
       
   208 	else
       
   209 		echo "Fail"
       
   210 		echo "Expected 0 Returned $ret"
       
   211 		let fail+=1;
       
   212 	fi
       
   213 }
       
   214 test_find27()
       
   215 {
       
   216 	let total+=1;
       
   217 	echo "test_find27 :find with primaries ; find  ./test4/  -print  ";
       
   218 	#print is also a keyword in shell. what to do???
       
   219 	find c:\\findtest\\test4\\ "-print"
       
   220 	ret=$?
       
   221 	if [ $ret -eq 0 ]
       
   222 	then
       
   223 		echo " PASS ";
       
   224 		let pass+=1;
       
   225 	else
       
   226 		echo "Fail"
       
   227 		echo "Expected 0 Returned $ret"
       
   228 		let fail+=1;
       
   229 	fi
       
   230 }
       
   231 test_find28()
       
   232 {
       
   233 	let total+=1;
       
   234 	echo "test_find28 :find with primaries ; find  ./test4/  -print0  ";
       
   235 	find c:\\findtest\\test4\\ -print0
       
   236 	ret=$?
       
   237 	if [ $ret -eq 0 ]
       
   238 	then
       
   239 		echo " PASS ";
       
   240 		let pass+=1;
       
   241 	else
       
   242 		echo "Fail"
       
   243 		echo "Expected 0 Returned $ret"
       
   244 		let fail+=1;
       
   245 	fi
       
   246 }
       
   247 # not supported
       
   248 test_find29()
       
   249 {
       
   250 	let total+=1;
       
   251 	echo "test_find29 :find with primaries ; find  ./test4/  -printx  ";
       
   252 	find c:\\findtest\\test4\\ -printx
       
   253 	ret=$?
       
   254 	if [ $ret -eq 0 ]
       
   255 	then
       
   256 		echo " PASS ";
       
   257 		let pass+=1;
       
   258 	else
       
   259 		echo "Fail"
       
   260 		echo "Expected 0 Returned $ret"
       
   261 		let fail+=1;
       
   262 	fi
       
   263 }
       
   264 test_find30()
       
   265 {
       
   266 	let total+=1;
       
   267 	echo "test_find30 :find with primaries ; find  ./test4/  -prune  ";
       
   268 	find c:\\findtest\\test4\\ -prune
       
   269 	ret=$?
       
   270 	if [ $ret -eq 0 ]
       
   271 	then
       
   272 		echo " PASS ";
       
   273 		let pass+=1;
       
   274 	else
       
   275 		echo "Fail"
       
   276 		echo "Expected 0 Returned $ret"
       
   277 		let fail+=1;
       
   278 	fi
       
   279 }
       
   280 test_find31()
       
   281 {
       
   282 	let total+=1;
       
   283 	echo "test_find31 :find with primaries ; find  ./test3.txt  -size 4  ";
       
   284 	find c:\\findtest\\test3.txt -size 4
       
   285 	ret=$?
       
   286 	if [ $ret -eq 0 ]
       
   287 	then
       
   288 		echo " PASS ";
       
   289 		let pass+=1;
       
   290 	else
       
   291 		echo "Fail"
       
   292 		echo "Expected 0 Returned $ret"
       
   293 		let fail+=1;
       
   294 	fi
       
   295 }
       
   296 test_find32()
       
   297 {
       
   298 	let total+=1;
       
   299 	echo "test_find32 :find with primaries ; find  ./test3.txt -size 10c  ";
       
   300 	find c:\\findtest\\test3.txt -size 10c
       
   301 	ret=$?
       
   302 	if [ $ret -eq 0 ]
       
   303 	then
       
   304 		echo " PASS ";
       
   305 		let pass+=1;
       
   306 	else
       
   307 		echo "Fail"
       
   308 		echo "Expected 0 Returned $ret"
       
   309 		let fail+=1;
       
   310 	fi
       
   311 }
       
   312 init
       
   313 test_find17
       
   314 test_find18
       
   315 test_find19
       
   316 test_find20
       
   317 test_find21
       
   318 test_find22
       
   319 test_find23
       
   320 test_find24
       
   321 test_find25
       
   322 test_find26
       
   323 test_find27
       
   324 test_find28
       
   325 test_find29
       
   326 test_find30
       
   327 test_find31
       
   328 test_find32
       
   329 report