openenvutils/commandshell/shell/test/scripts/miniziptest.sh
changeset 0 2e3d3ce01487
child 4 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:\\ziptest ]
       
    23 	then
       
    24 		rm -r c:\\ziptest
       
    25 	fi
       
    26 	mkdir c:\\ziptest
       
    27 	cd c:\\ziptest
       
    28 	echo "Change directory to ziptest"	
       
    29 	echo "kjhdlaskdjsd dsakjdas
       
    30 	sajdkaksjdasd
       
    31 	sdklsjdasds" > abc.txt
       
    32 	echo "dsdfdsfds
       
    33 	dfsdfd " > def.txt
       
    34 	echo " " > ziplog.txt
       
    35 	if [ -d .\\test1 ]
       
    36 	then
       
    37 		rm -r c:\\ziptest
       
    38 	fi
       
    39 
       
    40 	mkdir c:\\test1
       
    41 	cd c:\\test1
       
    42 	echo "kjhdlaskdjsd dsakjdas
       
    43 	sajdkaksjdasd
       
    44 	sdklsjdasds" > abc1.txt
       
    45 	echo "dsdfdsfds
       
    46 	dfsdfd " > def.txt
       
    47 	cd 
       
    48 }		
       
    49 
       
    50 test_zip2()
       
    51 {
       
    52 	let total+=1;
       
    53 	echo "test_zip2:Zip with no options and zip file argument"
       
    54 
       
    55 	#echo "test_zip2:Zip with no options and zip file argument" >> ziplog.txt
       
    56 	zip c:\\ziptest\\abc.zip #>> ziplog.txt 2>> ziplog.txt
       
    57 	#returns 0 instead of 1
       
    58 	ret=$?
       
    59 	if [ $ret -eq 0 ]
       
    60 	then
       
    61 		echo "PASS"
       
    62 		let pass+=1;
       
    63 	else
       
    64 		echo "FAIL\nReturn Value $ret"
       
    65 		let fail+=1;
       
    66 	fi
       
    67 }
       
    68 
       
    69 test_zip1()
       
    70 {
       
    71 	let total+=1;
       
    72 	echo "test_zip1:Zip with no options and no arguments"
       
    73 
       
    74 	#echo "test_zip1:Zip with no options and no arguments" > ziplog.txt
       
    75 	zip 
       
    76 	#redirection hangs
       
    77 	#returns 0 instead of 1
       
    78 	ret=$?
       
    79 	if [ $ret -ne 0 ]
       
    80 	then
       
    81 		echo "FAIL\nExpected Value : 1 Return Value:$ret"
       
    82 		let fail+=1;
       
    83 	else
       
    84 		echo "PASS"
       
    85 		let pass+=1;
       
    86 	fi
       
    87 }
       
    88 
       
    89 test_zip3()
       
    90 {
       
    91 	let total+=1;
       
    92 	echo "test_zip3:Zip pqr3.zip abc.txt def.txt "
       
    93 	
       
    94 	#echo "test_zip3:Zip pqr3.zip abc.txt def.txt " >> ziplog.txt
       
    95 	zip c:\\ziptest\\pqr3.zip c:\\ziptest\\abc.txt c:\\ziptest\\def.txt #>> ziplog.txt 2>> ziplog.txt
       
    96 	ret=$?
       
    97 	if [ -e c:\\ziptest\\pqr3.zip -a  $ret -eq 0 ]
       
    98  	then
       
    99 		echo "Pass";
       
   100 		let pass+=1;
       
   101 	else
       
   102 		echo "Fail"
       
   103 		let fail+=1;
       
   104 	fi
       
   105 }
       
   106 test_zip4()
       
   107 {
       
   108 	let total+=1;
       
   109 	echo " test_zip4 : zip -0 pqr4.zip abc.txt def.txt"
       
   110 	
       
   111 	#echo " test_zip4 : zip -0 pqr4.zip abc.txt def.txt" >> ziplog.txt
       
   112 	 zip -0 c:\\ziptest\\pqr4.zip c:\\ziptest\\abc.txt c:\\ziptest\\def.txt #>> ziplog.txt 2>> ziplog.txt
       
   113 	 ret=$?
       
   114 
       
   115 	if [ -e c:\\ziptest\\pqr4.zip ]
       
   116 	then
       
   117 		echo "PASS : Zip file created"
       
   118 		let pass+=1;
       
   119 	else
       
   120 		echo "FAIL\nExpected Value:1  Return Value:$ret"
       
   121 		let fail+=1;
       
   122 	fi
       
   123 }
       
   124 
       
   125 test_zip10()
       
   126 {
       
   127 	let total+=1;
       
   128 	echo " test_zip10 : zip -5 pqr10.zip abc.txt def.txt"
       
   129 	
       
   130 	#echo " test_zip10 : zip -5 pqr10.zip abc.txt def.txt" >> ziplog.txt
       
   131 	 zip -5 c:\\ziptest\\pqr10.zip c:\\ziptest\\abc.txt c:\\ziptest\\def.txt #>> ziplog.txt 2>> ziplog.txt
       
   132 	 ret=$?
       
   133 
       
   134 	if [ -e c:\\ziptest\\pqr10.zip ]
       
   135 	then
       
   136 		echo "PASS : Zip file created"
       
   137 		let pass+=1;
       
   138 	else
       
   139 		echo "FAIL\nExpected Value:1  Return Value:$ret"
       
   140 		let fail+=1;
       
   141 	fi
       
   142 }
       
   143 
       
   144 test_zip5()
       
   145 {
       
   146 	let total+=1;
       
   147 	echo " test_zip5 : zip -20 pqr5.zip abc.txt def.txt"
       
   148 	#echo " test_zip5 : zip -20 pqr5.zip abc.txt def.txt" >> ziplog.txt
       
   149 	# on linux compresses 0% but doesnt fail	
       
   150 	 zip -20 c:\\ziptest\\pqr5.zip c:\\ziptest\\abc.txt c:\\ziptest\\def.txt 
       
   151 	 ret=$?
       
   152 
       
   153 	if [ -e c:\\ziptest\\pqr5.zip -a  $ret -eq 0 ]
       
   154 	then
       
   155 		echo "PASS : Zip file created"
       
   156 		let pass+=1;
       
   157 	else
       
   158 		echo "FAIL\n Return Value:$ret"
       
   159 		let fail+=1;
       
   160 	fi
       
   161 }
       
   162 
       
   163 test_zip6()
       
   164 {
       
   165 	let total+=1;
       
   166 	echo " test_zip6 : zip -o pqr5.zip abc.txt "
       
   167 	#echo " test_zip6 : zip -o pqr5.zip abc.txt " >> ziplog.txt
       
   168 	zip -o c:\\ziptest\\pqr5.zip c:\\ziptest\\abc.txt #>> ziplog.txt 2>> ziplog.txt
       
   169 	 ret=$?
       
   170 
       
   171 	if [ -e c:\\ziptest\\pqr5.zip -a $ret -eq 0 ]
       
   172 	then
       
   173 		echo "PASS : Zip file created"
       
   174 		let pass+=1;
       
   175 	else
       
   176 		echo "FAIL\n Return Value:$ret"
       
   177 		let fail+=1;
       
   178 	fi
       
   179 }
       
   180 
       
   181 
       
   182 test_zip7()
       
   183 {
       
   184 	let total+=1;
       
   185 	echo " test_zip7 : zip -a pqr5.zip def.txt "
       
   186 	#echo " test_zip7 : zip -a pqr5.zip def.txt " >> ziplog.txt
       
   187 	zip -a c:\\ziptest\\pqr5.zip c:\\ziptest\\def.txt #>> ziplog.txt 2>> ziplog.txt
       
   188 	 ret=$?
       
   189 
       
   190 	if [ -e c:\\ziptest\\pqr5.zip -a  $ret -eq 0 ]
       
   191 	then
       
   192 		echo "PASS : Zip file created"
       
   193 		let pass+=1;
       
   194 	else
       
   195 		echo "FAIL\n Return Value:$ret"
       
   196 		let fail+=1;
       
   197 	fi
       
   198 }
       
   199 
       
   200 test_zip11()
       
   201 {
       
   202 	let total+=1;
       
   203 	echo "test_zip11:Zip pqr11.zip abc.txt def.txt test\*";
       
   204 	zip -o c:\\ziptest\\pqr3.zip c:\\ziptest\\abc.txt c:\\ziptest\\def.txt 
       
   205 	ret=$?
       
   206 	if [ -e c:\\ziptest\\pqr3.zip -a  $ret -eq 0 ]
       
   207  	then
       
   208 		echo "Pass";
       
   209 		let pass+=1;
       
   210 	else
       
   211 		echo "Fail"
       
   212 		let fail+=1;
       
   213 	fi
       
   214 }
       
   215 
       
   216 report()
       
   217 {
       
   218 	echo "Changing the directory back";
       
   219 	echo "--------------------zip test results------------------------"
       
   220 	echo " TOTAL TESTS : $total"
       
   221 	echo " TOTAL PASS  : $pass"
       
   222 	echo " TOTAL FAIL  : $fail"
       
   223 	echo "------------------------------------------------------------"
       
   224 }
       
   225 
       
   226 #begin calls
       
   227 
       
   228 init
       
   229 test_zip1
       
   230 test_zip2
       
   231 test_zip3
       
   232 test_zip4
       
   233 test_zip5
       
   234 test_zip6
       
   235 test_zip7
       
   236 test_zip10
       
   237 test_zip11
       
   238 report