Home | History | Annotate | Download | only in stress_floppy
      1 #!/bin/sh
      2 #
      3 #
      4 #   Copyright (c) International Business Machines  Corp., 2001
      5 #
      6 #   This program is free software;  you can redistribute it and/or modify
      7 #   it under the terms of the GNU General Public License as published by
      8 #   the Free Software Foundation; either version 2 of the License, or
      9 #   (at your option) any later version.
     10 #
     11 #   This program is distributed in the hope that it will be useful,
     12 #   but WITHOUT ANY WARRANTY;  without even the implied warranty of
     13 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     14 #   the GNU General Public License for more details.
     15 #
     16 #   You should have received a copy of the GNU General Public License
     17 #   along with this program;  if not, write to the Free Software
     18 #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     19 #
     20 #
     21 #
     22 #  FILE   : stress_floppy
     23 #
     24 #  PURPOSE : Tests the reading/writing/formatting on a floppy drive
     25 #
     26 #  HISTORY:
     27 #    06/01 Robbie Williamson (robbiew (at] us.ibm.com)
     28 #     -Ported
     29 #
     30 #
     31 #---------------------------------------------------------------------------
     32 
     33 TCdat=${TCdat:-$LTP_DATAROOT}
     34 
     35 TCID="io_floppy"
     36 TST_TOTAL=7
     37 . test.sh
     38 
     39 setup()
     40 {
     41 	tst_tmpdir
     42 
     43 	tst_check_cmds fdformat tar dump cpio dd mkfs mkdosfs
     44 
     45 	TCtmp=$(pwd)
     46 }
     47 
     48 cleanup()
     49 {
     50 	tst_rmdir
     51 }
     52 
     53 
     54 test_for_device()
     55 {
     56 	grep fd /proc/devices
     57 	if [ $? = 0 ]; then
     58 		num_device=$(ls /dev | grep fd0 | wc -l)
     59 		if [ $num_device = 0 ]; then
     60 			tst_brkm TCONF "No floppy diskette drive available!"
     61 		else
     62 			tst_resm TINFO "Floppy diskette drive fd0 available."
     63 		fi
     64 	else
     65 		tst_brkm TCONF "No floppy diskette drive available!"
     66 	fi
     67 }
     68 
     69 test_format()
     70 {
     71 	tst_resm TINFO "Testing format..."
     72 	fdformat  /dev/fd0
     73 	if [ $? -ne 0 ]; then
     74 		tst_resm TFAIL "Format failed!"
     75 	else
     76 		tst_resm TPASS "Format successful."
     77 	fi
     78 }
     79 
     80 test_tar()
     81 {
     82 	for the_file in 1K_file 10K_file 100K_file 1000K_file
     83 	do
     84 		tst_resm TINFO "Testing $the_file tar..."
     85 		tar -C $TCdat/dumpdir -cvf /dev/fd0 $the_file
     86 		if [ $? -ne 0 ]; then
     87 			tst_resm TFAIL "$the_file Tar write failed!"
     88 			return
     89 		else
     90 			tst_resm TINFO "$the_file Tar write passed."
     91 		fi
     92 		tar -xvf /dev/fd0
     93 		if [ $? -ne 0 ]; then
     94 			tst_resm TFAIL "$the_file Tar read failed!"
     95 			return
     96 		else
     97 			tst_resm TINFO "$the_file Tar read passed."
     98 		fi
     99 		diff $TCdat/dumpdir/$the_file $the_file 2>&1 >/dev/null
    100 		if [ $? -ne 0 ]; then
    101 			tst_resm TFAIL "Diff of the $the_file tar files failed!"
    102 			return
    103 		else
    104 			tst_resm TINFO "Diff of the $the_file tar files passed."
    105 		fi
    106 		rm -f $the_file
    107 	done
    108 	tst_resm TPASS "test_tar: PASS."
    109 }
    110 
    111 test_dump()
    112 {
    113 	tst_resm TINFO "Testing dump/restore..."
    114 	cp -r $TCdat/dumpdir ./
    115 	if [ $? -ne 0 ]; then
    116 		tst_resm TFAIL "Could not create dumpdir directory in $TCtmp"
    117 		return
    118 	fi
    119 
    120 	dump -f /dev/fd0 dumpdir
    121 	if [ $? -ne 0 ]; then
    122 		tst_resm TFAIL "$the_file dump write failed!"
    123 		return
    124 	else
    125 		tst_resm TINFO "$the_file dump write passed."
    126 	fi
    127 
    128 	rm -rf dumpdir
    129 	cd /
    130 
    131 	restore -v -r -f /dev/fd0 2>/dev/null
    132 	if [ $? -ne 0 ]; then
    133 		tst_resm TFAIL "$the_file restore read failed!"
    134 		return
    135 	else
    136 		tst_resm TINFO "$the_file restore read passed."
    137 	fi
    138 
    139 	cd -
    140 
    141 	for the_file in 1K_file 10K_file 100K_file
    142 	do
    143 		diff dumpdir/$the_file /$TCdat/dumpdir/$the_file 2>&1 >/dev/null
    144 		if [ $? -ne 0 ]; then
    145 			tst_resm TFAIL \
    146 				 "Diff of the $the_file backup files failed!"
    147 			return
    148 		else
    149 			tst_resm TINFO \
    150 				 "Diff of the $the_file backup files passed."
    151 		fi
    152 	done
    153 	tst_resm TPASS "test_dump: PASS."
    154 	rm -rf dumpdir
    155 	rm -f restoresymtable
    156 }
    157 
    158 test_cpio()
    159 {
    160 	for the_file in 1K_file 10K_file 100K_file 1000K_file
    161 	do
    162 		tst_resm TINFO "Testing $the_file cpio..."
    163 		cd $TCdat/dumpdir
    164 		echo $the_file | cpio -o > /dev/fd0
    165 		if [ $? -ne 0 ]; then
    166 			tst_resm TFAIL "$the_file cpio write failed!"
    167 			return
    168 		else
    169 			tst_resm TINFO "$the_file cpio write passed."
    170 		fi
    171 		cd $TCtmp
    172 		if [ $? -ne 0 ]; then
    173 			tst_resm TFAIL "Could not change to $TCtmp directory!"
    174 			return
    175 		fi
    176 		cpio -i < /dev/fd0
    177 		if [ $? -ne 0 ]; then
    178 			tst_resm TFAIL "$the_file cpio read failed!"
    179 			return
    180 		else
    181 			tst_resm TINFO "$the_file cpio read passed."
    182 		fi
    183 		diff $TCdat/dumpdir/$the_file $the_file 2>&1 >/dev/null
    184 		if [ $? -ne 0 ]; then
    185 			tst_resm TFAIL \
    186 				 "Diff of the $the_file cpio files failed!"
    187 			return
    188 		else
    189 			tst_resm TINFO \
    190 				 "Diff of the $the_file cpio files passed."
    191 		fi
    192 		rm -f $the_file
    193 	done
    194 	tst_resm TPASS "test_cpio: PASS."
    195 }
    196 
    197 test_dd()
    198 {
    199 	for the_file in dd_file
    200 	do
    201 		tst_resm TINFO "Testing $the_file dd..."
    202 		dd if=$TCdat/$the_file of=/dev/fd0 ibs=1b obs=90b conv=sync
    203 		if [ $? -ne 0 ]; then
    204 			tst_resm TFAIL "$the_file dd write failed!"
    205 			return
    206 		else
    207 			tst_resm TINFO "$the_file dd write passed."
    208 		fi
    209 		dd if=/dev/fd0 of=$the_file ibs=90b obs=1b conv=sync
    210 		if [ $? -ne 0 ]; then
    211 			tst_resm TFAIL "$the_file dd read failed!"
    212 			return
    213 		else
    214 			tst_resm TINFO "$the_file dd read passed."
    215 		fi
    216 		diff $TCdat/$the_file $the_file 2>&1 >/dev/null
    217 		if [ $? -ne 0 ]; then
    218 			tst_resm TFAIL "Diff of the $the_file dd files failed!"
    219 			return
    220 		else
    221 			tst_resm TINFO "Diff of the $the_file dd files passed."
    222 		fi
    223 		rm -f $the_file
    224 	done
    225 	tst_resm TPASS "test_dd: PASS."
    226 }
    227 
    228 test_linuxformat()
    229 {
    230 	tst_resm TINFO "Testing mkdosfs...."
    231 	mkfs -v /dev/fd0
    232 	if [ $? -ne 0 ]; then
    233 		tst_resm TFAIL "Linux (ext2) format failed!"
    234 	else
    235 		tst_resm TPASS "Linux (ext2) successful."
    236 	fi
    237 }
    238 
    239 test_dosformat()
    240 {
    241 	tst_resm TINFO "Testing mkdosfs...."
    242 	mkdosfs -v /dev/fd0
    243 	if [ $? -ne 0 ]; then
    244 		tst_resm TFAIL "Dosformat failed!"
    245 	else
    246 		tst_resm TPASS "Dosformat successful."
    247 	fi
    248 }
    249 
    250 setup
    251 
    252 TST_CLEANUP=cleanup
    253 
    254 test_for_device
    255 
    256 test_format
    257 test_tar
    258 test_dump
    259 test_cpio
    260 test_dd
    261 test_linuxformat
    262 test_dosformat
    263 
    264 tst_exit
    265