blob: 9fc4e68b0bdad3026926cbbff0ad113e5f773f5c [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
246fvp_romlib_runtime() {
247 local tmpdir="$(mktempdir)"
248
249 # Save BL1 and romlib binaries from original build
250 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
251 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
252
253 # Patch index file
Sandrine Bailleux6b693e42022-06-17 16:20:56 +0200254 (
255 fvp_romlib_jmptbl="${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
256 fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
Fathi Boudra422bf772019-12-02 11:10:16 +0200257
Sandrine Bailleux6b693e42022-06-17 16:20:56 +0200258 function __restore() {
259 mv "$fvp_romlib_jmptbl_backup" "$fvp_romlib_jmptbl";
260 }
261
262 # Make sure the original index file is restored.
263 # This will be done either when the current sub-shell exits or
264 # when one of the sub-shell's commands fails.
265 trap __restore EXIT HUP QUIT INT TERM
266
267 cp "$fvp_romlib_jmptbl" "$fvp_romlib_jmptbl_backup"
268 sed -i '/fdt/ s/.$/&\ patch/' "$fvp_romlib_jmptbl"
269
270 # Rebuild with patched file
271 echo "Building patched romlib:"
272 build_tf
273 )
Fathi Boudra422bf772019-12-02 11:10:16 +0200274
Fathi Boudra422bf772019-12-02 11:10:16 +0200275 # Retrieve original BL1 and romlib binaries
276 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
277 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
278}
279
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500280fvp_gen_bin_url() {
281 local bin_mode="${bin_mode:?}"
282 local bin="${1:?}"
283
284 if upon "$jenkins_run"; then
285 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
286 else
287 echo "file://$workspace/artefacts/$bin_mode/$bin"
288 fi
289}
290
291gen_fvp_yaml_template() {
292 local yaml_template_file="$workspace/fvp_template.yaml"
293
294 # must parameters for yaml generation
295 local payload_type="${payload_type:?}"
296
297 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
298
299 archive_file "$yaml_template_file"
300}
301
302gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600303 local model="${model:?}"
304
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500305 local yaml_template_file="$workspace/fvp_template.yaml"
306 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500307 local yaml_job_file="$workspace/job.yaml"
308 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500309
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500310 # this function expects a template, quit if it is not present
311 if [ ! -f "$yaml_template_file" ]; then
312 return
313 fi
314
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600315 local model_params="${fvp_models[$model]}"
316 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
317 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
318 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
319
320 # model params are required for correct yaml creation, quit if empty
321 if [ -z "${model_name}" ]; then
322 echo "FVP model param 'model_name' variable empty, yaml not produced"
323 return
324 elif [ -z "${model_dir}" ]; then
325 echo "FVP model param 'model_dir' variable empty, yaml not produced"
326 return
327 elif [ -z "${model_bin}" ]; then
328 echo "FVP model param 'model_bin' variable empty, yaml not produced"
329 return
330 fi
331
332 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500333
334 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500335 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500336
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600337 # possible artefacts
338 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500339 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600340 bl2="$(fvp_gen_bin_url bl2.bin)"
341 bl31="$(fvp_gen_bin_url bl31.bin)"
342 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600343 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
344 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
345 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
346 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500347 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500348 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600349 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
350 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500351 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600352 fvp_spmc_manifest_dtb="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600353 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600354 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
355 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500356 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600357 ivy="$(fvp_gen_bin_url ivy.pkg)"
358 manifest_dtb="$(fvp_gen_bin_url manifest.dtb)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600359 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
360 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500361 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
362 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600363 ramdisk="$(fvp_gen_bin_url initrd.bin)"
364 romlib="$(fvp_gen_bin_url romlib.bin)"
365 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600366 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
367 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
368 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
369 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
370 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600371 spm="$(fvp_gen_bin_url spm.bin)"
372 tftf="$(fvp_gen_bin_url tftf.bin)"
373 tmp="$(fvp_gen_bin_url tmp.bin)"
374 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500375
376 docker_registry="${docker_registry:-}"
377 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500378 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600379 prompt1='/ #'
380 prompt2='root@genericarmv8:~#'
381 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500382
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500383 test_config="${TEST_CONFIG}"
384
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600385 # arrays that relates variables and template macros
386 # NOTE: any addition on these arrays, requires an addition in the
387 # fvp templates
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500388 declare -A metadata_macros
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600389 declare -A yaml_macros
390 declare -A artefacts_macros
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500391 metadata_macros=(
392 [test_config]="{TEST_CONFIG}"
393 )
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600394 yaml_macros=(
395 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
396 [docker_name]="{BOOT_DOCKER_NAME}"
397 [model]="{MODEL}"
398 [model_bin]="{BOOT_IMAGE_BIN}"
399 [model_dir]="{BOOT_IMAGE_DIR}"
400 [prompt1]="{PROMPT1}"
401 [prompt2]="{PROMPT2}"
402 [version_string]="{BOOT_VERSION_STRING}"
403 )
404 artefacts_macros=(
405 [backup_fip]="{BACKUP_FIP}"
406 [bl1]="{BL1}"
407 [bl2]="{BL2}"
408 [bl31]="{BL31}"
409 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600410 [cactus_primary]="{CACTUS_PRIMARY}"
411 [cactus_secondary]="{CACTUS_SECONDARY}"
412 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500413 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600414 [fvp_spmc_manifest_dtb]="{FVP_SPMC_MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600415 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600416 [dtb]="{DTB}"
417 [el3_payload]="{EL3_PAYLOAD}"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500418 [fip_gpt]="{FIP_GPT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600419 [fwu_fip]="{FWU_FIP}"
420 [fip]="{FIP}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600421 [generic_trace]="{GENERIC_TRACE}"
422 [hafnium]="{HAFNIUM}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600423 [image]="{IMAGE}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600424 [ivy]="{IVY}"
425 [manifest_dtb]="{MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600426 [mcp_rom]="{MCP_ROM}"
427 [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600428 [ns_bl1u]="{NS_BL1U}"
429 [ns_bl2u]="{NS_BL2U}"
430 [ramdisk]="{RAMDISK}"
431 [romlib]="{ROMLIB}"
432 [rootfs]="{ROOTFS}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600433 [secure_hafnium]="{SECURE_HAFNIUM}"
434 [scp_ram]="{SCP_RAM}"
435 [scp_ram_hyphen]="{SCP_RAM_HYPHEN}"
436 [scp_rom]="{SCP_ROM}"
437 [scp_rom_hyphen]="{SCP_ROM_HYPHEN}"
438 [spm]="{SPM}"
439 [tftf]="{TFTF}"
440 [tmp]="{TMP}"
441 [uboot]="{UBOOT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600442 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500443
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600444 # templates cover all possible artefacts, but model parameters may
445 # not required all, i.e. romlib.bin, so delete those irrelevant from
446 # the template
447 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600448 # there are artefacts where deletion is handled in special case, so treat them accordingly
449 case "$m" in
450 busybox)
451 # besides the macro removal, remove the compression field
452 if ! grep -q "${m}.bin" "$archive/model_params"; then
453 sed -i "/$m:\$/d" "${yaml_template_file}"
454 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
455 fi
456 ;;
457 cactus_primary)
458 # cactus packages have a hyphen, not an underscore
459 if ! grep -E -q "cactus-primary.pkg" "$archive/model_params"; then
460 sed -i "/$m:\$/d" "${yaml_template_file}"
461 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
462 fi
463 ;;
464 cactus_secondary)
465 # cactus packages have a hyphen, not an underscore
466 if ! grep -E -q "cactus-secondary.pkg" "$archive/model_params"; then
467 sed -i "/$m:\$/d" "${yaml_template_file}"
468 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
469 fi
470 ;;
471 cactus_tertiary)
472 # cactus packages have a hyphen, not an underscore
473 if ! grep -E -q "cactus-tertiary.pkg" "$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 Sandovald98f8332021-04-13 16:46:38 -0500478 coverage_trace_plugin)
479 if ! grep -q "coverage_trace.so" "$archive/model_params"; then
480 sed -i "/$m:\$/d" "${yaml_template_file}"
481 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
482 fi
483 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600484 fvp_spmc_manifest_dtb)
485 # handles fvp_spmc_manifest.dtb as DTB file
486 if ! grep -q "=fvp_spmc_manifest.dtb" "$archive/model_params"; then
487 sed -i "/ $m:\$/d" "${yaml_template_file}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600488 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
489 fi
490 ;;
491 generic_trace)
492 # the image (Linux Kernel) is named as kernel.bin
493 if ! grep -q "GenericTrace.so" "$archive/model_params"; then
494 sed -i "/$m:\$/d" "${yaml_template_file}"
495 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
496 fi
497 ;;
498 image)
499 # the image (Linux Kernel) is named as kernel.bin
500 if ! grep -q "kernel.bin" "$archive/model_params"; then
501 sed -i "/$m:\$/d" "${yaml_template_file}"
502 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
503 fi
504 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600505 ivy)
506 # the ivy package
507 if ! grep -q "ivy.pkg" "$archive/model_params"; then
508 sed -i "/$m:\$/d" "${yaml_template_file}"
509 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
510 fi
511 ;;
512 manifest_dtb)
513 # handles manifest.dtb as DTB file
514 if ! grep -q "=manifest.dtb" "$archive/model_params"; then
515 sed -i "/ $m:\$/d" "${yaml_template_file}"
516 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
517 fi
518 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600519 mcp_rom_hyphen)
520 # mcp rom is either present as mcp-rom or mcp_rom, handle the former case
521 if ! grep -q "mcp-rom.bin" "$archive/model_params"; then
522 sed -i "/$m:\$/d" "${yaml_template_file}"
523 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
524 fi
525 ;;
526 ramdisk)
527 # ramdisk is named initrd and is present with to extensions: bin or img
528 if ! grep -E -q "initrd.bin|initrd.img" "$archive/model_params"; then
529 sed -i "/$m:\$/d" "${yaml_template_file}"
530 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
531 fi
532 ;;
533 rootfs)
534 # besides the macro removal, remove the compression field
535 if ! grep -q "rootfs.bin" "$archive/model_params"; then
536 sed -i "/$m:\$/d" "${yaml_template_file}"
537 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
538 fi
539 ;;
540 scp_ram_hyphen)
541 # scp ram is either present as scp-ram or scp_ram, handle the former case
542 if ! grep -q "scp-ram.bin" "$archive/model_params"; then
543 sed -i "/$m:\$/d" "${yaml_template_file}"
544 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
545 fi
546 ;;
547 scp_rom_hyphen)
548 # scp rom is either present as scp-rom or scp_rom, handle the former case
549 if ! grep -q "scp-rom.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 *)
555 if ! grep -q "${m}.bin" "$archive/model_params"; then
556 sed -i "/$m:\$/d" "${yaml_template_file}"
557 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
558 fi
559 ;;
560 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600561 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500562
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600563 # copied files are the working files
564 cp "${yaml_template_file}" "${yaml_file}"
565 cp "$archive/model_params" "$lava_model_params"
566
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500567 # replace metadata macros with real values
568 for m in "${!metadata_macros[@]}"; do
569 sed -i -e "s|${metadata_macros[$m]}|${!m}|" "$yaml_file"
570 done
571
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600572 # replace yaml macros with real values
573 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600574 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600575 done
576
577 # replace artefact macros with real values
578 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600579 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600580 done
581
582 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600583 # replace them. As in the macro removal above, handle special cases for several
584 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600585 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600586 case "$m" in
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600587 cactus_primary)
588 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
589 ;;
590 cactus_secondary)
591 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
592 ;;
593 cactus_tertiary)
594 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
595 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500596 coverage_trace_plugin)
597 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
598 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
599 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600600 fvp_spmc_manifest_dtb)
601 sed -i -e "s|=fvp_spmc_manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
602 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600603 generic_trace)
604 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
605 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
606 ;;
607 image)
608 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
609 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600610 ivy)
611 sed -i -e "s|=ivy.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
612 ;;
613 manifest_dtb)
614 sed -i -e "s|=manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
615 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600616 mcp_rom_hyphen)
617 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
618 ;;
619 ramdisk)
620 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
621 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
622 ;;
623 scp_ram_hyphen)
624 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
625 ;;
626 scp_rom_hyphen)
627 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
628 ;;
629 tmp | hafnium | secure_hafnium)
630 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
631 ;;
632 *)
633 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
634 ;;
635 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600636 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500637
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500638 # include the model parameters
639 while read -r line; do
640 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600641 yaml_line="- \"${line}\""
642 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500643 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500644 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600645 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500646
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500647 # Append expect commands into the job definition through test-interactive commands
648 gen_fvp_yaml_expect >> "$yaml_file"
649
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600650 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500651 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500652
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600653 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500654 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500655 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500656}
657
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500658gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500659
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500660 run_root="$archive/run"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500661
662 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500663 for expect_file in $(find $run_root -name expect); do
664
665 # TODO: currently, only handle UART 0
666 case $expect_file in
667 *uart0* )
668 uart_number=uart0
669 ;;
670 *)
671 continue
672 ;;
673 esac
674
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500675 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
676 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
677 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
678 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
679 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
680 #
681 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
682 # where multiple successes or failures or commands are separated by @
683 #
684 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
685 # where multiple patterns are separated by @
686 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500687 expect_string=()
688
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500689 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500690 expect_file=$(cat $expect_file)
691
692 # Source the run_config enviroment variables
693 env=$run_root/$uart_number/env
694 if [ -e $env ]; then
695 source $env
696 fi
697
698 # Get all expect strings
Paul Sokolovskyeece6f72021-12-01 15:04:29 +0300699 expect_file=$ci_root/expect-lava/${expect_file}
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500700 source $expect_file
701
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500702
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500703 if [ ${#expect_string[@]} -gt 0 ]; then
704
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500705 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500706 for key in "${!expect_string[@]}"; do
707
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500708 # single raw expect string
709 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500710
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500711 # action type: either m or i
712 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500713
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500714 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500715
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500716 start="$(echo "${es}" | awk -F ';' '{print $2}')"
717 end="$(echo "${es}" | awk -F ';' '{print $3}')"
718 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
719
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500720 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500721- test:
722 monitors:
723 - name: tests
724 start: '${start}'
725 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500726EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500727 # Patterns are separated by '@'
728 OLD_IFS=$IFS; IFS=$'@'
729 for p in ${patterns}; do
730 cat << EOF
731 pattern: '$p'
732EOF
733 done
734 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500735 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500736 fixupdict:
737 PASS: pass
738 FAIL: fail
739EOF
740 fi # end of monitor action
741
742 if [ "${action}" = "i" ]; then
743
744 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
745 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
746 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
747 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
748
749 cat << EOF
750- test:
751 interactive:
752EOF
753 OLD_IFS=$IFS; IFS=$'@'
754
755 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
756 cat << EOF
757 - name: interactive_${uart_number}_${key}
758 prompts: ['${prompts}']
759 script:
760EOF
761 if [ -z "${commands}" ]; then
762 cat <<EOF
763 - name: interactive_command_${uart_number}_${key}
764 command:
765EOF
766 else
767 for c in ${commands}; do
768 cat <<EOF
769 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300770 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500771EOF
772 done
773 fi
774 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500775 successes:
776EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500777 for s in ${successes}; do
778 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500779 - message: '$s'
780EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500781 done
782 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500783 failures:
784EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500785 for f in ${failures}; do
786 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500787 - message: '$f'
788EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500789 done
790 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
791 cat << EOF
792 - name: interactive_${uart_number}_${key}
793 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500794 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500795EOF
796
797 if [ -z "${commands}" ]; then
798 cat <<EOF
799 - name: interactive_command_${uart_number}_${key}
800 command:
801EOF
802 else
803 for c in ${commands}; do
804 cat <<EOF
805 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300806 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500807EOF
808 done
809 fi
810 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500811 successes:
812EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500813 for s in ${successes}; do
814 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500815 - message: '$s'
816EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500817 done
818
819 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
820 cat << EOF
821 - name: interactive_${uart_number}_${key}
822 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500823 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500824EOF
825 if [ -z "${commands}" ]; then
826 cat <<EOF
827 - name: interactive_command_${uart_number}_${key}
828 command:
829EOF
830 else
831 for c in ${commands}; do
832 cat <<EOF
833 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300834 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500835EOF
836 done
837 fi
838 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500839 failures:
840EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500841 for f in ${failures}; do
842 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500843 - message: '$f'
844EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500845 done
846 else
847 cat << EOF
848 - name: interactive_${uart_number}_${key}
849 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500850 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500851EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500852 if [ -z "${commands}" ]; then
853 cat <<EOF
854 - name: interactive_command_${uart_number}_${key}
855 command:
856EOF
857 else
858 for c in ${commands}; do
859 cat <<EOF
860 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300861 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500862EOF
863 done
864 fi
865 fi
866
867 IFS=$OLD_IFS
868 fi # end of interactive action
869
870 done # end of expect loop
871
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500872 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500873 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500874}
875
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500876docker_registry_append() {
877 # if docker_registry is empty, just use local docker registry
878 [ -z "$docker_registry" ] && return
879
880 local last=-1
881 local last_char="${docker_registry:last}"
882
883 if [ "$last_char" != '/' ]; then
884 docker_registry="${docker_registry}/";
885 fi
886 echo "$docker_registry"
887}
888
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000889# generate GPT image and archive it
890gen_gpt_bin() {
891 raw_image="fip_gpt.bin"
892 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
893 img_bank_uuid=`uuidgen`
894 disk_uuid=`uuidgen`
895 bin="${1:?}"
896
897 # maximum FIP size 2MB
898 fip_max_size=2097152
899 start_sector=34
900 sector_size=512
901 num_sectors=$(($fip_max_size/$sector_size))
902 bin_size=$(stat -c %s $bin)
903
904 if [[ $fip_max_size -lt $bin_size ]]
905 then
906 echo "FIP binary ($bin_size bytes) larger than max partition 1"
907 "size ($fip_max_size byte)"
908 return
909 fi
910
911 # create raw 5MB image
912 dd if=/dev/zero of=$raw_image bs=5M count=1
913
914 # create GPT image
915 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
916 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
917
918 echo "write binary $bin at sector $start_sector"
919 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
920 count=$num_sectors conv=notrunc
921
922 archive_file "fip_gpt.bin"
923}
924
Fathi Boudra422bf772019-12-02 11:10:16 +0200925set +u