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