test-definitions/blob/master/auto-test/cyclictest/cyclictest.sh
2018-01-18 14:15
375 查看
#!/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/boost/boost.sh
- test-definitions/blob/master/auto-test/docker/docker.sh
- test-definitions/blob/master/auto-test/dsdbench/dsdbench.sh
- test-definitions/blob/master/auto-test/busybox/busybox.sh
- test-definitions/blob/master/auto-test/dstat/dstat.sh
- test-definitions/blob/master/auto-test/cassandra/cassandra.sh
- test-definitions/blob/master/auto-test/etcd/etcd.sh
- test-definitions/blob/master/auto-test/cassandra/cassandra-cpp-driver.sh
- test-definitions/blob/master/auto-test/ftp/ftp.sh
- test-definitions/blob/master/auto-test/go-bindata/go-bindata.sh
- test-definitions/blob/master/auto-test/gprof/gprof.sh
- test-definitions/blob/master/auto-test/kernel-compilation/kernel-compilation.sh
- test-definitions/blob/master/auto-test/hhvm/hhvm.sh
- /test-definitions/blob/master/auto-test/linpack/linpack.sh
- test-definitions/blob/master/auto-test/golang/golang.sh
- test-definitions/blob/master/auto-test/httperf-client/httperf.sh
- test-definitions/blob/master/auto-test/iostat/iostat.sh
- test-definitions/blob/master/auto-test/alisql/alisql.sh
- test-definitions/blob/master/auto-test/cockroach/cockroachInsecureTest.sh
- test-definitions/blob/master/auto-test/iperf/iperf.sh