Check the result code of all command that are executed. Without this,
if the fallocate invocation fails (this feature is not supported on ext3
filesystems for example) then a zero-length output file will be created,
and subsequent the mkfs and mount invocations will fail, which will cause
the subsequent dd invocation to attempt to fill up the host's entire free
disk space. That's not a nice user experience!
Related, if fallocate does fail, try to create the test disk image using
dd instead. That should work everywhere.
Fixes:
4a28274227d0 ("test: fat: add test of non-contiguous file reads")
Signed-off-by: Stephen Warren <swarren@nvidia.com>
mkdir -p ${mnt}
if [ ! -f ${img} ]; then
fallocate -l 40M ${img}
mkdir -p ${mnt}
if [ ! -f ${img} ]; then
fallocate -l 40M ${img}
+ if [ $? -ne 0 ]; then
+ echo fallocate failed - using dd instead
+ dd if=/dev/zero of=${img} bs=1024 count=$((40 * 1024))
+ if [ $? -ne 0 ]; then
+ echo Could not create empty disk image
+ exit $?
+ fi
+ fi
+ if [ $? -ne 0 ]; then
+ echo Could not create FAT filesystem
+ exit $?
+ fi
sudo mount -o loop,uid=$(id -u) ${img} ${mnt}
sudo mount -o loop,uid=$(id -u) ${img} ${mnt}
+ if [ $? -ne 0 ]; then
+ echo Could not mount test filesystem
+ exit $?
+ fi
for ((sects=8; sects < 512; sects += 8)); do
fn=${mnt}/keep-${sects}.img
for ((sects=8; sects < 512; sects += 8)); do
fn=${mnt}/keep-${sects}.img
dd if=${fill} of=${mnttestfn} bs=511 >/dev/null 2>&1
sudo umount ${mnt}
dd if=${fill} of=${mnttestfn} bs=511 >/dev/null 2>&1
sudo umount ${mnt}
+ if [ $? -ne 0 ]; then
+ echo Could not unmount test filesystem
+ exit $?
+ fi
fi
sudo mount -o ro,loop,uid=$(id -u) ${img} ${mnt}
fi
sudo mount -o ro,loop,uid=$(id -u) ${img} ${mnt}
+if [ $? -ne 0 ]; then
+ echo Could not mount test filesystem
+ exit $?
+fi
crc=0x`crc32 ${mnttestfn}`
sudo umount ${mnt}
crc=0x`crc32 ${mnttestfn}`
sudo umount ${mnt}
+if [ $? -ne 0 ]; then
+ echo Could not unmount test filesystem
+ exit $?
+fi
crc=`printf %02x%02x%02x%02x \
$((${crc} & 0xff)) \
crc=`printf %02x%02x%02x%02x \
$((${crc} & 0xff)) \
if itest.l *${crcaddr} != ${crc}; then echo FAILURE; else echo PASS; fi
reset
EOF
if itest.l *${crcaddr} != ${crc}; then echo FAILURE; else echo PASS; fi
reset
EOF
+if [ $? -ne 0 ]; then
+ echo U-Boot exit status indicates an error
+ exit $?
+fi