summaryrefslogtreecommitdiff
path: root/vfat-volid/test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'vfat-volid/test.sh')
-rw-r--r--vfat-volid/test.sh114
1 files changed, 114 insertions, 0 deletions
diff --git a/vfat-volid/test.sh b/vfat-volid/test.sh
new file mode 100644
index 0000000..6225d45
--- /dev/null
+++ b/vfat-volid/test.sh
@@ -0,0 +1,114 @@
+#!/bin/sh
+
+FAIL_CODE=32767
+
+function do_test() {
+
+ # parameters: sizeK vfat_arg id
+
+ UUT=/tmp/$$.disk
+ MPT=/tmp/$$
+ DEV=/dev/block/loop7
+
+ step=0
+ rc=0
+
+ while true; do
+
+ step=1
+ echo "Creating disk of size $1..." | tee -a $LOG
+ dd if=/dev/zero of=$UUT bs=1024 count=$1 >> $LOG
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ echo "Problems with dd" | tee -a $LOG
+ break
+ fi
+
+ step=2
+ echo "Setting up loop device $DEV"
+ losetup $DEV $UUT >> $LOG
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ echo "Problems setting up loop device" | tee -a $LOG
+ break
+ fi
+
+ step=3
+ echo "Running mkfs.vfat..." | tee -a $LOG
+ mkfs.vfat $2 -i $3 $DEV >> $LOG
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ echo "Problems formatting loop device" | tee -a $LOG
+ break
+ fi
+
+ step=4
+ mkdir -p $MPT
+
+ step=5
+ # argument "-t vfat" here is necessary, busybox's mount requires it
+ echo "Mounting device" | tee -a $LOG
+ mount -t vfat $DEV $MPT | tee -a $LOG
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ echo "Could not mount device" | tee -a $LOG
+ break
+ fi
+
+ step=6
+ echo "Getting volume ID" | tee -a $LOG
+ v1=`/system/bin/vfat-volid --path $MPT -i`
+ v2=`/system/bin/vfat-volid --path $MPT -s`
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ echo "Error when getting volume ID" | tee -a $LOG
+ break
+ fi
+
+ step=7
+ echo "Got volume IDs $v1 and $v2, should be identical" | tee -a $LOG
+ if [ x$v1 != x$3 ]; then
+ rc=$FAIL_CODE # indicate fail
+ fi
+ if [ x$v1 != x$v2 ]; then
+ rc=$FAIL_CODE # indicate fail
+ fi
+
+ break
+
+ done
+
+ # clean up
+ [ $step -gt 5 ] && umount $MPT
+ [ $step -gt 4 ] && rmdir $MPT
+ [ $step -gt 2 ] && losetup -d $DEV
+ [ $step -gt 1 ] && rm $UUT
+
+ return $rc
+}
+
+echo "Starting"
+insmod /system/modules/loop.ko
+mount -o rw,remount /
+mkdir /tmp
+
+LOG=/dev/null
+if [ $# -ge 1 ]; then
+ LOG=$1
+fi
+for FTYPE in 12 16 32; do
+ for SIZE in 360 1024 102400; do
+ for ID in 0x12347900 0x00000000 0xDEADBEEF 0xFFFFFDFD; do
+ do_test "$SIZE" "-F $FTYPE" "$ID"
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ echo -en "### FAIL code = $rc" | tee -a $LOG
+ else
+ echo -en "### PASS" | tee -a $LOG
+ fi
+ echo -e " (FTYPE=$FTYPE, SIZE=$SIZE, ID=$ID)\n" | tee -a $LOG
+ done
+ done
+done
+rmmod loop
+