2002-10-30 16:14:32 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
IMAGE=disk.img
|
|
|
|
MOUNT=/mnt/dummy
|
2002-10-31 16:09:28 +00:00
|
|
|
RESULT=result.txt
|
2002-10-30 16:14:32 +00:00
|
|
|
|
|
|
|
fail() {
|
2002-10-31 16:09:28 +00:00
|
|
|
echo "!! Test failed. Look in $RESULT for test logs."
|
2002-10-30 16:14:32 +00:00
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
check() {
|
2002-10-31 16:09:28 +00:00
|
|
|
/sbin/dosfsck -r $IMAGE | tee -a $RESULT
|
2002-10-30 16:14:32 +00:00
|
|
|
[ $RETVAL -ne 0 ] && fail
|
|
|
|
}
|
|
|
|
|
|
|
|
try() {
|
2002-12-03 14:00:33 +00:00
|
|
|
echo COMMAND: fat $1 "$2" "$3"
|
|
|
|
echo COMMAND: fat $1 "$2" "$3" >> $RESULT
|
|
|
|
./fat $1 "$2" "$3" 2>> $RESULT
|
2002-10-30 16:14:32 +00:00
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -ne 0 ] && fail
|
|
|
|
}
|
|
|
|
|
|
|
|
buildimage() {
|
2002-10-31 16:09:28 +00:00
|
|
|
/sbin/mkdosfs -F 32 -s $1 $IMAGE > /dev/null
|
2002-10-30 16:14:32 +00:00
|
|
|
mount -o loop $IMAGE $MOUNT
|
|
|
|
echo "Filling it with /etc files"
|
|
|
|
find /etc -type f -maxdepth 1 -exec cp {} $MOUNT \;
|
2002-12-03 14:00:33 +00:00
|
|
|
for i in `seq 1 120`;
|
|
|
|
do
|
|
|
|
echo apa > "$MOUNT/very $i long test filename so we can make sure they.work"
|
|
|
|
done
|
2002-11-01 15:26:06 +00:00
|
|
|
mkdir $MOUNT/dir
|
2002-10-31 16:09:28 +00:00
|
|
|
umount $MOUNT
|
2002-10-30 16:14:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
runtests() {
|
2002-10-31 16:09:28 +00:00
|
|
|
rm $RESULT
|
2002-10-30 16:14:32 +00:00
|
|
|
|
|
|
|
echo ---Test: create a 10K file
|
2002-12-03 14:00:33 +00:00
|
|
|
try mkfile "/really long filenames rock" 10
|
|
|
|
check
|
|
|
|
try mkfile /dir/apa.monkey.me.now 10
|
2002-10-30 16:14:32 +00:00
|
|
|
check
|
2002-12-03 14:00:33 +00:00
|
|
|
try chkfile "/really long filenames rock" 10
|
|
|
|
try chkfile /dir/apa.monkey.me.now 8
|
2002-10-30 16:14:32 +00:00
|
|
|
|
|
|
|
echo ---Test: create a 1K file
|
2002-12-03 14:00:33 +00:00
|
|
|
try mkfile /bpa.rock 1
|
2002-10-30 16:14:32 +00:00
|
|
|
check
|
2002-12-03 14:00:33 +00:00
|
|
|
try chkfile /bpa.rock 1
|
2002-10-30 16:14:32 +00:00
|
|
|
|
|
|
|
echo ---Test: create a 40K file
|
2002-12-03 14:00:33 +00:00
|
|
|
try mkfile /cpa.rock 40
|
2002-10-30 16:14:32 +00:00
|
|
|
check
|
2002-12-03 14:00:33 +00:00
|
|
|
try chkfile /cpa.rock 40
|
2002-10-31 20:40:15 +00:00
|
|
|
|
|
|
|
echo ---Test: create a 400K file
|
2002-12-03 14:00:33 +00:00
|
|
|
try mkfile /dpa.rock 400
|
|
|
|
check
|
|
|
|
try chkfile /dpa.rock 400
|
|
|
|
|
|
|
|
echo ---Test: create a 1200K file
|
|
|
|
try mkfile /epa.rock 1200
|
2002-10-31 20:40:15 +00:00
|
|
|
check
|
2002-12-03 14:00:33 +00:00
|
|
|
try chkfile /epa.rock 1200
|
2002-10-30 16:14:32 +00:00
|
|
|
|
2002-12-03 14:00:33 +00:00
|
|
|
echo ---Test: rewrite first 20K of a 40K file
|
|
|
|
try mkfile /cpa.rock 20
|
2002-10-30 16:14:32 +00:00
|
|
|
check
|
2002-12-03 14:00:33 +00:00
|
|
|
try chkfile /cpa.rock 20
|
2002-10-30 16:14:32 +00:00
|
|
|
|
2002-12-03 14:00:33 +00:00
|
|
|
echo ---Test: rewrite first sector of 40K file
|
|
|
|
try mkfile /cpa.rock 0
|
2002-10-30 16:14:32 +00:00
|
|
|
check
|
2002-12-03 14:00:33 +00:00
|
|
|
try chkfile /cpa.rock
|
|
|
|
try chkfile /apa.rock
|
|
|
|
try chkfile /bpa.rock
|
2002-10-30 16:14:32 +00:00
|
|
|
|
2002-10-31 19:06:14 +00:00
|
|
|
LOOP=50
|
2002-12-03 14:00:33 +00:00
|
|
|
SIZE=700
|
|
|
|
|
|
|
|
try del "/really long filenames rock"
|
2002-10-31 19:06:14 +00:00
|
|
|
|
2002-10-31 20:40:15 +00:00
|
|
|
echo ---Test: create $LOOP $SIZE k files
|
2002-10-31 19:06:14 +00:00
|
|
|
for i in `seq 1 $LOOP`;
|
2002-10-30 16:14:32 +00:00
|
|
|
do
|
2002-10-31 19:06:14 +00:00
|
|
|
echo ---Test: $i/$LOOP ---
|
2002-12-03 14:00:33 +00:00
|
|
|
try mkfile "/rockbox rocks.$i" $SIZE
|
|
|
|
check
|
|
|
|
try chkfile "/rockbox rocks.$i" $SIZE
|
2002-10-30 16:14:32 +00:00
|
|
|
check
|
2002-12-03 14:00:33 +00:00
|
|
|
try del "/rockbox rocks.$i"
|
2002-11-01 15:26:06 +00:00
|
|
|
check
|
2002-12-03 14:00:33 +00:00
|
|
|
try mkfile "/rockbox rocks.$i" $SIZE
|
2002-11-01 15:26:06 +00:00
|
|
|
check
|
2002-12-03 14:00:33 +00:00
|
|
|
try ren "/rockbox rocks.$i" "$i is a new long filename!"
|
2002-11-01 15:26:06 +00:00
|
|
|
check
|
2002-10-30 16:14:32 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-11-01 15:26:06 +00:00
|
|
|
echo "Building test image (4 sector/cluster)"
|
|
|
|
buildimage 4
|
|
|
|
runtests
|
|
|
|
|
2002-10-31 19:06:14 +00:00
|
|
|
echo "Building test image (32 sectors/cluster)"
|
|
|
|
buildimage 32
|
2002-10-31 16:09:28 +00:00
|
|
|
runtests
|
|
|
|
|
2002-12-03 14:00:33 +00:00
|
|
|
echo "Building test image (1 sector/cluster)"
|
|
|
|
buildimage 1
|
|
|
|
runtests
|
|
|
|
|
2002-10-31 16:09:28 +00:00
|
|
|
echo "Building test image (8 sectors/cluster)"
|
2002-10-30 16:14:32 +00:00
|
|
|
buildimage 8
|
|
|
|
runtests
|
|
|
|
|
2002-12-03 14:00:33 +00:00
|
|
|
echo "Building test image (128 sectors/cluster)"
|
|
|
|
buildimage 128
|
2002-10-31 16:09:28 +00:00
|
|
|
runtests
|
2002-10-30 16:14:32 +00:00
|
|
|
|
2002-10-31 16:09:28 +00:00
|
|
|
echo "== Test completed sucessfully =="
|