summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-02-21 17:53:26 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-03-16 13:03:43 +0000
commit952a2acef1ce36c4017e11b5718aef3427383307 (patch)
tree031cfbcda1e971ad49a84335fd57d9e92c731230
parent8fa58dc00765a2766d66099b4ed0588ed7400488 (diff)
downloadtest-definitions-pipe-952a2acef1ce36c4017e11b5718aef3427383307.tar.gz
automated: android: improve dd speed test
Change-Id: Ia8f6e0336b7d141e1079c7b8f1e26b51acfb4e5c Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rwxr-xr-xautomated/android/dd-wr-speed/dd-wr-speed.sh88
-rw-r--r--automated/android/dd-wr-speed/dd-wr-speed.yaml4
-rwxr-xr-xautomated/android/dd-wr-speed/device-script.sh29
3 files changed, 57 insertions, 64 deletions
diff --git a/automated/android/dd-wr-speed/dd-wr-speed.sh b/automated/android/dd-wr-speed/dd-wr-speed.sh
index bd38473..b094875 100755
--- a/automated/android/dd-wr-speed/dd-wr-speed.sh
+++ b/automated/android/dd-wr-speed/dd-wr-speed.sh
@@ -1,17 +1,21 @@
-#!/bin/sh
+#!/bin/sh -ex
HOST_OUTPUT="$(pwd)/output"
-DEVICE_OUTPUT="/sdcard/tests/dd-wr-speed"
-RESULT_FILE="${HOST_OUTPUT}/result.txt"
+LOCAL_DEVICE_OUTPUT="${HOST_OUTPUT}/device-output"
+DEVICE_OUTPUT="/data/local/tmp/dd-wr-speed"
+SN=""
+BOOT_TIMEOUT="300"
ITERATION="5"
PARTITION=""
+RESULT_FILE="${HOST_OUTPUT}/result.txt"
+export RESULT_FILE
usage() {
- echo "Usage: $0 [-p <partition>] [-i <iteration>] [-s <sn>]" 1>&2
+ echo "Usage: $0 [-p <partition>] [-i <iteration>] [-s <sn>] [-t <timeout>]" 1>&2
exit 1
}
-while getopts "p:i:s:" o; do
+while getopts ":p:i:s:t:" o; do
case "$o" in
# "/data" partition will be used by default. Use '-p' to specify an
# external partition as needed, the partition will be formatted to vfat,
@@ -21,58 +25,41 @@ while getopts "p:i:s:" o; do
i) ITERATION="${OPTARG}" ;;
# Specify device serial number when more than one device connected.
s) SN="${OPTARG}" ;;
+ t) BOOT_TIMEOUT="${OPTARG}" ;;
*) usage ;;
esac
done
+# shellcheck disable=SC1091
. ../../lib/sh-test-lib
+# shellcheck disable=SC1091
. ../../lib/android-test-lib
parse_output() {
- local test="$1"
- local test_case_id="${test}"
- local UNITS="MB/s"
-
- if ! [ -f "${HOST_OUTPUT}/${test}-output.txt" ]; then
- warn_msg "${test} result file missing"
- return
- fi
-
- # Fixup test case id with partition and filesystem.
- if [ -n "${PARTITION}" ]; then
- partition_name="$(basename "${PARTITION}")"
- test_case_id="${partition_name}-vfat-${test_case_id}"
- else
- filesystem="$(adb -s "${SN}" shell mount \
- | grep "/data" | awk '{print $3}')"
- test_case_id="emmc-${filesystem}-${test_case_id}"
+ test_case_id="$1"
+ if ! [ -f "${LOCAL_DEVICE_OUTPUT}/${test_case_id}-output.txt" ]; then
+ warn_msg "${test_case_id} result file missing"
+ return 1
fi
# Parse raw output and add results to ${RESULT_FILE}.
itr=1
- info_msg "Parsing ${test} output..."
- while read line; do
- if echo "${line}" | egrep -q "(M|G)B/s"; then
+ info_msg "Parsing ${test_case_id} output..."
+ while read -r line; do
+ if echo "${line}" | grep -E "(M|G)B/s"; then
# busybox dd print test result in the format "39.8MB/s".
- result="$(echo "${line}" | awk '{print $NF}')"
- units="$(printf "%s" "${result}" | tail -c 4)"
- measurement="$(printf "%s" "${result}" | tr -d "${units}")"
-
- if [ "${units}" = "GB/s" ]; then
- measurement=$(( measurement * 1024 ))
- elif [ "${units}" = "KB/s" ]; then
- measurement=$(( measurement / 1024 ))
- fi
-
- add_metric "${test_case_id}-itr${itr}" "pass" "${measurement}" "${UNITS}"
+ units=$(echo "${line}" | awk '{print substr($NF,(length($NF)-3),2)}')
+ measurement=$(echo "${line}" | awk '{print substr($NF,1,(length($NF)-4))}')
+ measurement=$(convert_to_mb "${measurement}" "${units}")
+ add_metric "${test_case_id}-itr${itr}" "pass" "${measurement}" "MB/s"
itr=$(( itr + 1 ))
fi
- done < "${HOST_OUTPUT}/${test}"-output.txt
+ done < "${LOCAL_DEVICE_OUTPUT}/${test_case_id}"-output.txt
# For multiple times dd test, calculate the mean, min and max values.
# Save them to ${RESULT_FILE}.
if [ "${ITERATION}" -gt 1 ]; then
- eval "$(grep "${test}" "${HOST_OUTPUT}"/result.txt \
+ eval "$(grep "${test_case_id}" "${HOST_OUTPUT}"/result.txt \
| awk '{
if(min=="") {min=max=$3};
if($3>max) {max=$3};
@@ -83,26 +70,31 @@ parse_output() {
print "mean="total/count, "min="min, "max="max;
}')"
- add_metric "${test_case_id}-mean" "pass" "${mean}" "${UNITS}"
- add_metric "${test_case_id}-min" "pass" "${min}" "${UNITS}"
- add_metric "${test_case_id}-max" "pass" "${max}" "${UNITS}"
+ # shellcheck disable=SC2154
+ add_metric "${test_case_id}-mean" "pass" "${mean}" "MB/s"
+ # shellcheck disable=SC2154
+ add_metric "${test_case_id}-min" "pass" "${min}" "MB/s"
+ # shellcheck disable=SC2154
+ add_metric "${test_case_id}-max" "pass" "${max}" "MB/s"
fi
}
# Test run.
-[ -d "${HOST_OUTPUT}" ] && mv "${HOST_OUTPUT}" "${HOST_OUTPUT}-$(date +%Y%m%d%H%M%S)"
-mkdir -p "${HOST_OUTPUT}"
+create_out_dir "${HOST_OUTPUT}"
+mkdir -p "${LOCAL_DEVICE_OUTPUT}"
initialize_adb
+wait_boot_completed "${BOOT_TIMEOUT}"
+
detect_abi
-install "../../bin/${abi}/busybox"
-install "./device-script.sh"
+# shellcheck disable=SC2154
+adb_push "../../bin/${abi}/busybox" "/data/local/tmp/bin/"
+adb_push "./device-script.sh" "/data/local/tmp/bin"
info_msg "About to run dd speed test on device ${SN}"
-adb -s "${SN}" shell device-script.sh "${ITERATION}" "${PARTITION}" "${DEVICE_OUTPUT}" 2>&1 \
- | tee "${HOST_OUTPUT}"/device-run.log
+adb -s "${SN}" shell "echo /data/local/tmp/bin/device-script.sh ${ITERATION} ${DEVICE_OUTPUT} ${PARTITION} | su" 2>&1 | tee "${HOST_OUTPUT}/device-stdout.log"
-pull_output "${DEVICE_OUTPUT}" "${HOST_OUTPUT}"
+adb_pull "${DEVICE_OUTPUT}" "${LOCAL_DEVICE_OUTPUT}"
parse_output "dd-write"
parse_output "dd-read"
diff --git a/automated/android/dd-wr-speed/dd-wr-speed.yaml b/automated/android/dd-wr-speed/dd-wr-speed.yaml
index f7b59f1..3abddc2 100644
--- a/automated/android/dd-wr-speed/dd-wr-speed.yaml
+++ b/automated/android/dd-wr-speed/dd-wr-speed.yaml
@@ -24,9 +24,11 @@ params:
# Specify device serial number for adb connection if more than one device
# connected.
SN: ""
+ # Specify timeout in seconds for wait_boot_completed
+ BOOT_TIMEOUT: "300"
run:
steps:
- cd ./automated/android/dd-wr-speed
- - ./dd-wr-speed.sh -p "${PARTITION}" -i "${ITERATION}" -s "${SN}"
+ - ./dd-wr-speed.sh -p "${PARTITION}" -i "${ITERATION}" -s "${SN}" -t "${BOOT_TIMEOUT}"
- ../../utils/send-to-lava.sh ./output/result.txt
diff --git a/automated/android/dd-wr-speed/device-script.sh b/automated/android/dd-wr-speed/device-script.sh
index 66ce843..86f3643 100755
--- a/automated/android/dd-wr-speed/device-script.sh
+++ b/automated/android/dd-wr-speed/device-script.sh
@@ -1,39 +1,38 @@
-#!/system/bin/sh
+#!/system/bin/sh -ex
ITERATION="$1"
-PARTITION="$2"
-OUTPUT="$3"
+OUTPUT="$2"
+PARTITION="$3"
+export PATH="/data/local/tmp/bin:${PATH}"
-if [ "$#" -ne 3 ]; then
- echo "ERROR: Usage: $0 ITERATION PARTITION OUTPUT"
+if [ "$#" -lt 2 ]; then
+ echo "ERROR: Usage: $0 <iteration> <output> <partition>"
exit 1
fi
-[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}-$(date +%Y%m%d%H%M%S)"
+[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date -r "${OUTPUT}" +%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}')"
+ partition_name=$(basename "${PARTITION}")
+ # shellcheck disable=SC2016
+ partition_numbers=$(grep "${partition_name}" /proc/partitions | busybox 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
+ umount "/dev/block/vold/public:${partition_numbers}" > /dev/null 2>&1 || true
+ umount "${PARTITION}" > /dev/null 2>&1 || true
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
+ if mount -t vfat "${PARTITION}" /mnt/dd_test/; then
echo "INFO: Mounted ${PARTITION} to /mnt/dd_test"
else
echo "ERROR: failed to mount ${PARTITION}" && exit 1
@@ -58,5 +57,5 @@ for i in $(seq "${ITERATION}"); do
busybox dd if=dd.img of=/dev/null bs=1048576 count=1024 2>&1 \
| tee -a "${OUTPUT}"/dd-read-output.txt
- rm dd.img
+ rm -f dd.img
done