openenvutils/commandshell/shell/test/scripts/greptest2.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:\\greptest ]
       
    23     then
       
    24 		mkdir c:\\greptest	
       
    25     fi
       
    26 	cd c:\\greptest
       
    27 	cat "Hello.
       
    28 		hi his
       
    29 		hi
       
    30 		Testing for the grep command." > test1.txt
       
    31 	cat "fddsfsduf  dsofdsfsdf  dfds
       
    32 	          dfsd isdf ndsljfs d" > test2.txt
       
    33 	cat "fddsfsduf " > test3.txt
       
    34 	if [ ! -d .\\test4 ] 
       
    35 	then 
       
    36 		mkdir .\\test4
       
    37 	fi
       
    38 	cd .\\test4
       
    39 	cat "Hello.
       
    40 		hi his
       
    41 		hi
       
    42 		Testing for the grep command." > test41.txt
       
    43 	cat "fddsfsduf  dsofdsfsdf  dfds
       
    44 	          dfsd isdf ndsljfs d" > test42.txt
       
    45 	cat "fddsfsduf " > test43.txt
       
    46 	cd 
       
    47 	
       
    48 }
       
    49 report()
       
    50 {
       
    51     echo "Changing the directory back";
       
    52     echo "--------------------Grep test results------------------------"
       
    53     echo " TOTAL TESTS : $total"
       
    54     echo " TOTAL PASS  : $pass"
       
    55     echo " TOTAL FAIL  : $fail"
       
    56     echo "------------------------------------------------------------"
       
    57 }
       
    58 test_grep17()
       
    59 {
       
    60 	echo " test_grep17 : grep with valid args; grep -m 0 \"hi\" test1.txt ";
       
    61 	let total+=1;
       
    62 	grep -m 0 "hi" c:\\greptest\\test1.txt 
       
    63 	ret=$?
       
    64 	if [ $ret -ne 0 ]
       
    65 	then
       
    66 		echo "PASS";
       
    67 		let pass+=1;
       
    68 	else
       
    69 		echo "FAIL"
       
    70 		echo "Expected 1 Returned $ret"
       
    71 		let fail+=1;
       
    72 	fi
       
    73 }
       
    74 test_grep18()
       
    75 {
       
    76 	echo " test_grep18 : grep with valid args; grep --mmap \"hi\" test1.txt ";
       
    77 	let total+=1;
       
    78 	grep --mmap "hi" c:\\greptest\\test1.txt 
       
    79 	ret=$?
       
    80 	if [ $ret -eq 0 ]
       
    81 	then
       
    82 		echo "PASS";
       
    83 		let pass+=1;
       
    84 	else
       
    85 		echo "FAIL"
       
    86 		echo "Expected 1 Returned $ret"
       
    87 		let fail+=1;
       
    88 	fi
       
    89 }
       
    90 test_grep19()
       
    91 {
       
    92 	echo " test_grep19 : grep with valid args; grep -n \"hi\" test1.txt ";
       
    93 	let total+=1;
       
    94 	grep -n "hi" c:\\greptest\\test1.txt 
       
    95 	ret=$?
       
    96 	if [ $ret -eq 0 ]
       
    97 	then
       
    98 		echo "PASS";
       
    99 		let pass+=1;
       
   100 	else
       
   101 		echo "FAIL"
       
   102 		echo "Expected 1 Returned $ret"
       
   103 		let fail+=1;
       
   104 	fi
       
   105 }
       
   106 test_grep20()
       
   107 {
       
   108 	echo " test_grep20 : grep with valid args; grep -o \"hi\" test1.txt ";
       
   109 	let total+=1;
       
   110 	grep -o "hi" c:\\greptest\\test1.txt 
       
   111 	ret=$?
       
   112 	if [ $ret -eq 0 ]
       
   113 	then
       
   114 		echo "PASS";
       
   115 		let pass+=1;
       
   116 	else
       
   117 		echo "FAIL"
       
   118 		echo "Expected 1 Returned $ret"
       
   119 		let fail+=1;
       
   120 	fi
       
   121 }
       
   122 test_grep21()
       
   123 {
       
   124 	echo " test_grep21 : grep with valid args; grep -q \"hi\" test1.txt ";
       
   125 	let total+=1;
       
   126 	grep -q "hi" c:\\greptest\\test1.txt 
       
   127 	ret=$?
       
   128 	if [ $ret -eq 0 ]
       
   129 	then
       
   130 		echo "PASS";
       
   131 		let pass+=1;
       
   132 	else
       
   133 		echo "FAIL"
       
   134 		echo "Expected 1 Returned $ret"
       
   135 		let fail+=1;
       
   136 	fi
       
   137 }
       
   138 test_grep22()
       
   139 {
       
   140 	echo " test_grep22 : grep with valid args; grep -s \"hi\" test1.txt ";
       
   141 	let total+=1;
       
   142 	grep -s "hi" c:\\greptest\\test1.txt 
       
   143 	ret=$?
       
   144 	if [ $ret -eq 0 ]
       
   145 	then
       
   146 		echo "PASS";
       
   147 		let pass+=1;
       
   148 	else
       
   149 		echo "FAIL"
       
   150 		echo "Expected 1 Returned $ret"
       
   151 		let fail+=1;
       
   152 	fi
       
   153 }
       
   154 test_grep23()
       
   155 {
       
   156 	echo " test_grep23 : grep with valid args; grep -r \"hi\" ./test4 ";
       
   157 	let total+=1;
       
   158 	grep -r "hi" c:\\greptest\\test4 
       
   159 	ret=$?
       
   160 	if [ $ret -eq 0 ]
       
   161 	then
       
   162 		echo "PASS";
       
   163 		let pass+=1;
       
   164 	else
       
   165 		echo "FAIL"
       
   166 		echo "Expected 1 Returned $ret"
       
   167 		let fail+=1;
       
   168 	fi
       
   169 }
       
   170 test_grep24()
       
   171 {
       
   172 	echo " test_grep24 : grep with valid args; grep -w \"h\" test1.txt ";
       
   173 	let total+=1;
       
   174 	grep -w "h" c:\\greptest\\test1.txt 
       
   175 	ret=$?
       
   176 	if [ $ret -eq 1 ]
       
   177 	then
       
   178 		echo "PASS";
       
   179 		let pass+=1;
       
   180 	else
       
   181 		echo "FAIL"
       
   182 		echo "Expected 1 Returned $ret"
       
   183 		let fail+=1;
       
   184 	fi
       
   185 }
       
   186 test_grep25()
       
   187 {
       
   188 	echo " test_grep25 : grep with valid args; grep -cv "hi" test1.txt ";
       
   189 	let total+=1;
       
   190 	grep -cv "hi" c:\\greptest\\test1.txt 
       
   191 	ret=$?
       
   192 	if [ $ret -eq 0 ]
       
   193 	then
       
   194 		echo "PASS";
       
   195 		let pass+=1;
       
   196 	else
       
   197 		echo "FAIL"
       
   198 		echo "Expected 1 Returned $ret"
       
   199 		let fail+=1;
       
   200 	fi
       
   201 }
       
   202 test_grep26()
       
   203 {
       
   204 	echo " test_grep26 : grep with valid args; grep -ov "hi" test1.txt ";
       
   205 	let total+=1;
       
   206 	grep -ov "hi" c:\\greptest\\test1.txt 
       
   207 	ret=$?
       
   208 	if [ $ret -eq 0 ]
       
   209 	then
       
   210 		echo "PASS";
       
   211 		let pass+=1;
       
   212 	else
       
   213 		echo "FAIL"
       
   214 		echo "Expected 1 Returned $ret"
       
   215 		let fail+=1;
       
   216 	fi
       
   217 }
       
   218 test_grep27()
       
   219 {
       
   220 	echo " test_grep27 : grep with valid args; grep -x \"hi\" test1.txt ";
       
   221 	let total+=1;
       
   222 	grep -x "hi" c:\\greptest\\test1.txt 
       
   223 	ret=$?
       
   224 	if [ $ret -eq 1 ]
       
   225 	then
       
   226 		echo "PASS";
       
   227 		let pass+=1;
       
   228 	else
       
   229 		echo "FAIL"
       
   230 		echo "Expected 1 Returned $ret"
       
   231 		let fail+=1;
       
   232 	fi
       
   233 }
       
   234 test_grep28()
       
   235 {
       
   236 	echo " test_grep28 : grep with valid args; grep -a "hi" test1.txt ";
       
   237 	let total+=1;
       
   238 	grep -a "hi" c:\\greptest\\test1.txt 
       
   239 	ret=$?
       
   240 	if [ $ret -eq 0 ]
       
   241 	then
       
   242 		echo "PASS";
       
   243 		let pass+=1;
       
   244 	else
       
   245 		echo "FAIL"
       
   246 		echo "Expected 1 Returned $ret"
       
   247 		let fail+=1;
       
   248 	fi
       
   249 }
       
   250 
       
   251 #begin making calls
       
   252 
       
   253 init
       
   254 test_grep17
       
   255 test_grep18
       
   256 test_grep19
       
   257 test_grep20
       
   258 test_grep21
       
   259 test_grep22
       
   260 test_grep23
       
   261 test_grep24
       
   262 test_grep25
       
   263 #test_grep26
       
   264 test_grep27
       
   265 test_grep28
       
   266 report