blob: 1dd56789138b8b76c6aae215df262db6af3f728e [file] [log] [blame]
Chase Qia4ae6ae2017-01-19 19:21:22 +08001#!/bin/sh -e
2# signaltest is a RT signal roundtrip test software.
3
4# shellcheck disable=SC1091
5. ../../lib/sh-test-lib
6
7OUTPUT="$(pwd)/output"
8LOGFILE="${OUTPUT}/signaltest.txt"
9RESULT_FILE="${OUTPUT}/result.txt"
10
11PRIORITY="99"
12THREADS="2"
13LOOPS="10000"
14
15usage() {
16 echo "Usage: $0 [-p priority] [-t threads] [-l loops]" 1>&2
17 exit 1
18}
19
20while getopts ":p:t:l:" opt; do
21 case "${opt}" in
22 p) PRIORITY="${OPTARG}" ;;
23 t) THREADS="${OPTARG}" ;;
24 l) LOOPS="${OPTARG}" ;;
25 *) usage ;;
26 esac
27done
28
29! check_root && error_msg "Please run this script as root."
Daniel Díaz6f49a1b2017-02-15 18:56:15 -060030create_out_dir "${OUTPUT}"
Chase Qia4ae6ae2017-01-19 19:21:22 +080031
32# Run signaltest.
Lei Yang168c8b72017-10-23 11:01:31 +080033if ! binary=$(which signaltest); then
34 detect_abi
35 # shellcheck disable=SC2154
36 binary="./bin/${abi}/signaltest"
37fi
38"${binary}" -p "${PRIORITY}" -t "${THREADS}" -l "${LOOPS}" \
Chase Qia4ae6ae2017-01-19 19:21:22 +080039 | tee "${LOGFILE}"
40
41# Parse test log.
42tail -n 1 "${LOGFILE}" \
43 | awk '{printf("min-latency pass %s us\n", $(NF-6))};
44 {printf("avg-latency pass %s us\n", $(NF-2))};
45 {printf("max-latency pass %s us\n", $NF)};' \
46 | tee -a "${RESULT_FILE}"