From 48f4a4a692724719024ef49addf518333a732356 Mon Sep 17 00:00:00 2001 From: Chase Qi Date: Fri, 14 Apr 2017 17:23:55 +0800 Subject: automated: android: add bootchart test * Migrate bootchart to v2. * Generate bootchart graphic. Change-Id: Iea19523d30d036a8197ee6cfc1a39a58512725f7 Signed-off-by: Chase Qi --- automated/android/bootchart/bootchart.sh | 63 ++++++++++++++++++ automated/android/bootchart/bootchart.yaml | 34 ++++++++++ automated/android/bootchart/device-script.sh | 95 ++++++++++++++++++++++++++++ 3 files changed, 192 insertions(+) create mode 100755 automated/android/bootchart/bootchart.sh create mode 100644 automated/android/bootchart/bootchart.yaml create mode 100755 automated/android/bootchart/device-script.sh diff --git a/automated/android/bootchart/bootchart.sh b/automated/android/bootchart/bootchart.sh new file mode 100755 index 0000000..b34e35b --- /dev/null +++ b/automated/android/bootchart/bootchart.sh @@ -0,0 +1,63 @@ +#!/bin/sh -e +# shellcheck disable=SC1091 + +SKIP_INSTALL='false' +ANDROID_SERIAL="" +BOOT_TIMEOUT="300" +OPERATION="start" +BOOTCHART_TIME="120" +OUTPUT="$(pwd)/output" +RESULT_FILE="${OUTPUT}/result.txt" + +. ../../lib/sh-test-lib +. ../../lib/android-test-lib + +usage() { + echo "Usage: $0 [-S ] [-s ] [-t ] [-o ] [-T ]" 1>&2 + exit 1 +} + +while getopts ":S:s:t:o:T:" o; do + case "$o" in + S) SKIP_INSTALL="${OPTARG}" ;; + s) ANDROID_SERIAL="${OPTARG}" ;; + t) BOOT_TIMEOUT="${OPTARG}" ;; + o) OPERATION="${OPTARG}" ;; + T) BOOTCHART_TIME="${OPTARG}" ;; + *) usage ;; + esac +done + +initialize_adb +wait_boot_completed "${BOOT_TIMEOUT}" +create_out_dir "${OUTPUT}" +install_deps 'curl tar xz-utils bootchart pybootchartgui' "${SKIP_INSTALL}" + +adb_push "./device-script.sh" "/data/local/tmp/" +info_msg "device-${ANDROID_SERIAL}: About to run bootchart ${OPERATION}..." +adb shell "echo /data/local/tmp/device-script.sh ${OPERATION} ${BOOTCHART_TIME} | su" \ + | tee "${OUTPUT}/device-stdout.log" + +grep -E "^[a-z_]+: (pass|fail)" "${OUTPUT}/device-stdout.log"\ + | sed 's/://g' >> "${RESULT_FILE}" + +# Retrieving the collected data from target, and generate bootchart graphic. +if [ "${OPERATION}" = "stop" ]; then + FILES="header proc_stat.log proc_ps.log proc_diskstats.log" + for f in $FILES; do + adb_pull "/data/local/tmp/bootchart/$f" "${OUTPUT}" + done + + cd "${OUTPUT}" + # shellcheck disable=SC2086 + tar -czf "bootchart.tgz" $FILES + bootchart bootchart.tgz + if [ -f bootchart.png ]; then + report_pass "generate-bootchart-graphic" + else + report_fail "generate-bootchart-graphic" + fi + + # Compress raw data and bootchart graphic for file uploading. + tar caf "output-bootchart.tar.xz" bootchart.tgz bootchart.png +fi diff --git a/automated/android/bootchart/bootchart.yaml b/automated/android/bootchart/bootchart.yaml new file mode 100644 index 0000000..410948c --- /dev/null +++ b/automated/android/bootchart/bootchart.yaml @@ -0,0 +1,34 @@ +metadata: + name: bootchart + format: "Lava-Test-Shell Test Definition 1.0" + description: "Collect the bootchart data and try to analyse." + maintainer: + - yongqin.liu@linaro.org + - chase.qi@linaro.org + os: + - android + scope: + - functional + devices: + - juno + - hi6220-hikey + +params: + SKIP_INSTALL: "false" + # Specify device serial no. when more than one device connected. + ANDROID_SERIAL: "" + # Specify timeout in seconds for wait_boot_completed. + BOOT_TIMEOUT: "300" + # Available operations: start or stop. + OPERATION: "start" + BOOTCHART_TIME: "120" + # Specify url and token for publishing artifacts. + ARTIFACTORIAL_URL: "https://archive.validation.linaro.org/artifacts/team/qa/" + ARTIFACTORIAL_TOKEN: "" + +run: + steps: + - cd ./automated/android/bootchart/ + - ./bootchart.sh -S "${SKIP_INSTALL}" -t "${BOOT_TIMEOUT}" -s "${ANDROID_SERIAL}" -o "${OPERATION}" -T "${BOOTCHART_TIME}" + - ../../utils/upload-to-artifactorial.sh -a "./output/output-bootchart.tar.xz" -u "${ARTIFACTORIAL_URL}" -t "${ARTIFACTORIAL_TOKEN}" + - ../../utils/send-to-lava.sh ./output/result.txt diff --git a/automated/android/bootchart/device-script.sh b/automated/android/bootchart/device-script.sh new file mode 100755 index 0000000..902616a --- /dev/null +++ b/automated/android/bootchart/device-script.sh @@ -0,0 +1,95 @@ +#!/system/bin/sh +# shellcheck disable=SC2181 +# +# script to start and stop bootchart test. +# +# Copyright (C) 2014, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. +# +# owner: yongqin.liu@linaro.org +# +############################################################################### + +LOGROOT="/data/bootchart" +start_f="${LOGROOT}/start" +enabled_f="${LOGROOT}/enabled" +stop_f="${LOGROOT}/stop" + +start_bootchart(){ + echo "${BOOTCHART_TIME}" > ${start_f} + if [ $? -ne 0 ]; then + echo "start_bootchart: fail" + else + echo "start_bootchart: pass" + fi +} + +enabled_bootchart(){ + touch ${enabled_f} + if [ $? -ne 0 ]; then + echo "enabled_bootchart: fail" + else + echo "enabled_bootchart: pass" + fi +} + +stop_bootchart(){ + echo 1 > ${stop_f} + if [ $? -ne 0 ]; then + echo "stop_bootchart: fail" + else + echo "stop_bootchart: pass" + fi + rm -fr ${start_f} ${enabled_f} + if [ $? -ne 0 ]; then + echo "rm_start_file: fail" + else + echo "rm_start_file: pass" + fi +} + +main(){ + OPERATION="${1}" + if [ "X${OPERATION}" = "X" ]; then + OPERATION="stop" + fi + BOOTCHART_TIME="${2}" + if [ "X${BOOTCHART_TIME}" = "X" ]; then + BOOTCHART_TIME=120 + fi + export BOOTCHART_TIME + + case "X${OPERATION}" in + "Xstart") + start_bootchart + enabled_bootchart + ;; + "Xstop") + stop_bootchart + # Wait the file to be sync disk completely + sleep 5 + # copy bootchart logs to /data/local/tmp so that we can pull them + # without root permissoin. + cp -r /data/bootchart /data/local/tmp/ + ;; + *) + echo "bootchart: fail" + ;; + esac +} + +main "$@" -- cgit v1.2.3