From fed78723b9287cf7b76b75682b30b65dd763522a Mon Sep 17 00:00:00 2001 From: Chase Qi Date: Thu, 24 Nov 2016 12:27:59 +0800 Subject: automated: added Linux Kernel compilation test Change-Id: I5d0b6423b8d6267bfc9c558eb7637335541a5055 Signed-off-by: Chase Qi --- .../linux/kernel-compilation/kernel-compilation.sh | 72 ++++++++++++++++++++++ .../kernel-compilation/kernel-compilation.yaml | 37 +++++++++++ 2 files changed, 109 insertions(+) create mode 100755 automated/linux/kernel-compilation/kernel-compilation.sh create mode 100644 automated/linux/kernel-compilation/kernel-compilation.yaml (limited to 'automated/linux') diff --git a/automated/linux/kernel-compilation/kernel-compilation.sh b/automated/linux/kernel-compilation/kernel-compilation.sh new file mode 100755 index 0000000..1637c12 --- /dev/null +++ b/automated/linux/kernel-compilation/kernel-compilation.sh @@ -0,0 +1,72 @@ +#!/bin/sh -e + +# shellcheck disable=SC1091 +. ../../lib/sh-test-lib +OUTPUT="$(pwd)/output" +RESULT_FILE="${OUTPUT}/result.txt" +export RESULT_FILE +LOGFILE="${OUTPUT}/kernel-compilation.txt" +VERSION='4.4.34' +NPROC=$(nproc) + +usage() { + echo "Usage: $0 [-v version] [-s true|false]" 1>&2 + exit 1 +} + +while getopts "v:s:h" o; do + case "$o" in + v) VERSION="${OPTARG}" ;; + s) SKIP_INSTALL="${OPTARG}" ;; + h|*) usage ;; + esac +done + +dist_name +# shellcheck disable=SC2154 +case "${dist}" in + Debian|Ubuntu) pkgs="time bc xz-utils build-essential" ;; + CentOS|Fedora) pkgs="time bc xz gcc make" ;; +esac +! 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}" + +[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)" +mkdir -p "${OUTPUT}" +cd "${OUTPUT}" + +# Download and extract Kernel tarball. +major_version=$(echo "${VERSION}" | awk -F'.' '{print $1}') +wget "https://cdn.kernel.org/pub/linux/kernel/v${major_version}.x/linux-${VERSION}.tar.xz" +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. +detect_abi +# shellcheck disable=SC2154 +case "${abi}" in + arm64|armeabi) + make defconfig + { time -p make -j"${NPROC}" Image; } 2>&1 | tee "${LOGFILE}" + ;; + *) + error_msg "Unsupported architecture!" + ;; +esac + +measurement="$(grep "^real" "${LOGFILE}" | awk '{print $2}')" +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. +cd ../ +rm -rf "linux-${VERSION}"* diff --git a/automated/linux/kernel-compilation/kernel-compilation.yaml b/automated/linux/kernel-compilation/kernel-compilation.yaml new file mode 100644 index 0000000..ef85afd --- /dev/null +++ b/automated/linux/kernel-compilation/kernel-compilation.yaml @@ -0,0 +1,37 @@ +metadata: + name: kernel-compilation + format: "Lava-Test-Shell Test Definition 1.0" + description: "Compile kernel with defconfig on ARM64/ARM platform and + measure how long it takes." + maintainer: + - chase.qi@linaro.org + os: + - debian + - ubuntu + - fedora + - centos + scope: + - functional + - performance + environment: + - lava-test-shell + devices: + - hi6220-hikey + - apq8016-sbc + - mustang + - moonshot + - thunderX + - d03 + - d05 + +params: + # Specify longterm/stable Kernel version that availabe on: + # https://www.kernel.org/ + VERSION: "4.4.34" + SKIP_INSTALL: "false" + +run: + steps: + - cd ./automated/linux/kernel-compilation/ + - ./kernel-compilation.sh -v "${VERSION}" -s "${SKIP_INSTALL}" + - ../../utils/send-to-lava.sh ./output/result.txt -- cgit v1.2.3