#!/bin/sh -e #-e表示遇到错误就退出
#定义函数说明这个脚本的用法
usage() {
echo "Usage: $0 <-c cpus> <-s [true|false]>" 1>&2
echo " -c CPU's to isolate and verify"
echo " -s Skip dependenciy installs"
echo " -t Git tag to use"
echo " example:"
echo " $0 -c 1,2 -s false -t v0.2"
exit 1
}
#parse 可选参数
while getopts "c:s:t:" o; do
case "$o" in
c) CPUS="${OPTARG}" ;;
s) SKIP_INSTALL="${OPTARG}" ;;
t) GIT_TAG="${OPTARG}" ;;
*) usage ;;
esac
done
#-z 表示是否为零。检查下面三个变量是否存在,如果不存在的话,则输出usage函数
[ -z "${CPUS}" ] && usage
[ -z "${SKIP_INSTALL}" ] && usage
[ -z "${GIT_TAG}" ] && usage
#执行脚本
. ../../lib/sh-test-lib
#变量赋值
OUTPUT="$(pwd)/output"
RESULT_FILE="${OUTPUT}/result.txt"
TEST_LOG="${OUTPUT}/isolation-test-output.txt"
create_out_dir "${OUTPUT}"
#符合条件的话,通过clone 命令clone仓库
if [ "${SKIP_INSTALL}" = "false" ] || [ "${SKIP_INSTALL}" = "False" ]; then
install_deps "git stress cpuset gzip"
git clone git://git.linaro.org/lng/task-isolation.git
fi
cd task-isolation
#切换到特定的分支
git checkout tags/"${GIT_TAG}" -b "${GIT_TAG}"
#执行这个脚本
./isolate-task.sh -v -c "${CPUS}" sleep "10" 2>&1 | tee "${TEST_LOG}"
#从log中找特定的输出,并把log输出到最终的文件中.
grep TEST_ISOLATION_CORE_ "${TEST_LOG}" > "${RESULT_FILE}"
test-definitions/blob/master/auto-test/isolate-task/isolate-task-verify.sh
最新推荐文章于 2022-03-16 18:40:44 发布