aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaresh Kamboju <naresh.kamboju@linaro.org>2019-03-06 20:18:26 +0530
committerNaresh Kamboju <naresh.kamboju@linaro.org>2019-03-11 14:13:15 +0530
commit69774f1aebe9355ef5728997481f7828c53a8204 (patch)
tree8a6d2215e014de2cc461a635840335636f0d097c
parent75afd5b2c458d79187df0cfe2f0592721043b7a4 (diff)
perf: Adding perf test case for LKFT test planHEADmaster
Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
-rwxr-xr-xautomated/linux/perf/perf.sh117
-rw-r--r--automated/linux/perf/perf.yaml28
2 files changed, 145 insertions, 0 deletions
diff --git a/automated/linux/perf/perf.sh b/automated/linux/perf/perf.sh
new file mode 100755
index 0000000..88e47c9
--- /dev/null
+++ b/automated/linux/perf/perf.sh
@@ -0,0 +1,117 @@
+#!/bin/sh
+
+set -x
+
+# shellcheck disable=SC1091
+. ../../lib/sh-test-lib
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+export RESULT_FILE
+SKIP_INSTALL="true"
+# List of test cases
+TEST="record report stat test"
+# PERF version
+PERF_VERSION="$(uname -r | cut -d . -f 1-2)"
+
+usage() {
+ echo "Usage: $0 [-s <true|false>]" 1>&2
+ exit 1
+}
+
+while getopts "s:" arg; do
+ case "$arg" in
+ s) SKIP_INSTALL="${OPTARG}";;
+ *) usage ;;
+ esac
+done
+
+# Run perf record tests
+run_perf_record() {
+ # Test 'perf record'
+ info_msg "Performing perf record test..."
+ TCID="perf_record_test"
+ perf record -e cycles -o perf-lava-test.data ls -a 2>&1 | tee perf-record.log
+ samples=$(grep -ao "[0-9]\\+[ ]\\+samples" perf-record.log| cut -f 1 -d' ')
+ if [ "${samples}" -gt 1 ]; then
+ report_pass "${TCID}"
+ else
+ report_fail "${TCID}"
+ fi
+ rm perf-record.log
+}
+
+# Run perf report tests
+run_perf_report() {
+ # Test 'perf report'
+ info_msg "Performing perf report test..."
+ TCID="perf_report_test"
+ perf report -i perf-lava-test.data 2>&1 | tee perf-report.log
+ pcnt_samples=$(grep -c -e "^[ ]\\+[0-9]\\+.[0-9]\\+%" perf-report.log)
+ if [ "${pcnt_samples}" -gt 1 ]; then
+ report_pass "${TCID}"
+ else
+ report_fail "${TCID}"
+ fi
+ rm perf-report.log perf-lava-test.data
+}
+
+# Run perf stat tests
+run_perf_stat() {
+ # Test 'perf stat'
+ info_msg "Performing perf stat test..."
+ TCID="perf_stat_test"
+ perf stat -e cycles ls -a 2>&1 | tee perf-stat.log
+ cycles=$(grep -o "[0-9,]\\+[ ]\\+cycles" perf-stat.log | sed 's/,//g' | cut -f 1 -d' ')
+ if [ -z "${cycles}" ]; then
+ echo "${TCID}: skip"
+ else
+ if [ "${cycles}" -gt 1 ]; then
+ report_pass "${TCID}"
+ else
+ report_fail "${TCID}"
+ fi
+ fi
+ rm perf-stat.log
+}
+
+# Run perf test tests
+run_perf_test() {
+ # Test 'perf test'
+ info_msg "Performing 'perf test'..."
+ eval $(perf test -v)
+ report_pass "perf_test"
+
+}
+
+# Test run.
+! check_root && error_msg "This script must be run as root"
+create_out_dir "${OUTPUT}"
+
+info_msg "About to run perf test..."
+info_msg "Output directory: ${OUTPUT}"
+
+if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then
+ info_msg "install_perf skipped"
+else
+ dist_name
+ # shellcheck disable=SC2154
+ case "${dist}" in
+ debian|ubuntu)
+ pkgs="linux-tools-${PERF_VERSION} stress"
+ install_deps "${pkgs}" "${SKIP_INSTALL}"
+ ;;
+ centos|fedora)
+ pkgs="perf stress"
+ install_deps "${pkgs}" "${SKIP_INSTALL}"
+ ;;
+ *)
+ warn_msg "Unsupported distribution: package install skipped"
+ esac
+ info_msg "Run install_perf"
+ install_perf
+fi
+
+for tests in ${TEST}; do
+ run_perf_"${tests}"
+done
+exit 0
diff --git a/automated/linux/perf/perf.yaml b/automated/linux/perf/perf.yaml
new file mode 100644
index 0000000..951f763
--- /dev/null
+++ b/automated/linux/perf/perf.yaml
@@ -0,0 +1,28 @@
+metadata:
+ name: perf
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Perf is a profiler tool for Linux and is used to collect and analyze performance and trace data.
+ This test runs following perf commands: record(record events for later reporting), report(break
+ down events by process, function, etc), stat(obtain event counts) and test(Run sanity tests)."
+ maintainer:
+ - milosz.wasilewski@linaro.org
+ os:
+ - ubuntu
+ scope:
+ - performance
+ devices:
+ - dragonboard410c
+ - hi6220-hikey
+ - juno
+ - x15
+ - x86
+ environment:
+ - lava-test-shell
+params:
+ SKIP_INSTALL: true
+
+run:
+ steps:
+ - cd ./automated/linux/perf/
+ - ./perf.sh -s "${SKIP_INSTALL}"
+ - ../../utils/send-to-lava.sh ./output/result.txt