blob: d6df203cf86e81e8bd6edbc2ca07556e6209b6ca [file] [log] [blame]
Fathi Boudra9e402bf2019-12-05 11:16:41 +02001#!/bin/bash
2
Leonardo Sandoval196c8fe2020-07-26 18:02:10 -05003set -ex
4
Leonardo Sandoval3a931b92021-02-05 11:20:09 -06005# 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}
Fathi Boudra9e402bf2019-12-05 11:16:41 +020029
Fathi Boudra7975ca72020-01-28 16:48:40 +020030# FIXME workaround clone_repos.sh script when using gerrit
31unset GERRIT_PROJECT
32unset GERRIT_BRANCH
33unset GERRIT_REFSPEC
34
Fathi Boudra9e402bf2019-12-05 11:16:41 +020035if [ -z "${WORKSPACE}" ]; then
36 ## Local build
37 export WORKSPACE=${PWD}
38fi
39
Fathi Boudra9e402bf2019-12-05 11:16:41 +020040cd ${WORKSPACE}
41
Manish V Badarkhe6f6dab82022-09-29 08:15:13 +010042# coverity-tf-misra: https://projects.linaro.org/browse/TFC-10 pending to
43# be included in OpenCI, hence it is blocklisted for now.
Leonardo Sandoval63fd38f2021-03-26 14:05:03 -060044
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050045blocklist="blocklist.txt"
46cat << EOF > "${blocklist}"
47coverity-tf-misra
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050048EOF
49
Leonardo Sandovalf9a362f2021-03-04 12:02:57 -060050if echo "${TEST_DESC}" | grep -F -f ${blocklist} - ; then
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050051 echo ${TEST_DESC} is blocklisted
52 exit 0
53fi
54
55mkdir -p ${WORKSPACE}/nfs/downloads/mbedtls
56cd ${WORKSPACE}/nfs/downloads/mbedtls
Paul Sokolovskyf319a702023-05-31 23:00:27 +030057curl --fail --connect-timeout 5 --retry 5 -sLSO -k -C - ${MBEDTLS_URL}
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050058export mbedtls_archive=${WORKSPACE}/nfs/downloads/mbedtls/$(ls -1 mbedtls-*.tar.gz)
59
Fathi Boudra9e402bf2019-12-05 11:16:41 +020060# Path to root of CI repository
61ci_root="${WORKSPACE}/tf-a-ci-scripts"
62
Leonardo Sandoval6631c432021-04-14 12:15:38 -050063export tf_downloads="https://downloads.trustedfirmware.org"
64export tfa_downloads="${tf_downloads}/tf-a"
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050065
66# Fetch required firmware/binaries and place it at proper location
Fathi Boudra9e402bf2019-12-05 11:16:41 +020067export nfs_volume="${WORKSPACE}/nfs"
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050068project_filer="${nfs_volume}/projectscratch/ssg/trusted-fw"
Leonardo Sandovalb2e54a92021-11-11 13:53:09 -060069mkdir -p ${project_filer}
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050070
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050071# fetch Juno rootfs, required by fvp
72linaro_2001_release="/nfs/downloads/linaro/20.01"
73cd ${linaro_2001_release}
Leonardo Sandoval3a931b92021-02-05 11:20:09 -060074resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo \
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050075 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
Leonardo Sandoval6631c432021-04-14 12:15:38 -050078# export trace code coverage variable
79export coverage_trace_plugin="${tf_downloads}/coverage-plugin/qa-tools/coverage-tool/coverage-plugin/coverage_trace.so"
80
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050081# 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
Leonardo Sandovale2123b12021-06-11 15:25:08 -050091# /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
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050097# /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
Harrison Mutaidc174472022-02-16 15:05:44 +0000102# CC=/arm/warehouse/Distributions/FA/ARMCompiler/6.18/19/standalone-linux-x86_64-rel/bin/armclang
Harrison Mutaidc174472022-02-16 15:05:44 +0000103mkdir -p /arm/warehouse/Distributions/FA/ARMCompiler/6.18/19/standalone-linux-x86_64-rel
Paul Sokolovsky83d2f502023-10-18 19:25:50 +0300104ln -s ${TOOLS_DIR}/armclang-6.18/bin \
Harrison Mutaidc174472022-02-16 15:05:44 +0000105 /arm/warehouse/Distributions/FA/ARMCompiler/6.18/19/standalone-linux-x86_64-rel/bin
Fathi Boudra9e402bf2019-12-05 11:16:41 +0200106
Paul Sokolovskydd83f742023-10-18 19:31:32 +0300107${TOOLS_DIR}/armclang-6.18/bin/armclang --vsn
Paul Sokolovsky808052e2023-10-29 10:08:05 +0300108
109# If build actually uses ArmClang, activate and verify UBL license
110if echo ${TEST_CONFIG} | grep -q armclang && [ -n "${ARMCLANG_UBL_CODE}" ]; then
Paul Sokolovsky032f7f82023-10-28 23:42:12 +0300111 ${TOOLS_DIR}/armclang-6.18/bin/armlm activate --code ${ARMCLANG_UBL_CODE}
112 ${TOOLS_DIR}/armclang-6.18/bin/armlm inspect
113 ${TOOLS_DIR}/armclang-6.18/bin/armclang --vsn
114fi
Paul Sokolovskydd83f742023-10-18 19:31:32 +0300115
Fathi Boudra9e402bf2019-12-05 11:16:41 +0200116# Mandatory workspace
117export workspace="${workspace:-${WORKSPACE}/workspace}"
118
119# During feature development, we need incremental build, so don't run
120# 'distlcean' on every invocation.
121export dont_clean="${dont_clean:-1}"
122
Fathi Boudra9e402bf2019-12-05 11:16:41 +0200123# Local paths to TF and TFTF repositories
124export tf_root="${tf_root:-${WORKSPACE}/trusted-firmware-a}"
125export tftf_root="${tftf_root:-${WORKSPACE}/tf-a-tests}"
126
127# We'd need to see the terminals during development runs, so no need for
128# automation.
129export test_run="${test_run:-1}"
130
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -0500131# By default, do not execute any run
132export skip_runs="${skip_runs:-1}"
133
134# set linaro platform release folder
135export linaro_2001_release="file://${linaro_2001_release}"
136
137export docker_registry="${DOCKER_REGISTRY}"
138export armlmd_license_file="${ARMLMD_LICENSE_FILE}"
139export juno_rootfs_url="${JUNO_ROOTFS_URL}"
140
141# Parse TEST_DESC and export test_group & tf_config and & run_config
142test_desc="${test_desc:-$TEST_DESC}"
143test_desc="${test_desc:?}"
144
145# Strip test suffix
146test_desc="${test_desc%%.test}"
147
148lhs="$(echo "$test_desc" | awk -F: '{print $1}')"
149rhs="$(echo "$test_desc" | awk -F: '{print $2}')"
150
Leonardo Sandoval601d8822021-03-17 10:40:06 -0600151test_group="$(echo "$lhs" | awk -F% '{print $2}')"
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -0500152build_config="$(echo "$lhs" | awk -F% '{print $3}')"
Leonardo Sandoval601d8822021-03-17 10:40:06 -0600153run_config="${rhs%.test}"
Paul Sokolovsky7be2e052021-11-08 14:45:01 +0300154test_config="${TEST_CONFIG}"
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -0500155
Leonardo Sandoval601d8822021-03-17 10:40:06 -0600156export BUILD_CONFIG="$build_config"
157export RUN_CONFIG="$run_config"
158export TEST_CONFIG="$test_config"
159export TEST_GROUP="$test_group"
Mark Dykes7df0ebc2023-07-27 14:52:39 -0500160export COVERAGE_ON=$(echo "$RUN_CONFIG" | grep -qE 'bmcov' && echo 1 || echo 0)
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -0500161
Fathi Boudra9e402bf2019-12-05 11:16:41 +0200162# Run this script bash -x, and it gets passed downstream for debugging
163if echo "$-" | grep -q "x"; then
164 bash_opts="-x"
165fi
166
Leonardo Sandoval601d8822021-03-17 10:40:06 -0600167mkdir -p "${workspace}"
168bash $bash_opts "$ci_root/script/build_package.sh"
Fathi Boudra9e402bf2019-12-05 11:16:41 +0200169
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -0500170# compress rootfs.bin file
171for a in $(find ${workspace} -type d -name artefacts); do
Leonardo Sandoval60afea52021-03-16 10:48:03 -0600172 for r in $(find $a -type f -name rootfs.bin -or -name busybox.bin); do
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -0500173 d=$(dirname $r); b=$(basename $r); cd "$d" && gzip "$b"
174 done
175done
176
Fathi Boudra9e402bf2019-12-05 11:16:41 +0200177cp -a $(find ${workspace} -type d -name artefacts) ${WORKSPACE}/