#!/bin/sh -e
# cyclictest measures event latency in Linux kernel by measuring the amount of
# time that passes between when a timer expires and when the thread which set
# the timer actually runs.
# shellcheck disable=SC1091
#cd 到相对目录下执行脚本文件
. ../../lib/sh-test-lib
#定义变量并赋值
OUTPUT="$(pwd)/output"
LOGFILE="${OUTPUT}/cyclictest.txt"
RESULT_FILE="${OUTPUT}/result.txt"
#可选参数赋初值,如果用户不指定的话。
PRIORITY="99"
INTERVAL="10000"
THREADS="1"
LOOPS="10000"
usage() {
echo "Usage: $0 [-p priority] [-i interval] [-t threads] [-l loops]" 1>&2
exit 1
}
#使用while循环来parse 可选参数
while getopts ":p:i:t:l:" opt; do
case "${opt}" in
p) PRIORITY="${OPTARG}" ;;
i) INTERVAL="${OPTARG}" ;;
t) THREADS="${OPTARG}" ;;
l) LOOPS="${OPTARG}" ;;
*) usage ;;
esac
done
#检查是否是root
! check_root && error_msg "Please run this script as root."
#调用函数新建文件夹
create_out_dir "${OUTPUT}"
# Run cyclictest.
#调用函数检查是arm还是x86
detect_abi
# shellcheck disable=SC2154
#根据abi的不同执行命令
./bin/"${abi}"/cyclictest -p "${PRIORITY}" -i "${INTERVAL}" -t "${THREADS}" \
-l "${LOOPS}" | tee "${LOGFILE}"
# Parse test log.
#parse test的log
tail -n "${THREADS}" "${LOGFILE}" \
| sed 's/T:/T: /' \
| awk '{printf("t%s-min-latency pass %s us\n", $2, $(NF-6))};
{printf("t%s-avg-latency pass %s us\n", $2, $(NF-2))};
{printf("t%s-max-latency pass %s us\n", $2, $NF)};' \
| tee -a "${RESULT_FILE}"
test-definitions/blob/master/auto-test/cyclictest/cyclictest.sh
最新推荐文章于 2023-07-01 17:29:53 发布