diff options
Diffstat (limited to 'automated/linux/cyclictest/cyclictest.sh')
-rwxr-xr-x | automated/linux/cyclictest/cyclictest.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/automated/linux/cyclictest/cyclictest.sh b/automated/linux/cyclictest/cyclictest.sh new file mode 100755 index 0000000..7586a84 --- /dev/null +++ b/automated/linux/cyclictest/cyclictest.sh @@ -0,0 +1,49 @@ +#!/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 +. ../../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 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 + +! check_root && error_msg "Please run this script as root." +[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)" +mkdir -p "${OUTPUT}" + +# Run cyclictest. +detect_abi +# shellcheck disable=SC2154 +./bin/"${abi}"/cyclictest -p "${PRIORITY}" -i "${INTERVAL}" -t "${THREADS}" \ + -l "${LOOPS}" | tee "${LOGFILE}" + +# 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}" |