Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Leonardo Sandoval | 196c8fe | 2020-07-26 18:02:10 -0500 | [diff] [blame] | 3 | set -ex |
| 4 | |
Leonardo Sandoval | 3a931b9 | 2021-02-05 11:20:09 -0600 | [diff] [blame] | 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 | } |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 29 | |
Fathi Boudra | 7975ca7 | 2020-01-28 16:48:40 +0200 | [diff] [blame] | 30 | # FIXME workaround clone_repos.sh script when using gerrit |
| 31 | unset GERRIT_PROJECT |
| 32 | unset GERRIT_BRANCH |
| 33 | unset GERRIT_REFSPEC |
| 34 | |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 35 | if [ -z "${WORKSPACE}" ]; then |
| 36 | ## Local build |
| 37 | export WORKSPACE=${PWD} |
| 38 | fi |
| 39 | |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 40 | cd ${WORKSPACE} |
| 41 | |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 42 | # Several test descriptions are pending to be included in OpenCI, so for the moment |
| 43 | # blocklist these. |
Leonardo Sandoval | f9a362f | 2021-03-04 12:02:57 -0600 | [diff] [blame] | 44 | # 1. coverity-tf-misra: https://projects.linaro.org/browse/TFC-10 |
Leonardo Sandoval | 6631c43 | 2021-04-14 12:15:38 -0500 | [diff] [blame] | 45 | # 2. fvp-tbb-mbedtls-upcounter,fvp-fwu:fvp-tftf.fwu-aemv8a.invalid_nvcounter-debug: Pending TFC ticket |
| 46 | # 3. Failure at LAVA job https://tf.validation.linaro.org/scheduler/job/142122 |
Leonardo Sandoval | 63fd38f | 2021-03-26 14:05:03 -0600 | [diff] [blame] | 47 | # TFC ticket https://projects.linaro.org/browse/TFC-70 |
Leonardo Sandoval | 6631c43 | 2021-04-14 12:15:38 -0500 | [diff] [blame] | 48 | # 4. Failure at LAVA job https://tf.validation.linaro.org/scheduler/job/142101 |
Leonardo Sandoval | 63fd38f | 2021-03-26 14:05:03 -0600 | [diff] [blame] | 49 | # TFC ticket https://projects.linaro.org/browse/TFC-70 |
| 50 | |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 51 | blocklist="blocklist.txt" |
| 52 | cat << EOF > "${blocklist}" |
| 53 | coverity-tf-misra |
Leonardo Sandoval | f9a362f | 2021-03-04 12:02:57 -0600 | [diff] [blame] | 54 | fvp-tbb-mbedtls-upcounter,fvp-fwu,nil,nil,nil:fvp-tftf.fwu-aemv8a.invalid_nvcounter-debug |
Leonardo Sandoval | 63fd38f | 2021-03-26 14:05:03 -0600 | [diff] [blame] | 55 | fvp-mb-256-optee-romlib,nil,nil,nil,nil:fvp-optee.mb-linux.rootfs+ftpm-romlib-fip.ftpm-aemv8a |
| 56 | fvp-linux-as-bl33,nil,nil,nil,nil:fvp-linux.bl33-dtb-aemv8a.linux.bl33-debug |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 57 | EOF |
| 58 | |
Leonardo Sandoval | f9a362f | 2021-03-04 12:02:57 -0600 | [diff] [blame] | 59 | if echo "${TEST_DESC}" | grep -F -f ${blocklist} - ; then |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 60 | echo ${TEST_DESC} is blocklisted |
| 61 | exit 0 |
| 62 | fi |
| 63 | |
| 64 | mkdir -p ${WORKSPACE}/nfs/downloads/mbedtls |
| 65 | cd ${WORKSPACE}/nfs/downloads/mbedtls |
| 66 | curl --connect-timeout 5 --retry 5 --retry-delay 1 -sLSO -k -C - ${MBEDTLS_URL} |
| 67 | export mbedtls_archive=${WORKSPACE}/nfs/downloads/mbedtls/$(ls -1 mbedtls-*.tar.gz) |
| 68 | |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 69 | # Path to root of CI repository |
| 70 | ci_root="${WORKSPACE}/tf-a-ci-scripts" |
| 71 | |
Leonardo Sandoval | 6631c43 | 2021-04-14 12:15:38 -0500 | [diff] [blame] | 72 | export tf_downloads="https://downloads.trustedfirmware.org" |
| 73 | export tfa_downloads="${tf_downloads}/tf-a" |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 74 | |
| 75 | # Fetch required firmware/binaries and place it at proper location |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 76 | export nfs_volume="${WORKSPACE}/nfs" |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 77 | project_filer="${nfs_volume}/projectscratch/ssg/trusted-fw" |
| 78 | for d in spm spm-10-23-2020; do |
| 79 | mkdir -p ${project_filer}/ci-files/$d |
| 80 | cd ${project_filer}/ci-files/$d |
Leonardo Sandoval | 3a931b9 | 2021-02-05 11:20:09 -0600 | [diff] [blame] | 81 | resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo \ |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 82 | download.json \ |
| 83 | ${tfa_downloads}/$d/?export=json |
| 84 | for f in $(cat download.json | jq .files[].Url | sed s/\"//g); do |
Leonardo Sandoval | 3a931b9 | 2021-02-05 11:20:09 -0600 | [diff] [blame] | 85 | resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo $(basename $f) $f |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 86 | done |
| 87 | done |
| 88 | |
| 89 | # FIXME: place below code in above loop |
| 90 | # fetch https://downloads.trustedfirmware.org/tf-a/dummy-crypto-lib.tar |
| 91 | cd ${project_filer} |
Leonardo Sandoval | 3a931b9 | 2021-02-05 11:20:09 -0600 | [diff] [blame] | 92 | resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo \ |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 93 | dummy-crypto-lib.tar \ |
| 94 | https://downloads.trustedfirmware.org/tf-a/dummy-crypto-lib.tar |
| 95 | tar xf dummy-crypto-lib.tar |
| 96 | |
| 97 | # fetch Juno rootfs, required by fvp |
| 98 | linaro_2001_release="/nfs/downloads/linaro/20.01" |
| 99 | cd ${linaro_2001_release} |
Leonardo Sandoval | 3a931b9 | 2021-02-05 11:20:09 -0600 | [diff] [blame] | 100 | resilient_cmd curl --connect-timeout 5 --retry 5 --retry-delay 1 -fsSLo \ |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 101 | lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz \ |
| 102 | https://releases.linaro.org/openembedded/juno-lsk/latest/lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz |
| 103 | |
Leonardo Sandoval | 6631c43 | 2021-04-14 12:15:38 -0500 | [diff] [blame] | 104 | # export trace code coverage variable |
| 105 | export coverage_trace_plugin="${tf_downloads}/coverage-plugin/qa-tools/coverage-tool/coverage-plugin/coverage_trace.so" |
| 106 | |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 107 | # FIXME: create temporal /arm softlinks. |
| 108 | # Reason behind is described at |
| 109 | # https://git.trustedfirmware.org/ci/dockerfiles.git/commit/?id=4e2c2c94e434bc8a9b25f5da7c6018a43db8cb2f |
| 110 | |
| 111 | # /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gcc |
| 112 | mkdir -p /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update |
| 113 | ln -s \ |
| 114 | ${TOOLS_DIR}/bin \ |
| 115 | /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-9-2020-q2-update/bin |
| 116 | |
Leonardo Sandoval | e2123b1 | 2021-06-11 15:25:08 -0500 | [diff] [blame^] | 117 | # /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc |
| 118 | mkdir -p /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-10-2020-q4-major |
| 119 | ln -s \ |
| 120 | ${TOOLS_DIR}/gnu-rm/bin \ |
| 121 | /arm/pdsw/downloads/scp-models/tools/gcc-arm-none-eabi-10-2020-q4-major/bin |
| 122 | |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 123 | # /arm/projectscratch/ssg/trusted-fw/dummy-crypto-lib |
| 124 | mkdir -p /arm/projectscratch/ssg/trusted-fw |
| 125 | ln -s \ |
| 126 | ${project_filer}/dummy-crypto-lib \ |
| 127 | /arm/projectscratch/ssg/trusted-fw/dummy-crypto-lib |
| 128 | |
| 129 | |
| 130 | # /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- |
| 131 | mkdir -p /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu |
| 132 | ln -s ${TOOLS_DIR}/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin \ |
| 133 | /arm/pdsw/tools/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin |
| 134 | |
| 135 | # CC=/arm/warehouse/Distributions/FA/ARMCompiler/6.8/25/standalone-linux-x86_64-rel/bin/armclang |
| 136 | mkdir -p /arm/warehouse/Distributions/FA/ARMCompiler/6.8/25/standalone-linux-x86_64-rel |
| 137 | ln -s ${TOOLS_DIR}/armclang-6.8/bin \ |
| 138 | /arm/warehouse/Distributions/FA/ARMCompiler/6.8/25/standalone-linux-x86_64-rel/bin |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 139 | |
| 140 | # Mandatory workspace |
| 141 | export workspace="${workspace:-${WORKSPACE}/workspace}" |
| 142 | |
| 143 | # During feature development, we need incremental build, so don't run |
| 144 | # 'distlcean' on every invocation. |
| 145 | export dont_clean="${dont_clean:-1}" |
| 146 | |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 147 | # Local paths to TF and TFTF repositories |
| 148 | export tf_root="${tf_root:-${WORKSPACE}/trusted-firmware-a}" |
| 149 | export tftf_root="${tftf_root:-${WORKSPACE}/tf-a-tests}" |
| 150 | |
| 151 | # We'd need to see the terminals during development runs, so no need for |
| 152 | # automation. |
| 153 | export test_run="${test_run:-1}" |
| 154 | |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 155 | # By default, do not execute any run |
| 156 | export skip_runs="${skip_runs:-1}" |
| 157 | |
| 158 | # set linaro platform release folder |
| 159 | export linaro_2001_release="file://${linaro_2001_release}" |
| 160 | |
| 161 | export docker_registry="${DOCKER_REGISTRY}" |
| 162 | export armlmd_license_file="${ARMLMD_LICENSE_FILE}" |
| 163 | export juno_rootfs_url="${JUNO_ROOTFS_URL}" |
| 164 | |
| 165 | # Parse TEST_DESC and export test_group & tf_config and & run_config |
| 166 | test_desc="${test_desc:-$TEST_DESC}" |
| 167 | test_desc="${test_desc:?}" |
| 168 | |
| 169 | # Strip test suffix |
| 170 | test_desc="${test_desc%%.test}" |
| 171 | |
| 172 | lhs="$(echo "$test_desc" | awk -F: '{print $1}')" |
| 173 | rhs="$(echo "$test_desc" | awk -F: '{print $2}')" |
| 174 | |
Leonardo Sandoval | 601d882 | 2021-03-17 10:40:06 -0600 | [diff] [blame] | 175 | test_group="$(echo "$lhs" | awk -F% '{print $2}')" |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 176 | build_config="$(echo "$lhs" | awk -F% '{print $3}')" |
Leonardo Sandoval | 601d882 | 2021-03-17 10:40:06 -0600 | [diff] [blame] | 177 | run_config="${rhs%.test}" |
| 178 | test_config="$(cat $WORKSPACE/TEST_DESC)" |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 179 | |
Leonardo Sandoval | 601d882 | 2021-03-17 10:40:06 -0600 | [diff] [blame] | 180 | export BUILD_CONFIG="$build_config" |
| 181 | export RUN_CONFIG="$run_config" |
| 182 | export TEST_CONFIG="$test_config" |
| 183 | export TEST_GROUP="$test_group" |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 184 | |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 185 | # Run this script bash -x, and it gets passed downstream for debugging |
| 186 | if echo "$-" | grep -q "x"; then |
| 187 | bash_opts="-x" |
| 188 | fi |
| 189 | |
Leonardo Sandoval | 601d882 | 2021-03-17 10:40:06 -0600 | [diff] [blame] | 190 | mkdir -p "${workspace}" |
| 191 | bash $bash_opts "$ci_root/script/build_package.sh" |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 192 | |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 193 | # compress rootfs.bin file |
| 194 | for a in $(find ${workspace} -type d -name artefacts); do |
Leonardo Sandoval | 60afea5 | 2021-03-16 10:48:03 -0600 | [diff] [blame] | 195 | for r in $(find $a -type f -name rootfs.bin -or -name busybox.bin); do |
Leonardo Sandoval | dc2a03a | 2020-10-05 18:12:19 -0500 | [diff] [blame] | 196 | d=$(dirname $r); b=$(basename $r); cd "$d" && gzip "$b" |
| 197 | done |
| 198 | done |
| 199 | |
Fathi Boudra | 9e402bf | 2019-12-05 11:16:41 +0200 | [diff] [blame] | 200 | cp -a $(find ${workspace} -type d -name artefacts) ${WORKSPACE}/ |