blob: 5365d3dd986671bb65bbae9107a2cbd5d7d7fe8f [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -06003# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8set -u
9
10bl1_addr="${bl1_addr:-0x0}"
Zelalem219df412020-05-17 19:21:20 -050011bl31_addr="${bl31_addr:-0x04001000}"
Zelalem1b874612020-08-04 18:08:18 -050012bl32_addr="${bl32_addr:-0x04003000}"
Fathi Boudra422bf772019-12-02 11:10:16 +020013bl33_addr="${bl33_addr:-0x88000000}"
14dtb_addr="${dtb_addr:-0x82000000}"
15fip_addr="${fip_addr:-0x08000000}"
16initrd_addr="${initrd_addr:-0x84000000}"
17kernel_addr="${kernel_addr:-0x80080000}"
18el3_payload_addr="${el3_payload_addr:-0x80000000}"
19
Manish Pandey3c435582020-07-15 12:14:26 +010020# SPM requires following addresses for RESET_TO_BL31 case
21spm_addr="${spm_addr:-0x6000000}"
22spmc_manifest_addr="${spmc_addr:-0x0403f000}"
23sp1_addr="${sp1_addr:-0x7000000}"
24sp2_addr="${sp2_addr:-0x7100000}"
Olivier Deprez0b834092020-08-21 08:36:01 +020025sp3_addr="${sp3_addr:-0x7200000}"
Olivier Deprezdd9ed332021-07-02 12:07:17 +020026sp4_addr="${sp4_addr:-0x7600000}"
Manish Pandey1e7be852020-11-09 16:04:48 +000027# SPM out directories
28export spm_secure_out_dir="${spm_secure_out_dir:-secure_aem_v8a_fvp_clang}"
29export spm_non_secure_out_dir="${spm_non_secure_out_dir:-aem_v8a_fvp_clang}"
Manish Pandey3c435582020-07-15 12:14:26 +010030
Fathi Boudra422bf772019-12-02 11:10:16 +020031ns_bl1u_addr="${ns_bl1u_addr:-0x0beb8000}"
32fwu_fip_addr="${fwu_fip_addr:-0x08400000}"
33backup_fip_addr="${backup_fip_addr:-0x09000000}"
34romlib_addr="${romlib_addr:-0x03ff2000}"
35
36uboot32_fip_url="$linaro_release/fvp32-latest-busybox-uboot/fip.bin"
37
Alexei Fedorove405cc32020-09-30 18:13:55 +010038rootfs_url="$linaro_release/lt-vexpress64-openembedded_minimal-armv8-gcc-5.2_20170127-761.img.gz"
Fathi Boudra422bf772019-12-02 11:10:16 +020039
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050040# Default FVP model variables
Leonardo Sandovale1460662021-05-27 16:05:38 -050041default_model_dtb="dtb.bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050042
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060043# FVP containers and model paths
laurenw-arm35faeaa2021-05-03 14:28:17 -050044fvp_arm_std_library_11_12="fvp:fvp_arm_std_library_${model_version_11_12}_${model_build_11_12};/opt/model/FVP_ARM_Std_Library/models/${model_flavour_11_12}"
Maksims Svecovs284a50d2021-11-02 11:09:47 +000045fvp_arm_std_library="fvp:fvp_arm_std_library_${model_version}_${model_build};/opt/model/FVP_ARM_Std_Library/FVP_Base"
laurenw-armf414aba2021-04-26 15:58:56 -050046fvp_base_revc_2xaemva="fvp:fvp_base_revc-2xaemva_${model_version}_${model_build};/opt/model/Base_RevC_AEMvA_pkg/models/${model_flavour}"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060047foundation_platform="fvp:foundation_platform_${model_version}_${model_build};/opt/model/Foundation_Platformpkg/models/${model_flavour}"
johpow01936638d2021-11-08 18:22:24 -060048fvp_base_aemv8r="fvp:fvp_base_aemv8r_${model_version}_${model_build};/opt/model/AEMv8R_base_pkg/models/${model_flavour}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -050049
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060050# FVP associate array, run_config are keys and fvp container parameters are the values
51# Container parameters syntax: <model name>;<model dir>;<model bin>
52# FIXMEs: fix those ;;; values with real values
53
54declare -A fvp_models
55fvp_models=(
56[base-aemv8a-quad]=";;;"
57[base-aemv8a-revb]=";;;"
58[base-aemv8a-latest-revb]=";;;"
59[base-aemva]=";;;"
Manish V Badarkhee4783832021-02-22 14:36:56 +000060[base-aemv8a-gic600ae]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060061[foundationv8]="${foundation_platform};Foundation_Platform"
laurenw-armf414aba2021-04-26 15:58:56 -050062[base-aemv8a]="${fvp_base_revc_2xaemva};FVP_Base_RevC-2xAEMvA"
johpow01936638d2021-11-08 18:22:24 -060063[baser-aemv8r]=";;;"
laurenw-arm35faeaa2021-05-03 14:28:17 -050064[cortex-a32x4]="${fvp_arm_std_library_11_12};FVP_Base_Cortex-A32x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060065[cortex-a35x4]="${fvp_arm_std_library};FVP_Base_Cortex-A35x4"
66[cortex-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A53x4"
Leonardo Sandoval95f896b2021-02-22 10:16:29 -060067[cortex-a55x4-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A75x4"
68[cortex-a55x4-a76x2]="${fvp_arm_std_library};FVP_Base_Cortex-A55x4+Cortex-A76x2"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060069[cortex-a57x1-a53x1]="${fvp_arm_std_library};FVP_Base_Cortex-A57x1-A53x1"
70[cortex-a57x2-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x2-A53x4"
71[cortex-a57x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4"
72[cortex-a57x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A57x4-A53x4"
73[cortex-a65aex8]="${fvp_arm_std_library};FVP_Base_Cortex-A65AEx8"
74[cortex-a65x4]="${fvp_arm_std_library};FVP_Base_Cortex-A65x4"
75[cortex-a72x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4"
76[cortex-a72x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A72x4-A53x4"
77[cortex-a73x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4"
78[cortex-a73x4-a53x4]="${fvp_arm_std_library};FVP_Base_Cortex-A73x4-A53x4"
79[cortex-a75x4]="${fvp_arm_std_library};FVP_Base_Cortex-A75x4"
80[cortex-a76aex4]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx4"
81[cortex-a76aex2]="${fvp_arm_std_library};FVP_Base_Cortex-A76AEx2"
82[cortex-a76x4]="${fvp_arm_std_library};FVP_Base_Cortex-A76x4"
83[cortex-a77x4]="${fvp_arm_std_library};FVP_Base_Cortex-A77x4"
84[cortex-a78x4]="${fvp_arm_std_library};FVP_Base_Cortex-A78x4"
johpow011008edc2022-02-01 18:50:33 -060085[cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060086[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1"
87[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2"
88[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4"
Leonardo Sandoval54f1ade2021-06-26 19:20:48 -050089[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x4"
Maksims Svecovsd10c1b92021-10-06 10:25:40 +010090[neoverse_n2]="${fvp_arm_std_library_11_12};FVP_Base_Neoverse-N1x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060091[neoverse-v1x4]=";;;"
Manish V Badarkhecbed15e2021-07-02 09:34:53 +010092[cortexa710x4]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060093[css-rdv1]=";;;"
94[css-rde1edge]=";;;"
95[css-rdn1edge]=";;;"
96[css-rdn1edgex2]=";;;"
97[css-sgi575]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060098[tc0]=";;;"
Usama Arifcba711d2021-08-04 15:53:42 +010099[tc1]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600100)
101
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500102
Fathi Boudra422bf772019-12-02 11:10:16 +0200103# FVP Kernel URLs
104declare -A fvp_kernels
105fvp_kernels=(
106[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
107[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
108[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
109[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
110[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
111)
112
Fathi Boudra422bf772019-12-02 11:10:16 +0200113# FVP initrd URLs
114declare -A fvp_initrd_urls
115fvp_initrd_urls=(
116[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200117[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
118[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
119[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
120)
121
Fathi Boudra422bf772019-12-02 11:10:16 +0200122get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100123 url="$tfa_downloads/optee/tee.bin" \
124 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200125 archive_file "bl32.bin"
126}
127
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100128# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
129# specific build rather than the default one generated by Jenkins.
130get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100131 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100132 saveas="bl32.bin" fetch_file
133 archive_file "bl32.bin"
134
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100135 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100136 saveas="bl32_extra1.bin" fetch_file
137 archive_file "bl32_extra1.bin"
138
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600139 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
140 # so just create the file
141 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100142 archive_file "bl32_extra2.bin"
143}
144
Fathi Boudra422bf772019-12-02 11:10:16 +0200145get_uboot32_bin() {
146 local tmpdir="$(mktempdir)"
147
148 pushd "$tmpdir"
149 extract_fip "$uboot32_fip_url"
150 mv "nt-fw.bin" "uboot.bin"
151 archive_file "uboot.bin"
152 popd
153}
154
155get_uboot_bin() {
156 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
157
158 url="$uboot_url" saveas="uboot.bin" fetch_file
159 archive_file "uboot.bin"
160}
161
162get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500163 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
164 uefi_ci_bin_url="${uefi_ci_bin_url:-$uefi_downloads/Artifacts/Linux/github/fvp/static/DEBUG_GCC5/FVP_AARCH64_EFI.fd}"
Fathi Boudra422bf772019-12-02 11:10:16 +0200165
166 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
167 archive_file "uefi.bin"
168}
169
170get_kernel() {
171 local kernel_type="${kernel_type:?}"
172 local url="${fvp_kernels[$kernel_type]}"
173
174 url="${url:?}" saveas="kernel.bin" fetch_file
175 archive_file "kernel.bin"
176}
177
178get_initrd() {
179 local initrd_type="${initrd_type:?}"
180 local url="${fvp_initrd_urls[$initrd_type]}"
181
182 url="${url:?}" saveas="initrd.bin" fetch_file
183 archive_file "initrd.bin"
184}
185
186get_dtb() {
187 local dtb_type="${dtb_type:?}"
188 local dtb_url
189 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500190 local cc="$(get_tf_opt CROSS_COMPILE)"
191 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200192
193 case "$dtb_type" in
194 "fvp-base-quad-cluster-gicv3-psci")
195 # Get the quad-cluster FDT from pdsw area
196 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
197 url="$dtb_url" saveas="$dtb_saveas" fetch_file
198 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200199 *)
Zelalem219df412020-05-17 19:21:20 -0500200 # Preprocess DTS file
201 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
202 -o "$workspace/${dtb_type}.pre.dts" \
203 "$tf_root/fdts/${dtb_type}.dts"
204 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200205 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500206 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200207 esac
208
209 archive_file "$dtb_saveas"
210}
211
212get_rootfs() {
213 local tmpdir
214 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
215 local cached="$project_filer/ci-files/$fs_base"
216
217 if upon "$jenkins_run" && [ -f "$cached" ]; then
218 # Job workspace is limited in size, and the root file system is
219 # quite large. This means, parallel runs of root file system
220 # tests could fail. So, for Jenkins runs, copy and use the root
221 # file system image from the $CI_SCRATCH location
222 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
223 mkdir -p "$private"
224 rm -f "$private/rootfs.bin"
225 url="$cached" saveas="$private/rootfs.bin" fetch_file
226 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
227 return
228 fi
229
230 tmpdir="$(mktempdir)"
231 pushd "$tmpdir"
232 url="$rootfs_url" saveas="rootfs.bin" fetch_file
233
234 # Possibly, the filesystem image we just downloaded is compressed.
235 # Decompress it if required.
236 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
237 echo "Decompressing root file system image rootfs.bin ..."
238 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
239 mv uncompressed_fs.bin "rootfs.bin"
240 fi
241
242 archive_file "rootfs.bin"
243 popd
244}
245
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200246fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
247
Fathi Boudra422bf772019-12-02 11:10:16 +0200248fvp_romlib_runtime() {
249 local tmpdir="$(mktempdir)"
250
251 # Save BL1 and romlib binaries from original build
252 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
253 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
254
255 # Patch index file
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200256 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
257 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200258
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200259 # Rebuild with patched file
260 echo "Building patched romlib:"
261 build_tf
Fathi Boudra422bf772019-12-02 11:10:16 +0200262
Fathi Boudra422bf772019-12-02 11:10:16 +0200263 # Retrieve original BL1 and romlib binaries
264 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
265 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
266}
267
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200268fvp_romlib_cleanup() {
269 # Restore original index
270 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
271}
272
273
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500274fvp_gen_bin_url() {
275 local bin_mode="${bin_mode:?}"
276 local bin="${1:?}"
277
278 if upon "$jenkins_run"; then
279 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
280 else
281 echo "file://$workspace/artefacts/$bin_mode/$bin"
282 fi
283}
284
285gen_fvp_yaml_template() {
286 local yaml_template_file="$workspace/fvp_template.yaml"
287
288 # must parameters for yaml generation
289 local payload_type="${payload_type:?}"
290
291 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
292
293 archive_file "$yaml_template_file"
294}
295
296gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600297 local model="${model:?}"
298
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500299 local yaml_template_file="$workspace/fvp_template.yaml"
300 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500301 local yaml_job_file="$workspace/job.yaml"
302 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500303
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500304 # this function expects a template, quit if it is not present
305 if [ ! -f "$yaml_template_file" ]; then
306 return
307 fi
308
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600309 local model_params="${fvp_models[$model]}"
310 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
311 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
312 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
313
314 # model params are required for correct yaml creation, quit if empty
315 if [ -z "${model_name}" ]; then
316 echo "FVP model param 'model_name' variable empty, yaml not produced"
317 return
318 elif [ -z "${model_dir}" ]; then
319 echo "FVP model param 'model_dir' variable empty, yaml not produced"
320 return
321 elif [ -z "${model_bin}" ]; then
322 echo "FVP model param 'model_bin' variable empty, yaml not produced"
323 return
324 fi
325
326 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500327
328 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500329 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500330
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600331 # possible artefacts
332 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500333 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600334 bl2="$(fvp_gen_bin_url bl2.bin)"
335 bl31="$(fvp_gen_bin_url bl31.bin)"
336 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600337 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
338 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
339 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
340 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500341 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500342 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600343 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
344 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500345 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600346 fvp_spmc_manifest_dtb="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600347 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600348 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
349 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500350 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600351 ivy="$(fvp_gen_bin_url ivy.pkg)"
352 manifest_dtb="$(fvp_gen_bin_url manifest.dtb)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600353 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
354 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500355 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
356 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600357 ramdisk="$(fvp_gen_bin_url initrd.bin)"
358 romlib="$(fvp_gen_bin_url romlib.bin)"
359 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600360 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
361 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
362 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
363 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
364 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600365 spm="$(fvp_gen_bin_url spm.bin)"
366 tftf="$(fvp_gen_bin_url tftf.bin)"
367 tmp="$(fvp_gen_bin_url tmp.bin)"
368 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500369
370 docker_registry="${docker_registry:-}"
371 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500372 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600373 prompt1='/ #'
374 prompt2='root@genericarmv8:~#'
375 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500376
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500377 test_config="${TEST_CONFIG}"
378
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600379 # arrays that relates variables and template macros
380 # NOTE: any addition on these arrays, requires an addition in the
381 # fvp templates
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500382 declare -A metadata_macros
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600383 declare -A yaml_macros
384 declare -A artefacts_macros
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500385 metadata_macros=(
386 [test_config]="{TEST_CONFIG}"
387 )
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600388 yaml_macros=(
389 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
390 [docker_name]="{BOOT_DOCKER_NAME}"
391 [model]="{MODEL}"
392 [model_bin]="{BOOT_IMAGE_BIN}"
393 [model_dir]="{BOOT_IMAGE_DIR}"
394 [prompt1]="{PROMPT1}"
395 [prompt2]="{PROMPT2}"
396 [version_string]="{BOOT_VERSION_STRING}"
397 )
398 artefacts_macros=(
399 [backup_fip]="{BACKUP_FIP}"
400 [bl1]="{BL1}"
401 [bl2]="{BL2}"
402 [bl31]="{BL31}"
403 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600404 [cactus_primary]="{CACTUS_PRIMARY}"
405 [cactus_secondary]="{CACTUS_SECONDARY}"
406 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500407 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600408 [fvp_spmc_manifest_dtb]="{FVP_SPMC_MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600409 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600410 [dtb]="{DTB}"
411 [el3_payload]="{EL3_PAYLOAD}"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500412 [fip_gpt]="{FIP_GPT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600413 [fwu_fip]="{FWU_FIP}"
414 [fip]="{FIP}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600415 [generic_trace]="{GENERIC_TRACE}"
416 [hafnium]="{HAFNIUM}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600417 [image]="{IMAGE}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600418 [ivy]="{IVY}"
419 [manifest_dtb]="{MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600420 [mcp_rom]="{MCP_ROM}"
421 [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600422 [ns_bl1u]="{NS_BL1U}"
423 [ns_bl2u]="{NS_BL2U}"
424 [ramdisk]="{RAMDISK}"
425 [romlib]="{ROMLIB}"
426 [rootfs]="{ROOTFS}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600427 [secure_hafnium]="{SECURE_HAFNIUM}"
428 [scp_ram]="{SCP_RAM}"
429 [scp_ram_hyphen]="{SCP_RAM_HYPHEN}"
430 [scp_rom]="{SCP_ROM}"
431 [scp_rom_hyphen]="{SCP_ROM_HYPHEN}"
432 [spm]="{SPM}"
433 [tftf]="{TFTF}"
434 [tmp]="{TMP}"
435 [uboot]="{UBOOT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600436 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500437
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600438 # templates cover all possible artefacts, but model parameters may
439 # not required all, i.e. romlib.bin, so delete those irrelevant from
440 # the template
441 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600442 # there are artefacts where deletion is handled in special case, so treat them accordingly
443 case "$m" in
444 busybox)
445 # besides the macro removal, remove the compression field
446 if ! grep -q "${m}.bin" "$archive/model_params"; then
447 sed -i "/$m:\$/d" "${yaml_template_file}"
448 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
449 fi
450 ;;
451 cactus_primary)
452 # cactus packages have a hyphen, not an underscore
453 if ! grep -E -q "cactus-primary.pkg" "$archive/model_params"; then
454 sed -i "/$m:\$/d" "${yaml_template_file}"
455 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
456 fi
457 ;;
458 cactus_secondary)
459 # cactus packages have a hyphen, not an underscore
460 if ! grep -E -q "cactus-secondary.pkg" "$archive/model_params"; then
461 sed -i "/$m:\$/d" "${yaml_template_file}"
462 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
463 fi
464 ;;
465 cactus_tertiary)
466 # cactus packages have a hyphen, not an underscore
467 if ! grep -E -q "cactus-tertiary.pkg" "$archive/model_params"; then
468 sed -i "/$m:\$/d" "${yaml_template_file}"
469 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
470 fi
471 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500472 coverage_trace_plugin)
473 if ! grep -q "coverage_trace.so" "$archive/model_params"; then
474 sed -i "/$m:\$/d" "${yaml_template_file}"
475 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
476 fi
477 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600478 fvp_spmc_manifest_dtb)
479 # handles fvp_spmc_manifest.dtb as DTB file
480 if ! grep -q "=fvp_spmc_manifest.dtb" "$archive/model_params"; then
481 sed -i "/ $m:\$/d" "${yaml_template_file}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600482 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
483 fi
484 ;;
485 generic_trace)
486 # the image (Linux Kernel) is named as kernel.bin
487 if ! grep -q "GenericTrace.so" "$archive/model_params"; then
488 sed -i "/$m:\$/d" "${yaml_template_file}"
489 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
490 fi
491 ;;
492 image)
493 # the image (Linux Kernel) is named as kernel.bin
494 if ! grep -q "kernel.bin" "$archive/model_params"; then
495 sed -i "/$m:\$/d" "${yaml_template_file}"
496 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
497 fi
498 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600499 ivy)
500 # the ivy package
501 if ! grep -q "ivy.pkg" "$archive/model_params"; then
502 sed -i "/$m:\$/d" "${yaml_template_file}"
503 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
504 fi
505 ;;
506 manifest_dtb)
507 # handles manifest.dtb as DTB file
508 if ! grep -q "=manifest.dtb" "$archive/model_params"; then
509 sed -i "/ $m:\$/d" "${yaml_template_file}"
510 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
511 fi
512 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600513 mcp_rom_hyphen)
514 # mcp rom is either present as mcp-rom or mcp_rom, handle the former case
515 if ! grep -q "mcp-rom.bin" "$archive/model_params"; then
516 sed -i "/$m:\$/d" "${yaml_template_file}"
517 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
518 fi
519 ;;
520 ramdisk)
521 # ramdisk is named initrd and is present with to extensions: bin or img
522 if ! grep -E -q "initrd.bin|initrd.img" "$archive/model_params"; then
523 sed -i "/$m:\$/d" "${yaml_template_file}"
524 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
525 fi
526 ;;
527 rootfs)
528 # besides the macro removal, remove the compression field
529 if ! grep -q "rootfs.bin" "$archive/model_params"; then
530 sed -i "/$m:\$/d" "${yaml_template_file}"
531 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
532 fi
533 ;;
534 scp_ram_hyphen)
535 # scp ram is either present as scp-ram or scp_ram, handle the former case
536 if ! grep -q "scp-ram.bin" "$archive/model_params"; then
537 sed -i "/$m:\$/d" "${yaml_template_file}"
538 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
539 fi
540 ;;
541 scp_rom_hyphen)
542 # scp rom is either present as scp-rom or scp_rom, handle the former case
543 if ! grep -q "scp-rom.bin" "$archive/model_params"; then
544 sed -i "/$m:\$/d" "${yaml_template_file}"
545 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
546 fi
547 ;;
548 *)
549 if ! grep -q "${m}.bin" "$archive/model_params"; then
550 sed -i "/$m:\$/d" "${yaml_template_file}"
551 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
552 fi
553 ;;
554 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600555 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500556
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600557 # copied files are the working files
558 cp "${yaml_template_file}" "${yaml_file}"
559 cp "$archive/model_params" "$lava_model_params"
560
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500561 # replace metadata macros with real values
562 for m in "${!metadata_macros[@]}"; do
563 sed -i -e "s|${metadata_macros[$m]}|${!m}|" "$yaml_file"
564 done
565
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600566 # replace yaml macros with real values
567 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600568 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600569 done
570
571 # replace artefact macros with real values
572 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600573 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600574 done
575
576 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600577 # replace them. As in the macro removal above, handle special cases for several
578 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600579 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600580 case "$m" in
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600581 cactus_primary)
582 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
583 ;;
584 cactus_secondary)
585 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
586 ;;
587 cactus_tertiary)
588 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
589 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500590 coverage_trace_plugin)
591 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
592 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
593 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600594 fvp_spmc_manifest_dtb)
595 sed -i -e "s|=fvp_spmc_manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
596 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600597 generic_trace)
598 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
599 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
600 ;;
601 image)
602 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
603 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600604 ivy)
605 sed -i -e "s|=ivy.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
606 ;;
607 manifest_dtb)
608 sed -i -e "s|=manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
609 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600610 mcp_rom_hyphen)
611 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
612 ;;
613 ramdisk)
614 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
615 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
616 ;;
617 scp_ram_hyphen)
618 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
619 ;;
620 scp_rom_hyphen)
621 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
622 ;;
623 tmp | hafnium | secure_hafnium)
624 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
625 ;;
626 *)
627 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
628 ;;
629 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600630 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500631
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500632 # include the model parameters
633 while read -r line; do
634 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600635 yaml_line="- \"${line}\""
636 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500637 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500638 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600639 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500640
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500641 # Append expect commands into the job definition through test-interactive commands
642 gen_fvp_yaml_expect >> "$yaml_file"
643
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600644 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500645 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500646
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600647 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500648 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500649 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500650}
651
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500652gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500653
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500654 run_root="$archive/run"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500655
656 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500657 for expect_file in $(find $run_root -name expect); do
658
659 # TODO: currently, only handle UART 0
660 case $expect_file in
661 *uart0* )
662 uart_number=uart0
663 ;;
664 *)
665 continue
666 ;;
667 esac
668
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500669 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
670 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
671 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
672 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
673 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
674 #
675 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
676 # where multiple successes or failures or commands are separated by @
677 #
678 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
679 # where multiple patterns are separated by @
680 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500681 expect_string=()
682
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500683 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500684 expect_file=$(cat $expect_file)
685
686 # Source the run_config enviroment variables
687 env=$run_root/$uart_number/env
688 if [ -e $env ]; then
689 source $env
690 fi
691
692 # Get all expect strings
Paul Sokolovskyeece6f72021-12-01 15:04:29 +0300693 expect_file=$ci_root/expect-lava/${expect_file}
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500694 source $expect_file
695
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500696
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500697 if [ ${#expect_string[@]} -gt 0 ]; then
698
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500699 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500700 for key in "${!expect_string[@]}"; do
701
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500702 # single raw expect string
703 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500704
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500705 # action type: either m or i
706 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500707
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500708 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500709
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500710 start="$(echo "${es}" | awk -F ';' '{print $2}')"
711 end="$(echo "${es}" | awk -F ';' '{print $3}')"
712 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
713
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500714 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500715- test:
716 monitors:
717 - name: tests
718 start: '${start}'
719 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500720EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500721 # Patterns are separated by '@'
722 OLD_IFS=$IFS; IFS=$'@'
723 for p in ${patterns}; do
724 cat << EOF
725 pattern: '$p'
726EOF
727 done
728 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500729 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500730 fixupdict:
731 PASS: pass
732 FAIL: fail
733EOF
734 fi # end of monitor action
735
736 if [ "${action}" = "i" ]; then
737
738 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
739 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
740 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
741 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
742
743 cat << EOF
744- test:
745 interactive:
746EOF
747 OLD_IFS=$IFS; IFS=$'@'
748
749 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
750 cat << EOF
751 - name: interactive_${uart_number}_${key}
752 prompts: ['${prompts}']
753 script:
754EOF
755 if [ -z "${commands}" ]; then
756 cat <<EOF
757 - name: interactive_command_${uart_number}_${key}
758 command:
759EOF
760 else
761 for c in ${commands}; do
762 cat <<EOF
763 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300764 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500765EOF
766 done
767 fi
768 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500769 successes:
770EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500771 for s in ${successes}; do
772 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500773 - message: '$s'
774EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500775 done
776 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500777 failures:
778EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500779 for f in ${failures}; do
780 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500781 - message: '$f'
782EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500783 done
784 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
785 cat << EOF
786 - name: interactive_${uart_number}_${key}
787 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500788 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500789EOF
790
791 if [ -z "${commands}" ]; then
792 cat <<EOF
793 - name: interactive_command_${uart_number}_${key}
794 command:
795EOF
796 else
797 for c in ${commands}; do
798 cat <<EOF
799 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300800 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500801EOF
802 done
803 fi
804 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500805 successes:
806EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500807 for s in ${successes}; do
808 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500809 - message: '$s'
810EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500811 done
812
813 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
814 cat << EOF
815 - name: interactive_${uart_number}_${key}
816 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500817 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500818EOF
819 if [ -z "${commands}" ]; then
820 cat <<EOF
821 - name: interactive_command_${uart_number}_${key}
822 command:
823EOF
824 else
825 for c in ${commands}; do
826 cat <<EOF
827 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300828 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500829EOF
830 done
831 fi
832 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500833 failures:
834EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500835 for f in ${failures}; do
836 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500837 - message: '$f'
838EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500839 done
840 else
841 cat << EOF
842 - name: interactive_${uart_number}_${key}
843 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500844 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500845EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500846 if [ -z "${commands}" ]; then
847 cat <<EOF
848 - name: interactive_command_${uart_number}_${key}
849 command:
850EOF
851 else
852 for c in ${commands}; do
853 cat <<EOF
854 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300855 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500856EOF
857 done
858 fi
859 fi
860
861 IFS=$OLD_IFS
862 fi # end of interactive action
863
864 done # end of expect loop
865
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500866 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500867 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500868}
869
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500870docker_registry_append() {
871 # if docker_registry is empty, just use local docker registry
872 [ -z "$docker_registry" ] && return
873
874 local last=-1
875 local last_char="${docker_registry:last}"
876
877 if [ "$last_char" != '/' ]; then
878 docker_registry="${docker_registry}/";
879 fi
880 echo "$docker_registry"
881}
882
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000883# generate GPT image and archive it
884gen_gpt_bin() {
885 raw_image="fip_gpt.bin"
886 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
887 img_bank_uuid=`uuidgen`
888 disk_uuid=`uuidgen`
889 bin="${1:?}"
890
891 # maximum FIP size 2MB
892 fip_max_size=2097152
893 start_sector=34
894 sector_size=512
895 num_sectors=$(($fip_max_size/$sector_size))
896 bin_size=$(stat -c %s $bin)
897
898 if [[ $fip_max_size -lt $bin_size ]]
899 then
900 echo "FIP binary ($bin_size bytes) larger than max partition 1"
901 "size ($fip_max_size byte)"
902 return
903 fi
904
905 # create raw 5MB image
906 dd if=/dev/zero of=$raw_image bs=5M count=1
907
908 # create GPT image
909 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
910 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
911
912 echo "write binary $bin at sector $start_sector"
913 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
914 count=$num_sectors conv=notrunc
915
916 archive_file "fip_gpt.bin"
917}
918
Fathi Boudra422bf772019-12-02 11:10:16 +0200919set +u