Arthur She | 179825b | 2025-02-10 09:22:55 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | # Run the given command passed through parameters, if fails, try |
| 6 | # at most more N-times with a pause of M-seconds until success. |
| 7 | resilient_cmd() { |
| 8 | local cmd="$*" |
| 9 | local max_wait=10 |
| 10 | local sleep_body=2 |
| 11 | local iter=0 |
| 12 | |
| 13 | echo "Waiting for $cmd to complete" |
| 14 | while true; do |
| 15 | if ${cmd}; then |
| 16 | echo "$cmd job finished" |
| 17 | break |
| 18 | fi |
| 19 | |
| 20 | sleep ${sleep_body} |
| 21 | |
| 22 | iter=$(( iter + 1 )) |
| 23 | if [ ${iter} -ge ${max_wait} ]; then |
| 24 | return 1 |
| 25 | fi |
| 26 | done |
| 27 | return 0 |
| 28 | } |
| 29 | |
| 30 | # FIXME workaround clone_repos.sh script when using gerrit |
| 31 | unset GERRIT_PROJECT |
| 32 | unset GERRIT_BRANCH |
| 33 | unset GERRIT_REFSPEC |
| 34 | |
| 35 | if [ -z "${WORKSPACE}" ]; then |
| 36 | ## Local build |
| 37 | export WORKSPACE=${PWD} |
| 38 | fi |
| 39 | |
| 40 | cd ${WORKSPACE} |
| 41 | |
| 42 | # coverity-tf-misra: https://projects.linaro.org/browse/TFC-10 pending to |
| 43 | # be included in OpenCI, hence it is blocklisted for now. |
| 44 | |
| 45 | blocklist="blocklist.txt" |
| 46 | cat << EOF > "${blocklist}" |
| 47 | coverity-tf-misra |
| 48 | EOF |
| 49 | |
| 50 | if echo "${TEST_DESC}" | grep -F -f ${blocklist} - ; then |
| 51 | echo ${TEST_DESC} is blocklisted |
| 52 | exit 0 |
| 53 | fi |
| 54 | |
| 55 | mkdir -p ${WORKSPACE}/nfs/downloads/mbedtls |
| 56 | cd ${WORKSPACE}/nfs/downloads/mbedtls |
| 57 | curl --fail --connect-timeout 5 --retry 5 -sLSO -k -C - ${MBEDTLS_URL} |
| 58 | export mbedtls_archive=${WORKSPACE}/nfs/downloads/mbedtls/$(ls -1 mbedtls-*.tar.gz) |
| 59 | |
| 60 | # Path to root of CI repository |
| 61 | ci_root="${WORKSPACE}/tf-a-ci-scripts" |
| 62 | |
| 63 | export tf_downloads="https://downloads.trustedfirmware.org" |
| 64 | export tfa_downloads="${tf_downloads}/tf-a" |
| 65 | |
| 66 | # Fetch required firmware/binaries and place it at proper location |
| 67 | export nfs_volume="${WORKSPACE}/nfs" |
| 68 | project_filer="${nfs_volume}/projectscratch/ssg/trusted-fw" |
| 69 | mkdir -p ${project_filer} |
| 70 | |
| 71 | # fetch Juno rootfs, required by fvp |
| 72 | linaro_2001_release="/nfs/downloads/linaro/20.01" |
| 73 | cd ${linaro_2001_release} |
| 74 | resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo \ |
| 75 | lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz \ |
| 76 | https://releases.linaro.org/openembedded/juno-lsk/latest/lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz |
| 77 | |
| 78 | # export trace code coverage variable |
| 79 | export coverage_trace_plugin="${tf_downloads}/coverage-plugin/qa-tools/coverage-tool/coverage-plugin/coverage_trace.so" |
| 80 | |
| 81 | # FIXME: create temporal /arm softlinks. |
| 82 | # Reason behind is described at |
| 83 | # https://git.trustedfirmware.org/ci/dockerfiles.git/commit/?id=4e2c2c94e434bc8a9b25f5da7c6018a43db8cb2f |
| 84 | |
| 85 | # /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gcc |
| 86 | mkdir -p /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update |
| 87 | ln -s \ |
| 88 | ${TOOLS_DIR}/bin \ |
| 89 | /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update/bin |
| 90 | |
| 91 | # /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc |
| 92 | mkdir -p /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-10-2020-q4-major |
| 93 | ln -s \ |
| 94 | ${TOOLS_DIR}/gnu-rm/bin \ |
| 95 | /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-10-2020-q4-major/bin |
| 96 | |
| 97 | # /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- |
| 98 | mkdir -p /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu |
| 99 | ln -s ${TOOLS_DIR}/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin \ |
| 100 | /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin |
| 101 | |
| 102 | # CC=/arm/warehouse/Distributions/FA/ARMCompiler/6.18/19/standalone-linux-x86_64-rel/bin/armclang |
| 103 | mkdir -p /arm/warehouse/Distributions/FA/ARMCompiler/6.18/19/standalone-linux-x86_64-rel |
| 104 | ln -s ${TOOLS_DIR}/armclang-6.18/bin \ |
| 105 | /arm/warehouse/Distributions/FA/ARMCompiler/6.18/19/standalone-linux-x86_64-rel/bin |
| 106 | |
| 107 | # If build actually uses ArmClang, activate and verify UBL license |
| 108 | if echo ${TEST_CONFIG} | grep -q armclang && [ -n "${ARMCLANG_UBL_CODE}" ]; then |
| 109 | ${TOOLS_DIR}/armclang-6.18/bin/armlm activate --code ${ARMCLANG_UBL_CODE} |
| 110 | ${TOOLS_DIR}/armclang-6.18/bin/armlm inspect |
| 111 | ${TOOLS_DIR}/armclang-6.18/bin/armclang --vsn |
| 112 | fi |
| 113 | |
| 114 | # Mandatory workspace |
| 115 | export workspace="${workspace:-${WORKSPACE}/workspace}" |
| 116 | |
| 117 | # During feature development, we need incremental build, so don't run |
| 118 | # 'distlcean' on every invocation. |
| 119 | export dont_clean="${dont_clean:-1}" |
| 120 | |
| 121 | # Local paths to TF and TFTF repositories |
| 122 | export tf_root="${tf_root:-${WORKSPACE}/trusted-firmware-a}" |
| 123 | export tftf_root="${tftf_root:-${WORKSPACE}/tf-a-tests}" |
| 124 | export spm_root="${spm_root:-${WORKSPACE}/spm}" |
| 125 | |
| 126 | # We'd need to see the terminals during development runs, so no need for |
| 127 | # automation. |
| 128 | export test_run="${test_run:-1}" |
| 129 | |
| 130 | # By default, do not execute any run |
| 131 | export skip_runs="${skip_runs:-1}" |
| 132 | |
| 133 | # set linaro platform release folder |
| 134 | export linaro_2001_release="file://${linaro_2001_release}" |
| 135 | |
| 136 | export docker_registry="${DOCKER_REGISTRY}" |
| 137 | export juno_rootfs_url="${JUNO_ROOTFS_URL}" |
| 138 | |
| 139 | # Parse TEST_DESC and export test_group & tf_config and & run_config |
| 140 | test_desc="${test_desc:-$TEST_DESC}" |
| 141 | test_desc="${test_desc:?}" |
| 142 | |
| 143 | # Strip test suffix |
| 144 | test_desc="${test_desc%%.test}" |
| 145 | |
| 146 | lhs="$(echo "$test_desc" | awk -F: '{print $1}')" |
| 147 | rhs="$(echo "$test_desc" | awk -F: '{print $2}')" |
| 148 | |
| 149 | test_group="$(echo "$lhs" | awk -F% '{print $2}')" |
| 150 | build_config="$(echo "$lhs" | awk -F% '{print $3}')" |
| 151 | run_config="${rhs%.test}" |
| 152 | test_config="${TEST_CONFIG}" |
| 153 | |
| 154 | export BUILD_CONFIG="$build_config" |
| 155 | export RUN_CONFIG="$run_config" |
| 156 | export TEST_CONFIG="$test_config" |
| 157 | export TEST_GROUP="$test_group" |
| 158 | # Conditions for code coverage is that the run config has 'bmcov' is its name |
| 159 | # or the test group parameter has 'code-coverage' contained in its name. |
| 160 | export COVERAGE_ON=$((echo "$RUN_CONFIG" | grep -v 'aarch32' | |
| 161 | grep -qE 'bmcov' && echo 1) || |
| 162 | (echo "${TEST_GROUP}" | grep -v 'aarch32' | |
| 163 | grep -qE 'code-coverage' && echo 1) || |
| 164 | echo 0) |
| 165 | |
| 166 | # Run this script bash -x, and it gets passed downstream for debugging |
| 167 | if echo "$-" | grep -q "x"; then |
| 168 | bash_opts="-x" |
| 169 | fi |
| 170 | |
| 171 | mkdir -p "${workspace}" |
| 172 | bash $bash_opts "$ci_root/script/build_package.sh" |
| 173 | |
| 174 | # compress rootfs.bin file |
| 175 | for a in $(find ${workspace} -type d -name artefacts); do |
| 176 | for r in $(find $a -type f -name rootfs.bin -or -name busybox.bin); do |
| 177 | d=$(dirname $r); b=$(basename $r); cd "$d" && gzip "$b" |
| 178 | done |
| 179 | done |
| 180 | |
| 181 | cp -a $(find ${workspace} -type d -name artefacts) ${WORKSPACE}/ |