Lines Matching +full:pass +full:- +full:1
2 # SPDX-License-Identifier: GPL-2.0+
6 # Invoke this test script from U-Boot base directory as ./test/fs/fs-test.sh
10 # fs-test.sb.ext4 Summary: PASS: 24 FAIL: 0
11 # fs-test.nonfs.ext4 Summary: PASS: 24 FAIL: 0
12 # fs-test.fs.ext4 Summary: PASS: 24 FAIL: 0
14 # fs-test.sb.fat16 Summary: PASS: 24 FAIL: 0
15 # fs-test.nonfs.fat16 Summary: PASS: 24 FAIL: 0
16 # fs-test.fs.fat16 Summary: PASS: 24 FAIL: 0
18 # fs-test.sb.fat32 Summary: PASS: 24 FAIL: 0
19 # fs-test.nonfs.fat32 Summary: PASS: 24 FAIL: 0
20 # fs-test.fs.fat32 Summary: PASS: 24 FAIL: 0
21 # --------------------------------------------
22 # Total Summary: TOTAL PASS: 216 TOTAL FAIL: 0
23 # --------------------------------------------
25 # pre-requisite binaries list.
32 # Location of generated sandbox u-boot
33 UBOOT="./sandbox/u-boot"
41 # $SMALL_FILE is the name of the 1MB file in the file system image
42 SMALL_FILE="1MB.file"
52 OUT="${OUT_DIR}/fs-test"
54 # Full Path of the 1 MB file that shall be created in the fs image.
65 if [ ! -x "`which $prereq`" ]; then
72 if [ ! -c /dev/urandom ]; then
78 # If 1st param is "clean", then clean out the generated files and exit
80 if [ "$1" = "clean" ]; then
81 rm -rf "$OUT_DIR"
87 # Generate sandbox U-Boot - gleaned from /test/dm/test-dm.sh
90 NUM_CPUS=$(cat /proc/cpuinfo |grep -c processor)
92 make O=sandbox -s -j${NUM_CPUS}
94 # Check if U-Boot exists
95 if [ ! -x "$UBOOT" ]; then
106 rm -f ${MD5_FILE}.* ${OUT}.*
107 mkdir -p ${OUT_DIR}
110 # 1st parameter is the name of the image file to be created
111 # 2nd parameter is the filesystem - fat16 ext4 etc
112 # -F cant be used with fat as it means something else.
114 # Create image if not already present - saves time, while debugging
117 MKFS_OPTION="-F 16"
121 MKFS_OPTION="-F 32"
125 MKFS_OPTION="-F"
130 if [ ! -f "$1" ]; then
131 fallocate -l 3G "$1" &> /dev/null
132 if [ $? -ne 0 ]; then
133 echo fallocate failed - using dd instead
134 dd if=/dev/zero of=$1 bs=1024 count=$((3 * 1024 * 1024))
135 if [ $? -ne 0 ]; then
140 mkfs -t "$FS_TYPE" $MKFS_OPTION "$1" &> /dev/null
141 if [ $? -ne 0 -a "$FS_TYPE" = "fat" ]; then
143 mkfs -t vfat $MKFS_OPTION "$1" &> /dev/null
145 if [ $? -ne 0 ]; then
152 # 1st parameter is image file
153 # 2nd parameter is file system type - fat16/ext4/...
156 # 5th parameter is fs/nonfs/sb - to dictate generic fs commands or
199 SUFFIX="fs -"
218 # In u-boot commands, <interface> stands for host or hostfs
224 setenv bind 'if test "\$sb" != sb; then host bind 0 "$1"; fi'
226 # Test Case 1 - ls
232 # host size hostfs - $3 for hostfs commands.
233 # 1MB is 0x0010 0000
234 # Test Case 2a - size of small file
238 # Test Case 2b - size of small file via a path using '..'
244 # Test Case 3 - size of big file
253 # Test Case 4a - Read full 1MB of small file
256 # Test Case 4b - Read full 1MB of small file
260 # Test Case 5a - First 1MB of big file
263 # Test Case 5b - First 1MB of big file
268 # Test Case 6a - Last 1MB of big file
271 # Test Case 6b - Last 1MB of big file
276 # Test Case 7a - One from the last 1MB chunk of 2GB
279 # Test Case 7b - One from the last 1MB chunk of 2GB
284 # Test Case 8a - One from the start 1MB chunk from 2GB
287 # Test Case 8b - One from the start 1MB chunk from 2GB
292 # Test Case 9a - One 1MB chunk crossing the 2GB boundary
295 # Test Case 9b - One 1MB chunk crossing the 2GB boundary
300 # Test Case 10 - 2MB chunk from the last 1MB of big file
305 # Read 1MB from small file
308 # Test Case 11a - Check that the write succeeded
312 # Test Case 11b - Check md5 of written to is same as the one read from
320 # Test Case 12 - Check directory traversal
323 # Read 1MB from small file
326 # Test Case 13a - Check directory traversal
330 # Test Case 13b - Check md5 of written to is same as the one read from
335 # Test Case 13c - Check md5 of written to is same as the one read from
344 # 1st argument is the name of the image file.
349 # $MB1 is the path of the small file (1 MB)
353 mkdir -p "$MOUNT_DIR"
354 sudo mount -o loop,rw "$1" "$MOUNT_DIR"
357 sudo mkdir -p "$MOUNT_DIR/SUBDIR"
360 # Note that we work only on the start 1MB, couple MBs in the 2GB range
361 # and the last 1 MB of the huge 2.5GB file.
363 if [ ! -f "${GB2p5}" ]; then
364 sudo dd if=/dev/urandom of="${GB2p5}" bs=1M count=1 \
366 sudo dd if=/dev/urandom of="${GB2p5}" bs=1M count=2 seek=2047 \
368 sudo dd if=/dev/urandom of="${GB2p5}" bs=1M count=1 seek=2499 \
373 if [ ! -f "${MB1}" ]; then
374 sudo dd if=/dev/urandom of="${MB1}" bs=1M count=1 \
380 sudo rm -f "${MB1}.w"
381 sudo rm -f "${MB1}.w2"
384 dd if="${MB1}" bs=1M skip=0 count=1 2> /dev/null | md5sum > "$2"
388 dd if="${GB2p5}" bs=1M skip=0 count=1 \
392 dd if="${GB2p5}" bs=1M skip=2499 count=1 \
395 # One from the last 1MB chunk of 2GB
396 dd if="${GB2p5}" bs=1M skip=2047 count=1 \
399 # One from the start 1MB chunk from 2GB
400 dd if="${GB2p5}" bs=1M skip=2048 count=1 \
403 # One 1MB chunk crossing the 2GB boundary
412 # 1st parameter is the text to print
413 # if $? is 0 its a pass, else a fail
414 # As a side effect it shall update env variable PASS and FAIL
416 if [ $? -eq 0 ]; then
417 echo pass - "$1"
418 PASS=$((PASS + 1))
420 echo FAIL - "$1"
421 FAIL=$((FAIL + 1))
425 # 1st parameter is the string which leads to an md5 generation
433 # md5sum in u-boot has output of form:
436 md5_src=`grep -A2 "$1" "$2" | grep "md5 for" | tr -d '\r'`
441 # - <md5>
443 md5_dst=`sed -n $4p $3`
447 # For a pass they should match.
452 # 1st parameter is the name of the output file to check
459 echo "** Start $1"
461 PASS=0
465 grep -A7 "Test Case 1 " "$1" | egrep -iq "2621440000 *$4"
468 # Check if the ls is showing correct results for 1 mb file
469 grep -A7 "Test Case 1 " "$1" | egrep -iq "1048576 *$3"
472 # Check size command on 1MB.file
473 egrep -A3 "Test Case 2a " "$1" | grep -q "filesize=100000"
475 # Check size command on 1MB.file via a path using '..'
476 egrep -A3 "Test Case 2b " "$1" | grep -q "filesize=100000"
480 egrep -A3 "Test Case 3 " "$1" | grep -q "filesize=9c400000"
483 # Check read full mb of 1MB.file
484 grep -A4 "Test Case 4a " "$1" | grep -q "filesize=100000"
486 check_md5 "Test Case 4b " "$1" "$2" 1 "TC4: load from $3"
489 grep -A4 "Test Case 5a " "$1" | grep -q "filesize=100000"
490 pass_fail "TC5: load of 1st MB from $4 size"
491 check_md5 "Test Case 5b " "$1" "$2" 2 "TC5: load of 1st MB from $4"
494 grep -A4 "Test Case 6a " "$1" | grep -q "filesize=100000"
496 check_md5 "Test Case 6b " "$1" "$2" 3 "TC6: load of last MB from $4"
498 # Check last 1mb chunk of 2gb from 2.5GB file
499 grep -A4 "Test Case 7a " "$1" | grep -q "filesize=100000"
500 pass_fail "TC7: load of last 1mb chunk of 2GB from $4 size"
501 check_md5 "Test Case 7b " "$1" "$2" 4 \
502 "TC7: load of last 1mb chunk of 2GB from $4"
504 # Check first 1mb chunk after 2gb from 2.5GB file
505 grep -A4 "Test Case 8a " "$1" | grep -q "filesize=100000"
506 pass_fail "TC8: load 1st MB chunk after 2GB from $4 size"
507 check_md5 "Test Case 8b " "$1" "$2" 5 \
508 "TC8: load 1st MB chunk after 2GB from $4"
510 # Check 1mb chunk crossing the 2gb boundary from 2.5GB file
511 grep -A4 "Test Case 9a " "$1" | grep -q "filesize=100000"
512 pass_fail "TC9: load 1MB chunk crossing 2GB boundary from $4 size"
513 check_md5 "Test Case 9b " "$1" "$2" 6 \
514 "TC9: load 1MB chunk crossing 2GB boundary from $4"
516 # Check 2mb chunk from the last 1MB of 2.5GB file loads 1MB
517 grep -A5 "Test Case 10 " "$1" | grep -q "filesize=100000"
518 pass_fail "TC10: load 2MB from the last 1MB of $4 loads 1MB"
520 # Check 1mb chunk write
521 grep -A2 "Test Case 11a " "$1" | grep -q '1048576 bytes written'
522 pass_fail "TC11: 1MB write to $3.w - write succeeded"
523 check_md5 "Test Case 11b " "$1" "$2" 1 \
524 "TC11: 1MB write to $3.w - content verified"
527 grep -A4 "Test Case 12 " "$1" | grep -q 'Unable to write'
528 pass_fail "TC12: 1MB write to . - write denied"
531 grep -A2 "Test Case 13a " "$1" | grep -q '1048576 bytes written'
532 pass_fail "TC13: 1MB write to ./$3.w2 - write succeeded"
533 check_md5 "Test Case 13b " "$1" "$2" 1 \
534 "TC13: 1MB read from ./$3.w2 - content verified"
535 check_md5 "Test Case 13c " "$1" "$2" 1 \
536 "TC13: 1MB read from $3.w2 - content verified"
538 echo "** End $1"
548 OUT_FILE="${OUT}.$1.${fs}.out"
549 test_image $IMAGE $fs $SMALL_FILE $BIG_FILE $1 "" \
550 > ${OUT_FILE} 2>&1
552 grep -v -e "File System is consistent\|update journal finished" \
553 -e "reading .*\.file\|writing .*\.file.w" \
558 TOTAL_PASS=$((TOTAL_PASS + PASS))
559 echo "Summary: PASS: $PASS FAIL: $FAIL"
560 echo "--------------------------------------------"
567 check_clean "$1"
591 mkdir -p "$MOUNT_DIR"
594 uid="uid=`id -u`"
600 sudo mount -o loop,rw,$uid "$IMAGE" "$MOUNT_DIR"
605 > ${OUT_FILE} 2>&1
611 TOTAL_PASS=$((TOTAL_PASS + PASS))
612 echo "Summary: PASS: $PASS FAIL: $FAIL"
613 echo "--------------------------------------------"
619 echo "Total Summary: TOTAL PASS: $TOTAL_PASS TOTAL FAIL: $TOTAL_FAIL"
620 echo "--------------------------------------------"
621 if [ $TOTAL_FAIL -eq 0 ]; then
626 exit 1