test: fat: add error-checking to non-contig test
PATCH 1/2 test: fat: add error-checking to non-contig test
From: Stephen Warren <[email protected]>
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.
--- test/fs/fat-noncontig-test.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
test/fs/fat-noncontig-test.sh +32 -0
@@ -74,9 +74,25 @@ make O=${odir} -s sandbox_defconfig && make O=${odir} -s -j8 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 mkfs.fat ${img} + if [ $? -ne 0 ]; then + echo Could not create FAT filesystem + exit $? + fi 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
@@ -92,11 +108,23 @@ if [ ! -f ${img} ]; then 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} +if [ $? -ne 0 ]; then + echo Could not mount test filesystem + exit $? +fi 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)) \
@@ -111,3 +139,7 @@ crc32 ${loadaddr} \$filesize ${crcaddr} 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
Signature · 1 line
1.9.1
PATCH 2/2 itest: add missing break statements to evalexp()
From: Stephen Warren <[email protected]>
The commit mentioned below replaced return statements inside a switch so that other code could be called after the switch. However, it didn't add any break statements, causing the cases to run together. Fix this.
--- common/cmd_itest.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
common/cmd_itest.c +9 -3
@@ -64,9 +64,15 @@ static long evalexp(char *s, int w)return 0 ; }switch (w) { -case 1 : l = (long )(*(unsigned char *)buf); -case 2 : l = (long )(*(unsigned short *)buf); -case 4 : l = (long )(*(unsigned long *)buf); +case 1 : + l = (long )(*(unsigned char *)buf); +break ; +case 2 : + l = (long )(*(unsigned short *)buf); +break ; +case 4 : + l = (long )(*(unsigned long *)buf); +break ; }unmap_physmem (buf, w);return l;
Signature · 1 line
1.9.1
PATCH 2/2 itest: add missing break statements to evalexp()
Quoted 9 lines · Stephen Warren
From: Stephen Warren <[email protected]>
The commit mentioned below replaced return statements inside a switch so that other code could be called after the switch. However, it didn't add any break statements, causing the cases to run together. Fix this.
Reported-by Coverity (CID 132282, 132283)Fixes 7861204c9af7 ("itest: make memory access work under sandbox")Signed-off-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/7afef0d3/attachment.sig>
PATCH 1/2 test: fat: add error-checking to non-contig test
In reply to Stephen WarrenQuoted 9 lines · Stephen Warren
From: Stephen Warren <[email protected]>
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!
Quoted 5 lines
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 <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/728d7319/attachment.sig>