--------------------------------------------------------- mktest_files: script for generating random size long name files --------------------------------------------------------- Usage: ./1_mktest_files.sh count
count - number of files to be generated The output directory is: "./test_files" --------------------------------------------------------- copy_files: copy the test_files/* into test partition mount point --------------------------------------------------------- Usage: ./2_copy_files.sh mount_point ----------------------------------------------------------- fat_test.sh: test fat read by write commands to the device console ---------------------------------------------------------- This script send commands to U-Boot console. First specify few script variables, e.g: - TTY="/dev/ttyS0" - MMCDEV=0 - PARTITION=2 - LOAD_ADDR="0x40000000" usage: 1. Target: run: ums 0 mmc 0 2. Run script 1 and 2 to make and copy the test files onto the test partition by UMS 3. This script: - set test device $PARTITION and other variables in the script, which is required for sending proper commands - set $TTY in the script run: ./3_fat_test.sh 4. Compare the crc results on the target and device consoles (sorry for the mess on the console) Signed-off-by: Przemyslaw Marczak <p.marc...@samsung.com> --- 1_mktest_files.sh | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2_copy_files.sh | 20 ++++++++++++++ 3_fat_test.sh | 38 ++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100755 1_mktest_files.sh create mode 100755 2_copy_files.sh create mode 100755 3_fat_test.sh diff --git a/1_mktest_files.sh b/1_mktest_files.sh new file mode 100755 index 0000000..e9f4e26 --- /dev/null +++ b/1_mktest_files.sh @@ -0,0 +1,82 @@ +#!/bin/bash +# +# Copyright (C) 2014 Samsung Electronics +# Przemyslaw Marczak <p.marc...@samsung.com> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +F_CNT=${1} +OUT_DIR="./test_files" +# File max: 100k +f_max_size=255 + +# Minimal len of long name -> len+"xxxk.bin" +LONG_NAME_LEN=20 + +if [ ${#1} -eq 0 ] + then + echo "Bad arg!" + echo "usage:" + echo "./mktest_files.sh count" + exit +else + if [ -d $OUT_DIR ] + then + echo "Directory: \"$OUT_DIR\" exists - cleanup" + rm $OUT_DIR/* + else + echo "Test files directory: \"$OUT_DIR\"" + mkdir $OUT_DIR + fi + echo "Generating $1 files:" +fi + +###### +# 1. # Generate random size for the files +###### + +i=0 +for val in `rand -M $f_max_size -N $F_CNT -u` + do + f_size_list[$i]=$val +# echo "Size[$i]: ${f_size_list[$i]}" + i=$(($i+1)) +done + +###### +# 2. # Prepare the long name +###### +CHAR="_" + +for I in `seq 1 1 $LONG_NAME_LEN`; do + LONG_NAME="$LONG_NAME""$CHAR" +done + +###### +# 3. # Generate files with random data +###### +i=0 +# Set fat16 file extension (dot + 3 characters) +EXT=".bin" +for len_k in ${f_size_list[@]} + do + + prefix="$len_k""k" + + prefix_len=${#prefix} + long_name_len=${#LONG_NAME} + ext_len=${#EXT} + name=`echo "$prefix""$LONG_NAME" | head -c $long_name_len` + name=$name$EXT +# echo Name: $name len: ${#name} + + echo "$i Prefix: $prefix name len: ${#name} chars:" + full_name="$OUT_DIR/$name" + + echo "$full_name" + + dd if=/dev/urandom of=${full_name} bs=1k count=$len_k 2>/dev/null + + i=$(($i+1)) +done diff --git a/2_copy_files.sh b/2_copy_files.sh new file mode 100755 index 0000000..6bfefc6 --- /dev/null +++ b/2_copy_files.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Copyright (C) 2014 Samsung Electronics +# Przemyslaw Marczak <p.marc...@samsung.com> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +#MOUNT_POINT - for the fat16 partition, +# e.g. target partition using ums command + +MOUNT_POINT=$1 +DIR="test_files" + +for I in `ls -1 -S $DIR/`; do + echo Copying "$DIR/$I" to $DEV + cp "$DIR/$I" $MOUNT_POINT +done + +sync \ No newline at end of file diff --git a/3_fat_test.sh b/3_fat_test.sh new file mode 100755 index 0000000..07222a0 --- /dev/null +++ b/3_fat_test.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# +# Copyright (C) 2014 Samsung Electronics +# Przemyslaw Marczak <p.marc...@samsung.com> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +TTY="/dev/ttyS0" +MMCDEV=0 +PARTITION=2 +LOAD_ADDR="0x40000000" + +DIR="test_files" + +SPACE="_____________________________ " +CMD_1_2="setenv t \"fatload mmc $MMCDEV:$PARTITION $LOAD_ADDR '\$F';" +CMD_2_2="echo $SPACE File: '\$F'; crc $LOAD_ADDR '\$S'\"" +CMD="$CMD_1_2""$CMD_2_2" + +# Set command for loading DIR +echo "$CMD" > $TTY + +for I in `ls -1 -S $DIR`; + do + FILE="$DIR"/"$I" + # Hex size: + SIZE=`ls -l $FILE | awk '{printf("%#x\n", $5)}'` + CRC=`crc32 $FILE` + + echo + echo "File: $I" + echo " ==> $CRC" + + CMD="setenv F \'$I\'; setenv S $SIZE; run t;" + echo "echo" > $TTY + echo $CMD > $TTY +done -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot