Leonardo Sandoval | 9dfdd1b | 2020-08-06 17:08:11 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 2 | # |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 3 | # Copyright (c) 2019-2020, Arm Limited. All rights reserved. |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | set -e |
| 9 | |
| 10 | # Build |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 11 | export COVERAGE_ON=$(echo "$RUN_CONFIG" | grep -v 'aarch32' | grep -qE 'bmcov' && echo 1 || echo 0) |
| 12 | if [ $COVERAGE_ON -eq 1 ]; then |
| 13 | source "$CI_ROOT/script/build_bmcov.sh" |
| 14 | fi |
| 15 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 16 | "$CI_ROOT/script/build_package.sh" |
| 17 | |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 18 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 19 | if [ "$skip_runs" ]; then |
| 20 | exit 0 |
| 21 | fi |
| 22 | |
| 23 | # Execute test locally for FVP configs |
| 24 | if [ "$RUN_CONFIG" != "nil" ] && echo "$RUN_CONFIG" | grep -iq '^fvp'; then |
| 25 | "$CI_ROOT/script/run_package.sh" |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 26 | if [ $COVERAGE_ON -eq 1 ]; then |
| 27 | ELF_FOLDER="" |
| 28 | DEBUG_FOLDER=${artefacts}/debug |
| 29 | RELEASE_FOLDER=${artefacts}/release |
| 30 | if ls "${DEBUG_FOLDER}/"*.elf &> /dev/null;then |
| 31 | export ELF_FOLDER=$DEBUG_FOLDER |
| 32 | elif ls "${RELEASE_FOLDER}/"*.elf &> /dev/null;then |
| 33 | export ELF_FOLDER=$RELEASE_FOLDER |
| 34 | else |
| 35 | # If elf files are not present, report can't be produced |
| 36 | echo "ELF files not present, aborting reports..." |
| 37 | exit 0 |
| 38 | fi |
| 39 | export OUTDIR=${WORKSPACE}/html |
| 40 | test_config=${TEST_CONFIG} |
| 41 | if [ -n "$CC_SCP_REFSPEC" ]; then #SCP |
| 42 | export JENKINS_SOURCES_WORKSPACE="${scp_root:-$workspace}" |
| 43 | if grep -q "fvp-linux.sgi" <<< "$test_config"; then |
| 44 | export LIST_OF_BINARIES=${LIST_OF_BINARIES:-"scp_ram scp_rom mcp_rom"} |
| 45 | elif grep -q "fvp-sgm775" <<< "$test_config"; then |
| 46 | export LIST_OF_BINARIES=${LIST_OF_BINARIES:-"scp_ram scp_rom"} |
| 47 | fi |
| 48 | export OBJDUMP="$(which 'arm-none-eabi-objdump')" |
| 49 | export READELF="$(which 'arm-none-eabi-readelf')" |
| 50 | export REPO=SCP |
| 51 | else # TF-A |
| 52 | export JENKINS_SOURCES_WORKSPACE="${tf_root:-$workspace}" |
| 53 | export LIST_OF_BINARIES=${LIST_OF_BINARIES:-"bl1 bl2 bl31"} |
| 54 | export OBJDUMP="$(which 'aarch64-none-elf-objdump')" |
| 55 | export READELF="$(which 'aarch64-none-elf-readelf')" |
| 56 | export REPO=TRUSTED_FIRMWARE |
| 57 | fi |
| 58 | echo "Toolchain:$OBJDUMP" |
| 59 | |
| 60 | mkdir -p ${OUTDIR} |
| 61 | sync |
| 62 | sleep 5 #wait for trace files to be written |
| 63 | if [ $(ls -1 ${DEBUG_FOLDER}/${trace_file_prefix}-* 2>/dev/null | wc -l) != 0 ]; then |
| 64 | export TRACE_FOLDER=${DEBUG_FOLDER} |
| 65 | elif [ $(ls -1 ${RELEASE_FOLDER}/${trace_file_prefix}-* 2>/dev/null | wc -l) != 0 ]; then |
| 66 | export TRACE_FOLDER=${RELEASE_FOLDER} |
| 67 | else |
| 68 | echo "Trace files not present, aborting reports..." |
| 69 | exit 0 |
| 70 | fi |
| 71 | export REPORT_TITLE="Coverage Summary Report [Build:${BUILD_NUMBER}]" |
| 72 | # launch intermediate layer script |
| 73 | export CONFIG_JSON=${OUTDIR}/config_file.json |
| 74 | export OUTPUT_JSON=${OUTDIR}/output_file.json |
| 75 | export CSOURCE_FOLDER=source |
| 76 | export DEBUG_ELFS=${DEBUG_ELFS:-True} |
| 77 | prepare_json_configuration "${LIST_OF_BINARIES}" "${JENKINS_SOURCES_WORKSPACE}" |
| 78 | echo "Executing intermediate_layer.py ..." |
| 79 | python ${BMCOV_REPORT_FOLDER}/intermediate_layer.py --config-json "${CONFIG_JSON}" |
| 80 | ver_py=$(python -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]\).*/\1\2/') |
| 81 | if [ "$ver_py" = "27" ]; then |
| 82 | python ${BMCOV_REPORT_FOLDER}/gen-coverage-report.py --config ${BMCOV_REPORT_FOLDER}/config_atf.py \ |
| 83 | --prefix_workspace "$JENKINS_SOURCES_WORKSPACE" |
| 84 | else |
| 85 | echo "Python 2.7 is required for producing Bmcov reports" |
| 86 | fi |
| 87 | chmod 775 ${BMCOV_REPORT_FOLDER}/branch_coverage/branch_coverage.sh |
| 88 | echo "Running branch coverage..." |
| 89 | branch_folder=${OUTDIR}/lcov_report |
| 90 | mkdir -p ${branch_folder} |
| 91 | pushd ${BMCOV_REPORT_FOLDER}/branch_coverage |
| 92 | . branch_coverage.sh --workspace ${JENKINS_SOURCES_WORKSPACE} --json-path ${OUTPUT_JSON} --outdir ${branch_folder} |
| 93 | popd |
| 94 | export OUTDIR=${WORKSPACE}/html |
| 95 | # prepare static (Jenkins) and dynamic (python server) pages |
| 96 | prepare_html_pages |
| 97 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 98 | fi |