Lines Matching +full:write +full:- +full:host
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.out: Summary: PASS: 24 FAIL: 0
11 # fs-test.ext4.out: Summary: PASS: 24 FAIL: 0
12 # fs-test.fs.ext4.out: Summary: PASS: 24 FAIL: 0
14 # fs-test.sb.fat16.out: Summary: PASS: 24 FAIL: 0
15 # fs-test.fat16.out: Summary: PASS: 21 FAIL: 3
16 # fs-test.fs.fat16.out: Summary: PASS: 21 FAIL: 3
18 # fs-test.sb.fat32.out: Summary: PASS: 24 FAIL: 0
19 # fs-test.fat32.out: Summary: PASS: 21 FAIL: 3
20 # fs-test.fs.fat32.out: Summary: PASS: 21 FAIL: 3
23 # pre-requisite binaries list.
30 # Location of generated sandbox u-boot
31 UBOOT="./sandbox/u-boot"
50 OUT="${OUT_DIR}/fs-test"
63 if [ ! -x "`which $prereq`" ]; then
70 if [ ! -c /dev/urandom ]; then
79 rm -rf "$OUT_DIR"
85 # Generate sandbox U-Boot - gleaned from /test/dm/test-dm.sh
88 NUM_CPUS=$(cat /proc/cpuinfo |grep -c processor)
90 make O=sandbox -s -j${NUM_CPUS}
92 # Check if U-Boot exists
93 if [ ! -x "$UBOOT" ]; then
104 rm -f ${MD5_FILE}.* ${OUT}.*
105 mkdir -p ${OUT_DIR}
109 # 2nd parameter is the filesystem - fat16 ext4 etc
110 # -F cant be used with fat as it means something else.
112 # Create image if not already present - saves time, while debugging
115 MKFS_OPTION="-F 16"
119 MKFS_OPTION="-F 32"
123 MKFS_OPTION="-F"
128 if [ ! -f "$1" ]; then
129 fallocate -l 3G "$1" &> /dev/null
130 if [ $? -ne 0 ]; then
131 echo fallocate failed - using dd instead
133 if [ $? -ne 0 ]; then
138 mkfs -t "$FS_TYPE" $MKFS_OPTION "$1" &> /dev/null
139 if [ $? -ne 0 -a "$FS_TYPE" = "fat" ]; then
141 mkfs -t vfat $MKFS_OPTION "$1" &> /dev/null
143 if [ $? -ne 0 ]; then
151 # 2nd parameter is file system type - fat16/ext4/...
154 # 5th parameter is fs/nonfs/sb - to dictate generic fs commands or
167 WRITE="write"
174 WRITE="write"
186 WRITE="save"
196 WRITE="save"
197 SUFFIX="fs -"
216 # In u-boot commands, <interface> stands for host or hostfs
217 # hostfs maps to the host fs.
218 # host maps to the "sb bind" that we do
224 # Test Case 1 - ls
225 ${PREFIX}ls host${SUFFIX} $6
227 ${PREFIX}ls host${SUFFIX} invalid_d
229 # We want ${PREFIX}size host 0:0 $3 for host commands and
230 # sb size hostfs - $3 for hostfs commands.
232 # Test Case 2a - size of small file
233 ${PREFIX}size host${SUFFIX} ${FPATH}$FILE_SMALL
236 # Test Case 2b - size of small file via a path using '..'
237 ${PREFIX}size host${SUFFIX} ${FPATH}SUBDIR/../$FILE_SMALL
242 # Test Case 3 - size of big file
243 ${PREFIX}size host${SUFFIX} ${FPATH}$FILE_BIG
251 # Test Case 4a - Read full 1MB of small file
252 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_SMALL
254 # Test Case 4b - Read full 1MB of small file
258 # Test Case 5a - First 1MB of big file
259 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x0
261 # Test Case 5b - First 1MB of big file
266 # Test Case 6a - Last 1MB of big file
267 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x9C300000
269 # Test Case 6b - Last 1MB of big file
274 # Test Case 7a - One from the last 1MB chunk of 2GB
275 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x7FF00000
277 # Test Case 7b - One from the last 1MB chunk of 2GB
282 # Test Case 8a - One from the start 1MB chunk from 2GB
283 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x80000000
285 # Test Case 8b - One from the start 1MB chunk from 2GB
290 # Test Case 9a - One 1MB chunk crossing the 2GB boundary
291 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG $length 0x7FF80000
293 # Test Case 9b - One 1MB chunk crossing the 2GB boundary
298 # Test Case 10 - 2MB chunk from the last 1MB of big file
299 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_BIG 0x00200000 0x9C300000
304 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_SMALL
305 # Write it back to test the writes
306 # Test Case 11a - Check that the write succeeded
307 ${PREFIX}${WRITE} host${SUFFIX} $addr ${FPATH}$FILE_WRITE \$filesize
309 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_WRITE
310 # Test Case 11b - Check md5 of written to is same as the one read from
317 # The write should fail, but the lookup should work
318 # Test Case 12 - Check directory traversal
319 ${PREFIX}${WRITE} host${SUFFIX} $addr ${FPATH}. 0x10
322 ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_SMALL
323 # Write it via "same directory", i.e. "." dirent
324 # Test Case 13a - Check directory traversal
325 ${PREFIX}${WRITE} host${SUFFIX} $addr ${FPATH}./${FILE_WRITE}2 \$filesize
327 ${PREFIX}load host${SUFFIX} $addr ${FPATH}./${FILE_WRITE}2
328 # Test Case 13b - Check md5 of written to is same as the one read from
332 ${PREFIX}load host${SUFFIX} $addr ${FPATH}${FILE_WRITE}2
333 # Test Case 13c - Check md5 of written to is same as the one read from
351 mkdir -p "$MOUNT_DIR"
352 sudo mount -o loop,rw "$1" "$MOUNT_DIR"
355 sudo mkdir -p "$MOUNT_DIR/SUBDIR"
361 if [ ! -f "${GB2p5}" ]; then
371 if [ ! -f "${MB1}" ]; then
378 sudo rm -f "${MB1}.w"
379 sudo rm -f "${MB1}.w2"
414 if [ $? -eq 0 ]; then
415 echo pass - "$1"
418 echo FAIL - "$1"
431 # md5sum in u-boot has output of form:
434 md5_src=`grep -A2 "$1" "$2" | grep "md5 for" | tr -d '\r'`
439 # - <md5>
441 md5_dst=`sed -n $4p $3`
463 grep -A7 "Test Case 1 " "$1" | egrep -iq "2621440000 *$4"
467 grep -A7 "Test Case 1 " "$1" | egrep -iq "1048576 *$3"
471 egrep -A3 "Test Case 2a " "$1" | grep -q "filesize=100000"
474 egrep -A3 "Test Case 2b " "$1" | grep -q "filesize=100000"
478 egrep -A3 "Test Case 3 " "$1" | grep -q "filesize=9c400000"
482 grep -A4 "Test Case 4a " "$1" | grep -q "filesize=100000"
487 grep -A4 "Test Case 5a " "$1" | grep -q "filesize=100000"
492 grep -A4 "Test Case 6a " "$1" | grep -q "filesize=100000"
497 grep -A4 "Test Case 7a " "$1" | grep -q "filesize=100000"
503 grep -A4 "Test Case 8a " "$1" | grep -q "filesize=100000"
509 grep -A4 "Test Case 9a " "$1" | grep -q "filesize=100000"
515 grep -A5 "Test Case 10 " "$1" | grep -q "filesize=100000"
518 # Check 1mb chunk write
519 grep -A2 "Test Case 11a " "$1" | grep -q '1048576 bytes written'
520 pass_fail "TC11: 1MB write to $3.w - write succeeded"
522 "TC11: 1MB write to $3.w - content verified"
525 grep -A4 "Test Case 12 " "$1" | grep -q 'Unable to write file'
526 pass_fail "TC12: 1MB write to . - write denied"
529 grep -A2 "Test Case 13a " "$1" | grep -q '1048576 bytes written'
530 pass_fail "TC13: 1MB write to ./$3.w2 - write succeeded"
532 "TC13: 1MB read from ./$3.w2 - content verified"
534 "TC13: 1MB read from $3.w2 - content verified"
550 grep -v -e "File System is consistent\|update journal finished" \
551 -e "reading .*\.file\|writing .*\.file.w" \
558 echo "--------------------------------------------"
575 # fs command, like load/size/write, the file system specific command
589 mkdir -p "$MOUNT_DIR"
592 uid="uid=`id -u`"
598 sudo mount -o loop,rw,$uid "$IMAGE" "$MOUNT_DIR"
611 echo "--------------------------------------------"
618 echo "--------------------------------------------"
619 if [ $TOTAL_FAIL -eq 0 ]; then