summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerin.liu <erin.liu@linaro.org>2016-09-30 07:43:30 +0100
committerChase Qi <chase.qi@linaro.org>2017-04-27 17:33:59 +0800
commitd92cc5a7e7461e7fe493a3a1be0bbdc7a94f9892 (patch)
tree5841fbad10d91053a992ebe88f90ad093448ca7e
parent8a3eb925abe3382ffb4a53bcac18becb87dee8c7 (diff)
downloadtest-definitions-pipe-d92cc5a7e7461e7fe493a3a1be0bbdc7a94f9892.tar.gz
automated: android: add monkey test case
Change-Id: I3eeabe9bdeb74cc90d9f49d18359a4d7a304388e Signed-off-by: erin.liu <erin.liu@linaro.org>
-rwxr-xr-xautomated/android/monkey/monkey.sh77
-rwxr-xr-xautomated/android/monkey/monkey.yaml42
2 files changed, 119 insertions, 0 deletions
diff --git a/automated/android/monkey/monkey.sh b/automated/android/monkey/monkey.sh
new file mode 100755
index 0000000..80130cd
--- /dev/null
+++ b/automated/android/monkey/monkey.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+# shellcheck disable=SC1090
+
+TEST_DIR=$(dirname "$(realpath "$0")")
+HOST_OUTPUT="${TEST_DIR}/output"
+LOGFILE="${HOST_OUTPUT}/monkey-test-output.txt"
+BLACKLIST_FILE="${HOST_OUTPUT}/blacklist.txt"
+RESULT_FILE="${HOST_OUTPUT}/result.txt"
+export RESULT_FILE
+
+usage() {
+ echo "Usage: $0 [-s <android_serial>] [-t <boot_timeout>] [-p <monkey_params>] [-b <blacklist>] [-e <event_count>] [-t <throttle>]" 1>&2
+ echo "You can input no parameter and use the default value:" 1>&2
+ echo "black_list: setting" 1>&2
+ echo "monkey_params: --ignore-timeouts --ignore-security-exceptions --kill-process-after-error -v -v -v" 1>&2
+ echo "event_count: 500" 1>&2
+ echo "throttle: 200" 1>&2
+ exit 1
+}
+
+# Some default parameters
+ANDROID_SERIAL=""
+BOOT_TIMEOUT="300"
+BLACKLIST="com.android.development_settings com.android.music com.android.deskclock"
+MONKEY_PARAMS="-s 1 --pct-touch 10 --pct-motion 20 --pct-nav 20 --pct-majornav 30 --pct-appswitch 20"
+EVENT_COUNT="1000"
+THROTTLE="200"
+
+while getopts ":s:t:b:p:e:T:h" opt; do
+ case "$opt" in
+ s) ANDROID_SERIAL="${OPTARG}" ;;
+ t) BOOT_TIMEOUT="${OPTARG}" ;;
+ b) BLACKLIST="${OPTARG}" ;;
+ p) MONKEY_PARAMS="${OPTARG}" ;;
+ e) EVENT_COUNT="${OPTARG}" ;;
+ T) THROTTLE="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+. "${TEST_DIR}/../../lib/sh-test-lib"
+. "${TEST_DIR}/../../lib/android-test-lib"
+
+initialize_adb
+wait_boot_completed "${BOOT_TIMEOUT}"
+create_out_dir "${HOST_OUTPUT}"
+
+# Read blacklist and write to blacklist.txt
+arr=$(echo "$BLACKLIST" | tr "," " ")
+info_msg "--- blacklist ---"
+for s in $arr
+do
+ echo "$s"
+ echo "$s" >> "$BLACKLIST_FILE"
+done
+
+adb_push "$BLACKLIST_FILE" "/data/local/tmp/"
+BLACKLIST="/data/local/tmp/blacklist.txt"
+
+info_msg "device-${ANDROID_SERIAL}: About to run monkey..."
+adb shell monkey "${MONKEY_PARAMS}" --pkg-blacklist-file "${BLACKLIST}" --throttle "${THROTTLE}" "${EVENT_COUNT}" 2>&1 \
+ | tee "${LOGFILE}"
+
+# Parse test log.
+grep "Events injected: ${EVENT_COUNT}" "${LOGFILE}"
+check_return "monkey-test-run"
+
+if grep -q "Network stats: elapsed time=" "${LOGFILE}"; then
+ grep "Network stats: elapsed time=" "${LOGFILE}" \
+ | awk -F'=' '{print $2}' \
+ | awk '{print $1}' \
+ | sed 's/ms//g' \
+ | awk '{printf("monkey-network-stats pass %s ms\n", $1)}' \
+ | tee -a "${RESULT_FILE}"
+else
+ report_fail "monkey-network-stats"
+fi
diff --git a/automated/android/monkey/monkey.yaml b/automated/android/monkey/monkey.yaml
new file mode 100755
index 0000000..d5aab2c
--- /dev/null
+++ b/automated/android/monkey/monkey.yaml
@@ -0,0 +1,42 @@
+metadata:
+ name: monkey
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Monkey performs stress testing for stability using monkey
+ command which generates pesudo-random streams of user events
+ such as clicks, touches, or gestures as well as some system
+ level events."
+ maintainer:
+ - erin.liu@linaro.org
+ - chase.qi@linaro.org
+ os:
+ - android
+ devices:
+ - hi6220-hikey
+ - apq8016-sbc
+ - juno
+ scope:
+ - functional
+ - performance
+ environment:
+ - lava-test-shell
+ - local-test-runner
+
+params:
+ # Specify device serial no. when more than one device connected.
+ ANDROID_SERIAL: ""
+ # Specify timeout in seconds for wait_boot_completed.
+ BOOT_TIMEOUT: "300"
+ # Blacklist packages known to crash.
+ BLACKLIST: "com.android.development_settings com.android.music com.android.deskclock"
+ # Basic monkey comand parameters.
+ MONKEY_PARAMS: "-s 1 --pct-touch 10 --pct-motion 20 --pct-nav 20 --pct-majornav 30 --pct-appswitch 20"
+ # The number of monkey event.
+ EVENT_COUNT: "1000"
+ # The interval of monkey event.
+ THROTTLE: "200"
+
+run:
+ steps:
+ - cd ./automated/android/monkey
+ - ./monkey.sh -s "${ANDROID_SERIAL}" -t "${BOOT_TIMEOUT}" -b "${BLACKLIST}" -p "${MONKEY_PARAMS}" -e "${EVENT_COUNT}" -T "${THROTTLE}"
+ - ../../utils/send-to-lava.sh ./output/result.txt