blob: 33bd1792e23ed5806da4313520d395eae5282502 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/system/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`
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 $3, should be identical" | tee -a $LOG
if [ x$v1 != x$3 ]; 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"
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 -e "### FAIL code = $rc" | tee -a $LOG
echo -e "[vfat_${FTYPE}_${SIZE}_$ID]: test failed"
else
echo -e "### PASS" | tee -a $LOG
echo -e "[vfat_${FTYPE}_${SIZE}_$ID]: test passed"
fi
echo -e "(FTYPE=$FTYPE, SIZE=$SIZE, ID=$ID)\n" | tee -a $LOG
done
done
done
|