blob: 4ef6ca10cd8614874fa473becb07e279a37a68d1 [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
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050042# Several test descriptions are pending to be included in OpenCI, so for the moment
43# blocklist these.
44blocklist="blocklist.txt"
45cat << EOF > "${blocklist}"
46coverity-tf-misra
47tf-l2-boot-tests-juno%juno-tbb-mbedtls-romlib,juno-default,nil,nil:juno-tftf-romlib
48EOF
49
50if echo "${TEST_DESC}" | grep -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 --connect-timeout 5 --retry 5 --retry-delay 1 -sLSO -k -C - ${MBEDTLS_URL}
58export 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 Sandovaldc2a03a2020-10-05 18:12:19 -050063export tfa_downloads="https://downloads.trustedfirmware.org/tf-a"
64
65# Fetch required firmware/binaries and place it at proper location
Fathi Boudra9e402bf2019-12-05 11:16:41 +020066export nfs_volume="${WORKSPACE}/nfs"
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050067project_filer="${nfs_volume}/projectscratch/ssg/trusted-fw"
68for d in spm spm-10-23-2020; do
69 mkdir -p ${project_filer}/ci-files/$d
70 cd ${project_filer}/ci-files/$d
Leonardo Sandoval3a931b92021-02-05 11:20:09 -060071 resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo \
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050072 download.json \
73 ${tfa_downloads}/$d/?export=json
74 for f in $(cat download.json | jq .files[].Url | sed s/\"//g); do
Leonardo Sandoval3a931b92021-02-05 11:20:09 -060075 resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo $(basename $f) $f
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050076 done
77done
78
79# FIXME: place below code in above loop
80# fetch https://downloads.trustedfirmware.org/tf-a/dummy-crypto-lib.tar
81cd ${project_filer}
Leonardo Sandoval3a931b92021-02-05 11:20:09 -060082resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo \
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050083 dummy-crypto-lib.tar \
84 https://downloads.trustedfirmware.org/tf-a/dummy-crypto-lib.tar
85tar xf dummy-crypto-lib.tar
86
87# fetch Juno rootfs, required by fvp
88linaro_2001_release="/nfs/downloads/linaro/20.01"
89cd ${linaro_2001_release}
Leonardo Sandoval3a931b92021-02-05 11:20:09 -060090resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo \
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -050091 lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz \
92 https://releases.linaro.org/openembedded/juno-lsk/latest/lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz
93
94# FIXME: create temporal /arm softlinks.
95# Reason behind is described at
96# https://git.trustedfirmware.org/ci/dockerfiles.git/commit/?id=4e2c2c94e434bc8a9b25f5da7c6018a43db8cb2f
97
98# /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gcc
99mkdir -p /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update
100ln -s \
101 ${TOOLS_DIR}/bin \
102 /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update/bin
103
104# /arm/projectscratch/ssg/trusted-fw/dummy-crypto-lib
105mkdir -p /arm/projectscratch/ssg/trusted-fw
106ln -s \
107 ${project_filer}/dummy-crypto-lib \
108 /arm/projectscratch/ssg/trusted-fw/dummy-crypto-lib
109
110
111# /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
112mkdir -p /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu
113ln -s ${TOOLS_DIR}/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin \
114 /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin
115
116# CC=/arm/warehouse/Distributions/FA/ARMCompiler/6.8/25/standalone-linux-x86_64-rel/bin/armclang
117mkdir -p /arm/warehouse/Distributions/FA/ARMCompiler/6.8/25/standalone-linux-x86_64-rel
118ln -s ${TOOLS_DIR}/armclang-6.8/bin \
119 /arm/warehouse/Distributions/FA/ARMCompiler/6.8/25/standalone-linux-x86_64-rel/bin
Fathi Boudra9e402bf2019-12-05 11:16:41 +0200120
121# Mandatory workspace
122export workspace="${workspace:-${WORKSPACE}/workspace}"
123
124# During feature development, we need incremental build, so don't run
125# 'distlcean' on every invocation.
126export dont_clean="${dont_clean:-1}"
127
128# During feature development, we typically only build in debug mode.
129export bin_mode="${bin_mode:-debug}"
130
131# Local paths to TF and TFTF repositories
132export tf_root="${tf_root:-${WORKSPACE}/trusted-firmware-a}"
133export tftf_root="${tftf_root:-${WORKSPACE}/tf-a-tests}"
134
135# We'd need to see the terminals during development runs, so no need for
136# automation.
137export test_run="${test_run:-1}"
138
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -0500139# By default, do not execute any run
140export skip_runs="${skip_runs:-1}"
141
142# set linaro platform release folder
143export linaro_2001_release="file://${linaro_2001_release}"
144
145export docker_registry="${DOCKER_REGISTRY}"
146export armlmd_license_file="${ARMLMD_LICENSE_FILE}"
147export juno_rootfs_url="${JUNO_ROOTFS_URL}"
148
149# Parse TEST_DESC and export test_group & tf_config and & run_config
150test_desc="${test_desc:-$TEST_DESC}"
151test_desc="${test_desc:?}"
152
153# Strip test suffix
154test_desc="${test_desc%%.test}"
155
156lhs="$(echo "$test_desc" | awk -F: '{print $1}')"
157rhs="$(echo "$test_desc" | awk -F: '{print $2}')"
158
159export test_group="$(echo "$lhs" | awk -F% '{print $2}')"
160
161# Test descriptors are always generated in the following order:
162# tf_config, tftf_config, scp_config, scp_tools
163build_config="$(echo "$lhs" | awk -F% '{print $3}')"
164export tf_config="$(echo "${build_config}" | awk -F, '{print $1}')"
165export tftf_config="$(echo "${build_config}" | awk -F, '{print $2}')"
166export scp_config="$(echo "${build_config}" | awk -F, '{print $3}')"
167export scp_tools="$(echo "${build_config}" | awk -F, '{print $4}')"
168
169export run_config="${rhs%.test}"
170
Fathi Boudra9e402bf2019-12-05 11:16:41 +0200171# Run this script bash -x, and it gets passed downstream for debugging
172if echo "$-" | grep -q "x"; then
173 bash_opts="-x"
174fi
175
176bash $bash_opts "$ci_root/script/run_local_ci.sh"
177
Leonardo Sandovaldc2a03a2020-10-05 18:12:19 -0500178# compress rootfs.bin file
179for a in $(find ${workspace} -type d -name artefacts); do
180 for r in $(find $a -type f -name rootfs.bin); do
181 d=$(dirname $r); b=$(basename $r); cd "$d" && gzip "$b"
182 done
183done
184
Fathi Boudra9e402bf2019-12-05 11:16:41 +0200185cp -a $(find ${workspace} -type d -name artefacts) ${WORKSPACE}/