# Expected results are as follows:
# EXT4 tests:
# fs-test.sb.ext4.out: Summary: PASS: 17 FAIL: 2
-# fs-test.ext4.out: Summary: PASS: 11 FAIL: 8
-# fs-test.fs.ext4.out: Summary: PASS: 11 FAIL: 8
+# fs-test.ext4.out: Summary: PASS: 10 FAIL: 9
+# fs-test.fs.ext4.out: Summary: PASS: 10 FAIL: 9
# FAT tests:
# fs-test.sb.fat.out: Summary: PASS: 17 FAIL: 2
# fs-test.fat.out: Summary: PASS: 19 FAIL: 0
# fs-test.fs.fat.out: Summary: PASS: 19 FAIL: 0
-# Total Summary: TOTAL PASS: 94 TOTAL FAIL: 20
+# Total Summary: TOTAL PASS: 92 TOTAL FAIL: 22
# pre-requisite binaries list.
PREREQ_BINS="md5sum mkfs mount umount dd fallocate mkdir"
# Check if the prereq binaries exist, or exit
function check_prereq() {
for prereq in $PREREQ_BINS; do
- if [ ! -x `which $prereq` ]; then
+ if [ ! -x "`which $prereq`" ]; then
echo "Missing $prereq binary. Exiting!"
exit
fi
# We save time by not deleting and recreating the file system images
function prepare_env() {
rm -f ${MD5_FILE}.* ${OUT}.*
- mkdir ${OUT_DIR}
+ mkdir -p ${OUT_DIR}
}
# 1st parameter is the name of the image file to be created
fi
if [ ! -f "$1" ]; then
fallocate -l 3G "$1" &> /dev/null
+ if [ $? -ne 0 ]; then
+ echo fallocate failed - using dd instead
+ dd if=/dev/zero of=$1 bs=1024 count=$((3 * 1024 * 1024))
+ if [ $? -ne 0 ]; then
+ echo Could not create empty disk image
+ exit $?
+ fi
+ fi
mkfs -t "$2" $MKFS_OPTION "$1" &> /dev/null
if [ $? -ne 0 -a "$2" = "fat" ]; then
# If we fail and we did fat, try vfat.
mkfs -t vfat $MKFS_OPTION "$1" &> /dev/null
fi
+ if [ $? -ne 0 ]; then
+ echo Could not create filesystem
+ exit $?
+ fi
fi
}
-# 1st parameter is the FS type: fat/ext4
-# 2nd parameter is the name of small file
-# Returns filename which can be used for fat or ext4 for writing
-function fname_for_write() {
- case $1 in
- ext4)
- # ext4 needs absolute path name of file
- echo /${2}.w
- ;;
-
- *)
- echo ${2}.w
- ;;
- esac
-}
-
# 1st parameter is image file
# 2nd parameter is file system type - fat/ext4
# 3rd parameter is name of small file
case "$2" in
fat)
+ FPATH=""
PREFIX="fat"
WRITE="write"
;;
ext4)
+ # ext4 needs absolute path
+ FPATH="/"
PREFIX="ext4"
WRITE="write"
;;
esac
- if [ -z "$6" ]; then
- FILE_WRITE=`fname_for_write $2 $3`
- FILE_SMALL=$3
- FILE_BIG=$4
- else
- FILE_WRITE=$6/`fname_for_write $2 $3`
- FILE_SMALL=$6/$3
- FILE_BIG=$6/$4
+ # sb always uses full path to mointpoint, irrespective of filesystem
+ if [ "$5" = "sb" ]; then
+ FPATH=${6}/
fi
+ FILE_WRITE=${3}.w
+ FILE_SMALL=$3
+ FILE_BIG=$4
+
# In u-boot commands, <interface> stands for host or hostfs
# hostfs maps to the host fs.
# host maps to the "sb bind" that we do
# sb size hostfs - $3 for hostfs commands.
# 1MB is 0x0010 0000
# Test Case 2 - size of small file
-${PREFIX}size host${SUFFIX} $FILE_SMALL
+${PREFIX}size host${SUFFIX} ${FPATH}$FILE_SMALL
printenv filesize
setenv filesize
# 2.5GB (1024*1024*2500) is 0x9C40 0000
# Test Case 3 - size of big file
-${PREFIX}size host${SUFFIX} $FILE_BIG
+${PREFIX}size host${SUFFIX} ${FPATH}$FILE_BIG
printenv filesize
setenv filesize
# Last two parameters are size and offset.
# Test Case 4a - Read full 1MB of small file
-${PREFIX}load host${SUFFIX} $addr $FILE_SMALL
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_SMALL
printenv filesize
# Test Case 4b - Read full 1MB of small file
md5sum $addr \$filesize
setenv filesize
# Test Case 5a - First 1MB of big file
-${PREFIX}load host${SUFFIX} $addr $FILE_BIG $length 0x0
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x0
printenv filesize
# Test Case 5b - First 1MB of big file
md5sum $addr \$filesize
# fails for ext as no offset support
# Test Case 6a - Last 1MB of big file
-${PREFIX}load host${SUFFIX} $addr $FILE_BIG $length 0x9C300000
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x9C300000
printenv filesize
# Test Case 6b - Last 1MB of big file
md5sum $addr \$filesize
# fails for ext as no offset support
# Test Case 7a - One from the last 1MB chunk of 2GB
-${PREFIX}load host${SUFFIX} $addr $FILE_BIG $length 0x7FF00000
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x7FF00000
printenv filesize
# Test Case 7b - One from the last 1MB chunk of 2GB
md5sum $addr \$filesize
# fails for ext as no offset support
# Test Case 8a - One from the start 1MB chunk from 2GB
-${PREFIX}load host${SUFFIX} $addr $FILE_BIG $length 0x80000000
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x80000000
printenv filesize
# Test Case 8b - One from the start 1MB chunk from 2GB
md5sum $addr \$filesize
# fails for ext as no offset support
# Test Case 9a - One 1MB chunk crossing the 2GB boundary
-${PREFIX}load host${SUFFIX} $addr $FILE_BIG $length 0x7FF80000
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x7FF80000
printenv filesize
# Test Case 9b - One 1MB chunk crossing the 2GB boundary
md5sum $addr \$filesize
# Generic failure case
# Test Case 10 - 2MB chunk from the last 1MB of big file
-${PREFIX}load host${SUFFIX} $addr $FILE_BIG 0x00200000 0x9C300000
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG 0x00200000 0x9C300000
printenv filesize
#
# Read 1MB from small file
-${PREFIX}load host${SUFFIX} $addr $FILE_SMALL
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_SMALL
# Write it back to test the writes
# Test Case 11a - Check that the write succeeded
-${PREFIX}${WRITE} host${SUFFIX} $addr $FILE_WRITE \$filesize
+${PREFIX}${WRITE} host${SUFFIX} $addr ${FPATH}$FILE_WRITE \$filesize
mw.b $addr 00 100
-${PREFIX}load host${SUFFIX} $addr $FILE_WRITE
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_WRITE
# Test Case 11b - Check md5 of written to is same as the one read from
md5sum $addr \$filesize
setenv filesize
# md5sum in u-boot has output of form:
# md5 for 01000008 ... 01100007 ==> <md5>
# the 7th field is the actual md5
- md5_src=`grep -A3 "$1" "$2" | grep "md5 for"`
+ md5_src=`grep -A3 "$1" "$2" | grep "md5 for" | tr -d '\r'`
md5_src=($md5_src)
md5_src=${md5_src[6]}
check_md5 "Test Case 9b " "$1" "$2" 6 \
"TC9: load 1MB chunk crossing 2GB boundary from $4"
- # Check 2mb chunk from the last 1MB of 2.5GB file - generic failure case
- grep -A6 "Test Case 10 " "$1" | grep -q 'Error: "filesize" not defined'
- pass_fail "TC10: load 2MB from the last 1MB of $4 - generic fail case"
+ # Check 2mb chunk from the last 1MB of 2.5GB file loads 1MB
+ grep -A6 "Test Case 10 " "$1" | grep -q "filesize=100000"
+ pass_fail "TC10: load 2MB from the last 1MB of $4 loads 1MB"
# Check 1mb chunk write
grep -A3 "Test Case 11a " "$1" | \