diff options
author | Chase Qi <chase.qi@linaro.org> | 2016-08-31 11:57:26 +0800 |
---|---|---|
committer | Chase Qi <chase.qi@linaro.org> | 2016-09-01 16:26:23 +0800 |
commit | d469bcef58196c215a2c806014ab8c053d229f21 (patch) | |
tree | f86f9fddbb7aeab39ff5db43201f6552c593328b /automated/android/dd-wr-speed/device-script.sh | |
parent | 3d1bc8474e38b17ae4ee1660c2a2fc0edf023961 (diff) |
v2: android: add dd write/read speed test
Change-Id: Ia25948fa61f368da49ade20b315591301bf65071
Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'automated/android/dd-wr-speed/device-script.sh')
-rwxr-xr-x | automated/android/dd-wr-speed/device-script.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/automated/android/dd-wr-speed/device-script.sh b/automated/android/dd-wr-speed/device-script.sh new file mode 100755 index 0000000..66ce843 --- /dev/null +++ b/automated/android/dd-wr-speed/device-script.sh @@ -0,0 +1,62 @@ +#!/system/bin/sh + +ITERATION="$1" +PARTITION="$2" +OUTPUT="$3" + +if [ "$#" -ne 3 ]; then + echo "ERROR: Usage: $0 ITERATION PARTITION OUTPUT" + exit 1 +fi + +[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}-$(date +%Y%m%d%H%M%S)" +mkdir -p "${OUTPUT}" && cd "${OUTPUT}" + +# If partition specified, format it to vfat, and mount it to /mnt/dd_test. +# Then enter the mount point to do dd test. +if [ -n "${PARTITION}" ]; then + partition_name="$(basename "${PARTITION}")" + partition_numbers="$(grep "${partition_name}" /proc/partitions \ + | awk '{print $1","$2}')" + + if [ -z "${partition_numbers}" ]; then + echo "ERROR: ${PARTITION} NOT found" && exit 1 + else + # Attemp to umount it in case it is mounted by Android vold. + umount "/dev/block/vold/public:${partition_numbers}" > /dev/null 2>&1 + umount "${PARTITION}" > /dev/null 2>&1 + + echo "INFO: formatting ${PARTITION} to vfat..." + busybox mkfs.vfat "${PARTITION}" + sync && sleep 10 + + mkdir -p /mnt/dd_test + mount -t vfat "/dev/block/vold/public:${partition_numbers}" \ + /mnt/dd_test/ + if [ $? -eq 0 ]; then + echo "INFO: Mounted ${PARTITION} to /mnt/dd_test" + else + echo "ERROR: failed to mount ${PARTITION}" && exit 1 + fi + + cd /mnt/dd_test + echo "INFO: dd test directory: $(pwd)" + fi +fi + +# Run dd write/read test. +for i in $(seq "${ITERATION}"); do + echo + echo "INFO: Running dd write test [$i/${ITERATION}]" + echo 3 > /proc/sys/vm/drop_caches + busybox dd if=/dev/zero of=dd.img bs=1048576 count=1024 conv=fsync 2>&1 \ + | tee -a "${OUTPUT}"/dd-write-output.txt + + echo + echo "INFO: Running dd read test [$i/${ITERATION}]" + echo 3 > /proc/sys/vm/drop_caches + busybox dd if=dd.img of=/dev/null bs=1048576 count=1024 2>&1 \ + | tee -a "${OUTPUT}"/dd-read-output.txt + + rm dd.img +done |