www.pudn.com > emmc_test.zip > emmc_test.sh, change:2012-12-31,size:1974b


#!/system/bin/bash

dir1="/data"
dir2="/dev"
dir3="/cache"
dir4="/tmp"
file="$dir/iotest.txt"
subarea=""
size=0.75

recreate_data_file()
{
	if [ -f "$1" ];then
		rm $1
		touch $1
	fi
}

generate_1k()
{
        um=26
	alphabeta="a b c d e f g h i j k l m n o p q r s t u v w x y z" ;
	A=($alphabeta);
	let j=$$
	ran=`awk -v s=$j 'BEGIN{srand(s); print '\"${A[$((RANDOM%26))]}\"'}'`
	
	t_file=$1
	recreate_data_file $t_file
	c_text=""
	for ((i=1;i<1024;i=i+1))
	do
	    ran=`awk -v s=$j 'BEGIN{srand(s); print '\"${A[$((RANDOM%26))]}\"'}'`
	    c_text=$c_text"$ran"
	done
	echo $c_text >> $t_file
}

generate_1m()
{
	c_file=$1
	generate_1k $c_file
	t_file="/mnt/sdcard/tmp.txt"
	cat $c_file > $t_file
	for ((i=1;i<1024;i=i+1))
	do
		cat $t_file >> $c_file 
	done
	rm $t_file
}

create_exact_file()
{
	t_file="/mnt/sdcard/tmp.txt"
	cat $file > $t_file
	fill=`awk 'BEGIN{printf("%d", ('$size'*'$1'-'$2'))}'`
	echo "Start adding $fill""M to $subarea area"
	for ((i=1;i<$fill;i=i+1))
	do
		cat $t_file >> $file 
	done
	cat $file
	rm $t_file
	rm $file
}

while :
do
    for i in "$dir1" "$dir2" "$dir3";
    do
	subarea=$i
	#subarea=${!subarea}
	echo "prepare to write partition $subarea"
	file="$subarea/iotest.txt"
	echo "create $file"
	subarea=`echo $subarea | awk -F '/' '{print $2}'`
	total=`df | grep $subarea | awk -F ' ' '{print $2}'`
	total=`echo $total | awk -F 'M' '{print $1}'`
	used=`df | grep $subarea | awk -F ' ' '{print $3}'`
	if echo $used | grep 'M' > /dev/null;then 
	    used=`echo $used | awk -F 'M' '{print $1}'`
	    K_used=$(($used*1024))
	    M_used=$(($K_used/1024))
	    G_used=$(($M_used/1024/1024))
	else
	    used=`echo $used | awk -F 'K' '{print $1}'`
	    K_used=$(($used))
	    M_used=$(($K_used/1024))
	    G_used=$(($M_used/1024/1024))
	fi
	
	echo "total space = $total""M"
	echo "used space = $M_used""M"

	generate_1m $file
	create_exact_file $total $M_used;
	echo "Finish $subarea area writing!";

    done
done

#rm `find -name iotest.txt`