blob: 18e6ab49f535d205acb5f3cc9499e1b956310721 [file] [log] [blame]
Arthur She179825b2025-02-10 09:22:55 -08001#!/bin/bash
2
3set -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.
7resilient_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
31unset GERRIT_PROJECT
32unset GERRIT_BRANCH
33unset GERRIT_REFSPEC
34
35if [ -z "${WORKSPACE}" ]; then
36 ## Local build
37 export WORKSPACE=${PWD}
38fi
39
40cd ${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
45blocklist="blocklist.txt"
46cat << EOF > "${blocklist}"
47coverity-tf-misra
48EOF
49
50if echo "${TEST_DESC}" | grep -F -f ${blocklist} - ; then
51 echo ${TEST_DESC} is blocklisted
52 exit 0
53fi
54
55mkdir -p ${WORKSPACE}/nfs/downloads/mbedtls
56cd ${WORKSPACE}/nfs/downloads/mbedtls
57curl --fail --connect-timeout 5 --retry 5 -sLSO -k -C - ${MBEDTLS_URL}
58export mbedtls_archive=${WORKSPACE}/nfs/downloads/mbedtls/$(ls -1 mbedtls-*.tar.gz)
59
60# Path to root of CI repository
61ci_root="${WORKSPACE}/tf-a-ci-scripts"
62
63export tf_downloads="https://downloads.trustedfirmware.org"
64export tfa_downloads="${tf_downloads}/tf-a"
65
66# Fetch required firmware/binaries and place it at proper location
67export nfs_volume="${WORKSPACE}/nfs"
68project_filer="${nfs_volume}/projectscratch/ssg/trusted-fw"
69mkdir -p ${project_filer}
70
71# fetch Juno rootfs, required by fvp
72linaro_2001_release="/nfs/downloads/linaro/20.01"
73cd ${linaro_2001_release}
74resilient_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
79export 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
86mkdir -p /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update
87ln -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
92mkdir -p /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-10-2020-q4-major
93ln -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-
98mkdir -p /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu
99ln -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
103mkdir -p /arm/warehouse/Distributions/FA/ARMCompiler/6.18/19/standalone-linux-x86_64-rel
104ln -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
108if 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
112fi
113
114# Mandatory workspace
115export workspace="${workspace:-${WORKSPACE}/workspace}"
116
117# During feature development, we need incremental build, so don't run
118# 'distlcean' on every invocation.
119export dont_clean="${dont_clean:-1}"
120
121# Local paths to TF and TFTF repositories
122export tf_root="${tf_root:-${WORKSPACE}/trusted-firmware-a}"
123export tftf_root="${tftf_root:-${WORKSPACE}/tf-a-tests}"
124export spm_root="${spm_root:-${WORKSPACE}/spm}"
125
126# We'd need to see the terminals during development runs, so no need for
127# automation.
128export test_run="${test_run:-1}"
129
130# By default, do not execute any run
131export skip_runs="${skip_runs:-1}"
132
133# set linaro platform release folder
134export linaro_2001_release="file://${linaro_2001_release}"
135
136export docker_registry="${DOCKER_REGISTRY}"
137export juno_rootfs_url="${JUNO_ROOTFS_URL}"
138
139# Parse TEST_DESC and export test_group & tf_config and & run_config
140test_desc="${test_desc:-$TEST_DESC}"
141test_desc="${test_desc:?}"
142
143# Strip test suffix
144test_desc="${test_desc%%.test}"
145
146lhs="$(echo "$test_desc" | awk -F: '{print $1}')"
147rhs="$(echo "$test_desc" | awk -F: '{print $2}')"
148
149test_group="$(echo "$lhs" | awk -F% '{print $2}')"
150build_config="$(echo "$lhs" | awk -F% '{print $3}')"
151run_config="${rhs%.test}"
152test_config="${TEST_CONFIG}"
153
154export BUILD_CONFIG="$build_config"
155export RUN_CONFIG="$run_config"
156export TEST_CONFIG="$test_config"
157export 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.
160export 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
167if echo "$-" | grep -q "x"; then
168 bash_opts="-x"
169fi
170
171mkdir -p "${workspace}"
172bash $bash_opts "$ci_root/script/build_package.sh"
173
174# compress rootfs.bin file
175for 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
179done
180
181cp -a $(find ${workspace} -type d -name artefacts) ${WORKSPACE}/