From: 이춘석/동작제어Lab(SR)/Senior Engineer/삼성전자 Date: Thu, 19 Apr 2018 23:46:56 +0000 (+0900) Subject: Add coverage report script for CI (#801) X-Git-Tag: 0.1~171 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f8f71a72cb4bca028551a4f2c9f453928edfd86;p=platform%2Fcore%2Fml%2Fnnfw.git Add coverage report script for CI (#801) This script is used on CI to generate lcov coverage info. Signed-off-by: Chunseok Lee --- diff --git a/ci/docker_coverage_report.sh b/ci/docker_coverage_report.sh new file mode 100755 index 0000000..a311b2e --- /dev/null +++ b/ci/docker_coverage_report.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-nnfw_docker} + +SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +HOST_HOME=$SCRIPT_ROOT/../ +DOCKER_HOME=/home + +GIT_SSL_NO_VERIFY=1 + +DOCKER_VOLUMES+=" -v $HOST_HOME:$DOCKER_HOME" + +DOCKER_ENV_VARS+=" -e http_proxy" +DOCKER_ENV_VARS+=" -e no_proxy" +DOCKER_ENV_VARS+=" -e GIT_SSL_NO_VERIFY" + +DOCKER_RUN_OPTS="--rm" +DOCKER_RUN_OPTS+=" -w $DOCKER_HOME" + + +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME sh -c "./ci/gen_coverage_report.sh" + +BUILD_RESULT=$? + +# Newly created files during above docker run can have different ownership. +# This may cause some problems, for example, some jenkins slaves or developers +# can't remove built files due to lack of permission. +# To address this issue, let's change owner of all files +# in NNFW to owner of NNFW. +NNFW_OWNER_UID=$(stat -c "%u" $HOST_HOME) +NNFW_OWNER_GID=$(stat -c "%g" $HOST_HOME) + +CMD="chown -R $NNFW_OWNER_UID:$NNFW_OWNER_GID $DOCKER_HOME" +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME $CMD + +exit $BUILD_RESULT + diff --git a/ci/gen_coverage_report.sh b/ci/gen_coverage_report.sh new file mode 100755 index 0000000..6169dc3 --- /dev/null +++ b/ci/gen_coverage_report.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# This file is based on https://github.sec.samsung.net/STAR/nncc/pull/80 + +SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +NNFW_ROOT=$SCRIPT_ROOT/.. + +LCOV_PATH=$(command -v lcov) +GENHTML_PATH=$(command -v genhtml) + +if [[ -z "${LCOV_PATH}" ]]; then + echo "ERROR: 'lcov' is not found" + exit 255 +fi + +if [[ -z "${GENHTML_PATH}" ]]; then + echo "ERROR: 'genhtml' is not found" + exit 255 +fi + +OUTPUT_PATH="$1" + +if [[ -z "${OUTPUT_PATH}" ]]; then + OUTPUT_PATH="$NNFW_ROOT/coverage" +fi + +if [[ -e "${OUTPUT_PATH}" ]]; then + echo "ERROR: '${OUTPUT_PATH}' already exists" + exit 255 +fi + +mkdir -p "${OUTPUT_PATH}" + +RAW_COVERAGE_INFO_PATH="${OUTPUT_PATH}/coverage.raw.info" +SRC_COVERAGE_INFO_PATH="${OUTPUT_PATH}/coverage.src.info" +TOOLS_COVERAGE_INFO_PATH="${OUTPUT_PATH}/coverage.tools.info" +FINAL_COVERAGE_INFO_PATH="${OUTPUT_PATH}/coverage.info" +HTML_PATH="${OUTPUT_PATH}/html" +COVERTURA_PATH="${OUTPUT_PATH}/nnfw_coverage.xml" + +"${LCOV_PATH}" -c -d "${NNFW_ROOT}" -o "${RAW_COVERAGE_INFO_PATH}" +"${LCOV_PATH}" -e "${RAW_COVERAGE_INFO_PATH}" -o "${SRC_COVERAGE_INFO_PATH}" '/home/src/*' +"${LCOV_PATH}" -e "${RAW_COVERAGE_INFO_PATH}" -o "${TOOLS_COVERAGE_INFO_PATH}" '/home/tools/*' +"${LCOV_PATH}" -a "${SRC_COVERAGE_INFO_PATH}" -a "${TOOLS_COVERAGE_INFO_PATH}" -o "${FINAL_COVERAGE_INFO_PATH}" +"${LCOV_PATH}" -r "${FINAL_COVERAGE_INFO_PATH}" -o "${FINAL_COVERAGE_INFO_PATH}" '/home/src/runtime/test/*' +"${GENHTML_PATH}" "${FINAL_COVERAGE_INFO_PATH}" --output-directory "${HTML_PATH}" + +tar -zcf "${OUTPUT_PATH}"/coverage_report.tar.gz "${HTML_PATH}" +$NNFW_ROOT/ci/lcov-to-covertura-xml.sh "${FINAL_COVERAGE_INFO_PATH}" -o "${COVERTURA_PATH}"