博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
test-definitions/blob/master/auto-test/kernel-compilation/kernel-compilation.sh
阅读量:4214 次
发布时间:2019-05-26

本文共 2106 字,大约阅读时间需要 7 分钟。

#!/bin/sh -e# shellcheck disable=SC1091. ../../lib/sh-test-libOUTPUT="$(pwd)/output"RESULT_FILE="${OUTPUT}/result.txt"export RESULT_FILELOGFILE="${OUTPUT}/kernel-compilation.txt"VERSION='4.4.34'NPROC=$(nproc)#定义一个函数说明这个脚本该如何使用usage() {    echo "Usage: $0 [-v version] [-s true|false]" 1>&2    exit 1}#parse 可选参数while getopts "v:s:h" o; do    case "$o" in        v) VERSION="${OPTARG}" ;;        s) SKIP_INSTALL="${OPTARG}" ;;        h|*) usage ;;    esacdone#执行函数得到发型板的名字dist_name# shellcheck disable=SC2154#目前只支持两类kernelcase "${dist}" in    debian|ubuntu) pkgs="wget time bc xz-utils build-essential" ;;    centos|fedora) pkgs="wget time bc xz gcc make" ;;esac#检查是否root 用户。非root用户的话,说出错误日志! check_root && error_msg "You need to be root to install packages!"# install_deps supports the above distributions.# It will skip package installation on other distributions by default.#安装必须的包install_deps "${pkgs}" "${SKIP_INSTALL}"create_out_dir "${OUTPUT}"cd "${OUTPUT}"# Download and extract Kernel tarball.#从kernel 官网下载用户指定版本的kernelmajor_version=$(echo "${VERSION}" | awk -F'.' '{print $1}')wget "https://cdn.kernel.org/pub/linux/kernel/v${major_version}.x/linux-${VERSION}.tar.xz"#解压tar 包,并cd到其目录下面tar xf "linux-${VERSION}.tar.xz"cd "linux-${VERSION}"# Compile Kernel with defconfig.# It is native not cross compiling.# It will not work on x86.#检查当前平台是arm64 还是x86detect_abi# shellcheck disable=SC2154case "${abi}" in    arm64|armeabi)		#生成.config        make defconfig		#开始build kernel.前面加time 表示会统计build kernel 用了多久的时间        { time -p make -j"${NPROC}" Image; } 2>&1 | tee "${LOGFILE}"        ;;    *)        error_msg "Unsupported architecture!"        ;;esac#从time -p输出的log中得到real的时间measurement="$(grep "^real" "${LOGFILE}" | awk '{print $2}')"#在特定目录下查找Image,如果可以查到说明kernel 编译通过if egrep "arch/.*/boot/Image" "${LOGFILE}"; then    report_pass "kernel-compilation"    add_metric "kernel-compilation-time" "pass" "${measurement}" "seconds"else    report_fail "kernel-compilation"    add_metric "kernel-compilation-time" "fail" "${measurement}" "seconds"fi# Cleanup.#删除kernel 目录cd ../rm -rf "linux-${VERSION}"*

转载地址:http://uknmi.baihongyu.com/

你可能感兴趣的文章
通过FTP服务的winsockes录制脚本
查看>>
LRwinsocket协议测试AAA服务器
查看>>
Net远程管理实验
查看>>
反病毒专家谈虚拟机技术 面临两大技术难题
查看>>
几种典型的反病毒技术:特征码技术、覆盖法技术等
查看>>
Software Security Testing软件安全测试
查看>>
论文浅尝 | 通过共享表示和结构化预测进行事件和事件时序关系的联合抽取
查看>>
论文浅尝 | GMNN: Graph Markov Neural Networks
查看>>
廖雪峰Python教程 学习笔记3 hello.py
查看>>
从内核看epoll的实现(基于5.9.9)
查看>>
python与正则表达式
查看>>
安装.Net Framework 4.7.2时出现“不受信任提供程序信任的根证书中终止”的解决方法
查看>>
input type=“button“与input type=“submit“的区别
查看>>
解决Github代码下载慢问题!
查看>>
LeetCode-栈|双指针-42. 接雨水
查看>>
Linux文件和设备编程
查看>>
文件描述符
查看>>
终端驱动程序:几个简单例子
查看>>
HTML条件注释
查看>>
内核态与用户态
查看>>