openenvutils/commandshell/shell/test/scripts/findtest1.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 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     echo "Changing the directory back";
       
    46     echo "--------------------Find test results------------------------"
       
    47     echo " TOTAL TESTS : $total"
       
    48     echo " TOTAL PASS  : $pass"
       
    49     echo " TOTAL FAIL  : $fail"
       
    50     echo "------------------------------------------------------------"
       
    51 }
       
    52 set +x
       
    53 test_find1()
       
    54 {
       
    55 	let total+=1;
       
    56 	echo "test_find1() :find without options; find";
       
    57 	find
       
    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_find15()
       
    70 {
       
    71 	let total+=1;
       
    72 	echo "test_find15() :find with invalid options; find -a";
       
    73 	find -a
       
    74 	ret=$?
       
    75 	if [ $ret -ne 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_find16()
       
    86 {
       
    87 	let total+=1;
       
    88 	echo "test_find16() :find with invalid arg; find ./test123.txt -type f";
       
    89 	find c:\\test123.txt -type f
       
    90 	ret=$?
       
    91 	if [ $ret -ne 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 #deprecated
       
   102 test_find2()
       
   103 {
       
   104 	let total+=1;
       
   105 	echo "test_find2 :find with valid option ; find  -d . ";
       
   106 	find -d .
       
   107 	ret=$?
       
   108 	if [ $ret -eq 0 ]
       
   109 	then
       
   110 		echo " PASS ";
       
   111 		let pass+=1;
       
   112 	else
       
   113 		echo "Fail"
       
   114 		echo "Expected 0 Returned $ret"
       
   115 		let fail+=1;
       
   116 	fi
       
   117 }
       
   118 test_find3()
       
   119 {
       
   120 	let total+=1;
       
   121 	echo "test_find3 :find with valid option ; find  -s . ";
       
   122 	find -s .
       
   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_find4()
       
   135 {
       
   136 	let total+=1;
       
   137 	echo "test_find4 :find with primaries ; find  ./test1.txt -amin 1 ";
       
   138 	find c:\\findtest\\test1.txt -amin 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_find5()
       
   151 {
       
   152 	let total+=1;
       
   153 	echo "test_find5 :find with primaries ; find  ./test1.txt -anewer test2.txt";
       
   154 	find c:\\findtest\\test1.txt  -anewer c:\\findtest\\test2.txt
       
   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 
       
   167 test_find6()
       
   168 {
       
   169 	let total+=1;
       
   170 	echo "test_find6 :find with primaries ; find  ./test2.txt -cmin 1";
       
   171 	find c:\\findtest\\test2.txt -cmin 1
       
   172 	ret=$?
       
   173 	if [ $ret -eq 0 ]
       
   174 	then
       
   175 		echo " PASS ";
       
   176 		let pass+=1;
       
   177 	else
       
   178 		echo "Fail"
       
   179 		echo "Expected 0 Returned $ret"
       
   180 		let fail+=1;
       
   181 	fi
       
   182 }
       
   183 test_find7()
       
   184 {
       
   185 	let total+=1;
       
   186 	echo "test_find7 :find with primaries ; find  ./test1.txt -cnewer test2.txt";
       
   187 	find c:\\findtest\\test1.txt -cnewer c:\\findtest\\test2.txt
       
   188 	ret=$?
       
   189 	if [ $ret -eq 0 ]
       
   190 	then
       
   191 		echo " PASS ";
       
   192 		let pass+=1;
       
   193 	else
       
   194 		echo "Fail"
       
   195 		echo "Expected 0 Returned $ret"
       
   196 		let fail+=1;
       
   197 	fi
       
   198 }
       
   199 test_find8()
       
   200 {
       
   201 	let total+=1;
       
   202 	echo "test_find8 :find with primaries ; find  ./test2.txt -ctime 1";
       
   203 	find c:\\findtest\\test2.txt -ctime 1
       
   204 	ret=$?
       
   205 	if [ $ret -eq 0 ]
       
   206 	then
       
   207 		echo " PASS ";
       
   208 		let pass+=1;
       
   209 	else
       
   210 		echo "Fail"
       
   211 		echo "Expected 0 Returned $ret"
       
   212 		let fail+=1;
       
   213 	fi
       
   214 }
       
   215 test_find9()
       
   216 {
       
   217 	let total+=1;
       
   218 	echo "test_find9 :find with primaries ; find  ./test2.txt -delete ";
       
   219 	find c:\\findtest\\test2.txt  -delete
       
   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_find10()
       
   232 {
       
   233 	let total+=1;
       
   234 	echo "test_find10 :find with primaries ; find  ./test4 -depth ";
       
   235 	find c:\\findtest\\test4 -depth
       
   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_find11()
       
   249 {
       
   250 	let total+=1;
       
   251 	echo "test_find11 :find with primaries ; find  ./test3.txt -depth 2";
       
   252 	find c:\\findtest\\test3.txt -depth 2
       
   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_find12()
       
   265 {
       
   266 	let total+=1;
       
   267 	echo "test_find12 :find with primaries ; find  ./test4 -empty";
       
   268 	find c:\\findtest\\test4 -empty
       
   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_find13()
       
   281 {
       
   282 	let total+=1;
       
   283 	echo "test_find13 :find with primaries ; find  . -execute ";
       
   284 	find . -execute
       
   285 	ret=$?
       
   286 	if [ $ret -ne 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_find14()
       
   297 {
       
   298 	let total+=1;
       
   299 	echo "test_find14 :find with primaries ; find  ./test4/test41 -iname \"test4*\" ";
       
   300 	find c:\\findtest\\test4\test41.txt -iname "test4*"
       
   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_find1
       
   314 #test_find2
       
   315 test_find3
       
   316 test_find4
       
   317 test_find5
       
   318 test_find6
       
   319 test_find7
       
   320 test_find8
       
   321 test_find9
       
   322 test_find10
       
   323 #test_find11
       
   324 test_find12
       
   325 test_find13
       
   326 test_find14
       
   327 test_find15
       
   328 test_find16
       
   329 report