blob: 546bfba441c5b5eb2f8cf28b5d3bcc32884367a0 [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"
85[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1"
86[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2"
87[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4"
Leonardo Sandoval54f1ade2021-06-26 19:20:48 -050088[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x4"
Maksims Svecovsd10c1b92021-10-06 10:25:40 +010089[neoverse_n2]="${fvp_arm_std_library_11_12};FVP_Base_Neoverse-N1x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060090[neoverse-v1x4]=";;;"
Manish V Badarkhecbed15e2021-07-02 09:34:53 +010091[cortexa710x4]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060092[css-rdv1]=";;;"
93[css-rde1edge]=";;;"
94[css-rdn1edge]=";;;"
95[css-rdn1edgex2]=";;;"
96[css-sgi575]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060097[tc0]=";;;"
Usama Arifcba711d2021-08-04 15:53:42 +010098[tc1]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060099)
100
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500101
Fathi Boudra422bf772019-12-02 11:10:16 +0200102# FVP Kernel URLs
103declare -A fvp_kernels
104fvp_kernels=(
105[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
106[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
107[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
108[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
109[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
110)
111
Fathi Boudra422bf772019-12-02 11:10:16 +0200112# FVP initrd URLs
113declare -A fvp_initrd_urls
114fvp_initrd_urls=(
115[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200116[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
117[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
118[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
119)
120
Fathi Boudra422bf772019-12-02 11:10:16 +0200121get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100122 url="$tfa_downloads/optee/tee.bin" \
123 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200124 archive_file "bl32.bin"
125}
126
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100127# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
128# specific build rather than the default one generated by Jenkins.
129get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100130 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100131 saveas="bl32.bin" fetch_file
132 archive_file "bl32.bin"
133
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100134 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100135 saveas="bl32_extra1.bin" fetch_file
136 archive_file "bl32_extra1.bin"
137
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600138 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
139 # so just create the file
140 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100141 archive_file "bl32_extra2.bin"
142}
143
Fathi Boudra422bf772019-12-02 11:10:16 +0200144get_uboot32_bin() {
145 local tmpdir="$(mktempdir)"
146
147 pushd "$tmpdir"
148 extract_fip "$uboot32_fip_url"
149 mv "nt-fw.bin" "uboot.bin"
150 archive_file "uboot.bin"
151 popd
152}
153
154get_uboot_bin() {
155 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
156
157 url="$uboot_url" saveas="uboot.bin" fetch_file
158 archive_file "uboot.bin"
159}
160
161get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500162 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
163 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 +0200164
165 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
166 archive_file "uefi.bin"
167}
168
169get_kernel() {
170 local kernel_type="${kernel_type:?}"
171 local url="${fvp_kernels[$kernel_type]}"
172
173 url="${url:?}" saveas="kernel.bin" fetch_file
174 archive_file "kernel.bin"
175}
176
177get_initrd() {
178 local initrd_type="${initrd_type:?}"
179 local url="${fvp_initrd_urls[$initrd_type]}"
180
181 url="${url:?}" saveas="initrd.bin" fetch_file
182 archive_file "initrd.bin"
183}
184
185get_dtb() {
186 local dtb_type="${dtb_type:?}"
187 local dtb_url
188 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500189 local cc="$(get_tf_opt CROSS_COMPILE)"
190 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200191
192 case "$dtb_type" in
193 "fvp-base-quad-cluster-gicv3-psci")
194 # Get the quad-cluster FDT from pdsw area
195 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
196 url="$dtb_url" saveas="$dtb_saveas" fetch_file
197 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200198 *)
Zelalem219df412020-05-17 19:21:20 -0500199 # Preprocess DTS file
200 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
201 -o "$workspace/${dtb_type}.pre.dts" \
202 "$tf_root/fdts/${dtb_type}.dts"
203 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200204 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500205 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200206 esac
207
208 archive_file "$dtb_saveas"
209}
210
211get_rootfs() {
212 local tmpdir
213 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
214 local cached="$project_filer/ci-files/$fs_base"
215
216 if upon "$jenkins_run" && [ -f "$cached" ]; then
217 # Job workspace is limited in size, and the root file system is
218 # quite large. This means, parallel runs of root file system
219 # tests could fail. So, for Jenkins runs, copy and use the root
220 # file system image from the $CI_SCRATCH location
221 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
222 mkdir -p "$private"
223 rm -f "$private/rootfs.bin"
224 url="$cached" saveas="$private/rootfs.bin" fetch_file
225 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
226 return
227 fi
228
229 tmpdir="$(mktempdir)"
230 pushd "$tmpdir"
231 url="$rootfs_url" saveas="rootfs.bin" fetch_file
232
233 # Possibly, the filesystem image we just downloaded is compressed.
234 # Decompress it if required.
235 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
236 echo "Decompressing root file system image rootfs.bin ..."
237 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
238 mv uncompressed_fs.bin "rootfs.bin"
239 fi
240
241 archive_file "rootfs.bin"
242 popd
243}
244
Zelalem219df412020-05-17 19:21:20 -0500245fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
246
Fathi Boudra422bf772019-12-02 11:10:16 +0200247fvp_romlib_runtime() {
248 local tmpdir="$(mktempdir)"
249
250 # Save BL1 and romlib binaries from original build
251 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
252 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
253
254 # Patch index file
Zelalem219df412020-05-17 19:21:20 -0500255 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
256 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200257
258 # Rebuild with patched file
259 echo "Building patched romlib:"
260 build_tf
261
Fathi Boudra422bf772019-12-02 11:10:16 +0200262 # Retrieve original BL1 and romlib binaries
263 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
264 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
265}
266
Zelalem219df412020-05-17 19:21:20 -0500267fvp_romlib_cleanup() {
268 # Restore original index
269 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
270}
271
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500272
273fvp_gen_bin_url() {
274 local bin_mode="${bin_mode:?}"
275 local bin="${1:?}"
276
277 if upon "$jenkins_run"; then
278 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
279 else
280 echo "file://$workspace/artefacts/$bin_mode/$bin"
281 fi
282}
283
284gen_fvp_yaml_template() {
285 local yaml_template_file="$workspace/fvp_template.yaml"
286
287 # must parameters for yaml generation
288 local payload_type="${payload_type:?}"
289
290 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
291
292 archive_file "$yaml_template_file"
293}
294
295gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600296 local model="${model:?}"
297
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500298 local yaml_template_file="$workspace/fvp_template.yaml"
299 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500300 local yaml_job_file="$workspace/job.yaml"
301 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500302
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500303 # this function expects a template, quit if it is not present
304 if [ ! -f "$yaml_template_file" ]; then
305 return
306 fi
307
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600308 local model_params="${fvp_models[$model]}"
309 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
310 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
311 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
312
313 # model params are required for correct yaml creation, quit if empty
314 if [ -z "${model_name}" ]; then
315 echo "FVP model param 'model_name' variable empty, yaml not produced"
316 return
317 elif [ -z "${model_dir}" ]; then
318 echo "FVP model param 'model_dir' variable empty, yaml not produced"
319 return
320 elif [ -z "${model_bin}" ]; then
321 echo "FVP model param 'model_bin' variable empty, yaml not produced"
322 return
323 fi
324
325 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500326
327 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500328 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500329
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600330 # possible artefacts
331 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500332 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600333 bl2="$(fvp_gen_bin_url bl2.bin)"
334 bl31="$(fvp_gen_bin_url bl31.bin)"
335 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600336 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
337 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
338 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
339 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500340 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500341 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600342 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
343 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500344 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600345 fvp_spmc_manifest_dtb="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600346 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600347 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
348 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500349 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600350 ivy="$(fvp_gen_bin_url ivy.pkg)"
351 manifest_dtb="$(fvp_gen_bin_url manifest.dtb)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600352 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
353 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500354 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
355 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600356 ramdisk="$(fvp_gen_bin_url initrd.bin)"
357 romlib="$(fvp_gen_bin_url romlib.bin)"
358 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600359 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
360 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
361 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
362 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
363 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600364 spm="$(fvp_gen_bin_url spm.bin)"
365 tftf="$(fvp_gen_bin_url tftf.bin)"
366 tmp="$(fvp_gen_bin_url tmp.bin)"
367 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500368
369 docker_registry="${docker_registry:-}"
370 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500371 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600372 prompt1='/ #'
373 prompt2='root@genericarmv8:~#'
374 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500375
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500376 test_config="${TEST_CONFIG}"
377
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600378 # arrays that relates variables and template macros
379 # NOTE: any addition on these arrays, requires an addition in the
380 # fvp templates
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500381 declare -A metadata_macros
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600382 declare -A yaml_macros
383 declare -A artefacts_macros
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500384 metadata_macros=(
385 [test_config]="{TEST_CONFIG}"
386 )
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600387 yaml_macros=(
388 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
389 [docker_name]="{BOOT_DOCKER_NAME}"
390 [model]="{MODEL}"
391 [model_bin]="{BOOT_IMAGE_BIN}"
392 [model_dir]="{BOOT_IMAGE_DIR}"
393 [prompt1]="{PROMPT1}"
394 [prompt2]="{PROMPT2}"
395 [version_string]="{BOOT_VERSION_STRING}"
396 )
397 artefacts_macros=(
398 [backup_fip]="{BACKUP_FIP}"
399 [bl1]="{BL1}"
400 [bl2]="{BL2}"
401 [bl31]="{BL31}"
402 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600403 [cactus_primary]="{CACTUS_PRIMARY}"
404 [cactus_secondary]="{CACTUS_SECONDARY}"
405 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500406 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600407 [fvp_spmc_manifest_dtb]="{FVP_SPMC_MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600408 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600409 [dtb]="{DTB}"
410 [el3_payload]="{EL3_PAYLOAD}"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500411 [fip_gpt]="{FIP_GPT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600412 [fwu_fip]="{FWU_FIP}"
413 [fip]="{FIP}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600414 [generic_trace]="{GENERIC_TRACE}"
415 [hafnium]="{HAFNIUM}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600416 [image]="{IMAGE}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600417 [ivy]="{IVY}"
418 [manifest_dtb]="{MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600419 [mcp_rom]="{MCP_ROM}"
420 [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600421 [ns_bl1u]="{NS_BL1U}"
422 [ns_bl2u]="{NS_BL2U}"
423 [ramdisk]="{RAMDISK}"
424 [romlib]="{ROMLIB}"
425 [rootfs]="{ROOTFS}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600426 [secure_hafnium]="{SECURE_HAFNIUM}"
427 [scp_ram]="{SCP_RAM}"
428 [scp_ram_hyphen]="{SCP_RAM_HYPHEN}"
429 [scp_rom]="{SCP_ROM}"
430 [scp_rom_hyphen]="{SCP_ROM_HYPHEN}"
431 [spm]="{SPM}"
432 [tftf]="{TFTF}"
433 [tmp]="{TMP}"
434 [uboot]="{UBOOT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600435 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500436
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600437 # templates cover all possible artefacts, but model parameters may
438 # not required all, i.e. romlib.bin, so delete those irrelevant from
439 # the template
440 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600441 # there are artefacts where deletion is handled in special case, so treat them accordingly
442 case "$m" in
443 busybox)
444 # besides the macro removal, remove the compression field
445 if ! grep -q "${m}.bin" "$archive/model_params"; then
446 sed -i "/$m:\$/d" "${yaml_template_file}"
447 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
448 fi
449 ;;
450 cactus_primary)
451 # cactus packages have a hyphen, not an underscore
452 if ! grep -E -q "cactus-primary.pkg" "$archive/model_params"; then
453 sed -i "/$m:\$/d" "${yaml_template_file}"
454 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
455 fi
456 ;;
457 cactus_secondary)
458 # cactus packages have a hyphen, not an underscore
459 if ! grep -E -q "cactus-secondary.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_tertiary)
465 # cactus packages have a hyphen, not an underscore
466 if ! grep -E -q "cactus-tertiary.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 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500471 coverage_trace_plugin)
472 if ! grep -q "coverage_trace.so" "$archive/model_params"; then
473 sed -i "/$m:\$/d" "${yaml_template_file}"
474 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
475 fi
476 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600477 fvp_spmc_manifest_dtb)
478 # handles fvp_spmc_manifest.dtb as DTB file
479 if ! grep -q "=fvp_spmc_manifest.dtb" "$archive/model_params"; then
480 sed -i "/ $m:\$/d" "${yaml_template_file}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600481 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
482 fi
483 ;;
484 generic_trace)
485 # the image (Linux Kernel) is named as kernel.bin
486 if ! grep -q "GenericTrace.so" "$archive/model_params"; then
487 sed -i "/$m:\$/d" "${yaml_template_file}"
488 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
489 fi
490 ;;
491 image)
492 # the image (Linux Kernel) is named as kernel.bin
493 if ! grep -q "kernel.bin" "$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 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600498 ivy)
499 # the ivy package
500 if ! grep -q "ivy.pkg" "$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 ;;
505 manifest_dtb)
506 # handles manifest.dtb as DTB file
507 if ! grep -q "=manifest.dtb" "$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 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600512 mcp_rom_hyphen)
513 # mcp rom is either present as mcp-rom or mcp_rom, handle the former case
514 if ! grep -q "mcp-rom.bin" "$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 ;;
519 ramdisk)
520 # ramdisk is named initrd and is present with to extensions: bin or img
521 if ! grep -E -q "initrd.bin|initrd.img" "$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 rootfs)
527 # besides the macro removal, remove the compression field
528 if ! grep -q "rootfs.bin" "$archive/model_params"; then
529 sed -i "/$m:\$/d" "${yaml_template_file}"
530 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
531 fi
532 ;;
533 scp_ram_hyphen)
534 # scp ram is either present as scp-ram or scp_ram, handle the former case
535 if ! grep -q "scp-ram.bin" "$archive/model_params"; then
536 sed -i "/$m:\$/d" "${yaml_template_file}"
537 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
538 fi
539 ;;
540 scp_rom_hyphen)
541 # scp rom is either present as scp-rom or scp_rom, handle the former case
542 if ! grep -q "scp-rom.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 *)
548 if ! grep -q "${m}.bin" "$archive/model_params"; then
549 sed -i "/$m:\$/d" "${yaml_template_file}"
550 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
551 fi
552 ;;
553 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600554 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500555
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600556 # copied files are the working files
557 cp "${yaml_template_file}" "${yaml_file}"
558 cp "$archive/model_params" "$lava_model_params"
559
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500560 # replace metadata macros with real values
561 for m in "${!metadata_macros[@]}"; do
562 sed -i -e "s|${metadata_macros[$m]}|${!m}|" "$yaml_file"
563 done
564
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600565 # replace yaml macros with real values
566 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600567 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600568 done
569
570 # replace artefact macros with real values
571 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600572 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600573 done
574
575 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600576 # replace them. As in the macro removal above, handle special cases for several
577 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600578 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600579 case "$m" in
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600580 cactus_primary)
581 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
582 ;;
583 cactus_secondary)
584 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
585 ;;
586 cactus_tertiary)
587 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
588 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500589 coverage_trace_plugin)
590 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
591 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
592 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600593 fvp_spmc_manifest_dtb)
594 sed -i -e "s|=fvp_spmc_manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
595 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600596 generic_trace)
597 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
598 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
599 ;;
600 image)
601 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
602 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600603 ivy)
604 sed -i -e "s|=ivy.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
605 ;;
606 manifest_dtb)
607 sed -i -e "s|=manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
608 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600609 mcp_rom_hyphen)
610 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
611 ;;
612 ramdisk)
613 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
614 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
615 ;;
616 scp_ram_hyphen)
617 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
618 ;;
619 scp_rom_hyphen)
620 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
621 ;;
622 tmp | hafnium | secure_hafnium)
623 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
624 ;;
625 *)
626 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
627 ;;
628 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600629 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500630
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500631 # include the model parameters
632 while read -r line; do
633 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600634 yaml_line="- \"${line}\""
635 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500636 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500637 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600638 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500639
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500640 # Append expect commands into the job definition through test-interactive commands
641 gen_fvp_yaml_expect >> "$yaml_file"
642
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600643 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500644 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500645
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600646 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500647 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500648 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500649}
650
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500651gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500652
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500653 run_root="$archive/run"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500654
655 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500656 for expect_file in $(find $run_root -name expect); do
657
658 # TODO: currently, only handle UART 0
659 case $expect_file in
660 *uart0* )
661 uart_number=uart0
662 ;;
663 *)
664 continue
665 ;;
666 esac
667
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500668 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
669 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
670 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
671 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
672 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
673 #
674 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
675 # where multiple successes or failures or commands are separated by @
676 #
677 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
678 # where multiple patterns are separated by @
679 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500680 expect_string=()
681
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500682 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500683 expect_file=$(cat $expect_file)
684
685 # Source the run_config enviroment variables
686 env=$run_root/$uart_number/env
687 if [ -e $env ]; then
688 source $env
689 fi
690
691 # Get all expect strings
Paul Sokolovskyeece6f72021-12-01 15:04:29 +0300692 expect_file=$ci_root/expect-lava/${expect_file}
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500693 source $expect_file
694
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500695
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500696 if [ ${#expect_string[@]} -gt 0 ]; then
697
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500698 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500699 for key in "${!expect_string[@]}"; do
700
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500701 # single raw expect string
702 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500703
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500704 # action type: either m or i
705 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500706
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500707 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500708
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500709 start="$(echo "${es}" | awk -F ';' '{print $2}')"
710 end="$(echo "${es}" | awk -F ';' '{print $3}')"
711 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
712
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500713 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500714- test:
715 monitors:
716 - name: tests
717 start: '${start}'
718 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500719EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500720 # Patterns are separated by '@'
721 OLD_IFS=$IFS; IFS=$'@'
722 for p in ${patterns}; do
723 cat << EOF
724 pattern: '$p'
725EOF
726 done
727 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500728 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500729 fixupdict:
730 PASS: pass
731 FAIL: fail
732EOF
733 fi # end of monitor action
734
735 if [ "${action}" = "i" ]; then
736
737 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
738 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
739 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
740 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
741
742 cat << EOF
743- test:
744 interactive:
745EOF
746 OLD_IFS=$IFS; IFS=$'@'
747
748 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
749 cat << EOF
750 - name: interactive_${uart_number}_${key}
751 prompts: ['${prompts}']
752 script:
753EOF
754 if [ -z "${commands}" ]; then
755 cat <<EOF
756 - name: interactive_command_${uart_number}_${key}
757 command:
758EOF
759 else
760 for c in ${commands}; do
761 cat <<EOF
762 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300763 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500764EOF
765 done
766 fi
767 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500768 successes:
769EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500770 for s in ${successes}; do
771 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500772 - message: '$s'
773EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500774 done
775 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500776 failures:
777EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500778 for f in ${failures}; do
779 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500780 - message: '$f'
781EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500782 done
783 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
784 cat << EOF
785 - name: interactive_${uart_number}_${key}
786 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500787 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500788EOF
789
790 if [ -z "${commands}" ]; then
791 cat <<EOF
792 - name: interactive_command_${uart_number}_${key}
793 command:
794EOF
795 else
796 for c in ${commands}; do
797 cat <<EOF
798 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300799 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500800EOF
801 done
802 fi
803 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500804 successes:
805EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500806 for s in ${successes}; do
807 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500808 - message: '$s'
809EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500810 done
811
812 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
813 cat << EOF
814 - name: interactive_${uart_number}_${key}
815 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500816 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500817EOF
818 if [ -z "${commands}" ]; then
819 cat <<EOF
820 - name: interactive_command_${uart_number}_${key}
821 command:
822EOF
823 else
824 for c in ${commands}; do
825 cat <<EOF
826 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300827 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500828EOF
829 done
830 fi
831 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500832 failures:
833EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500834 for f in ${failures}; do
835 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500836 - message: '$f'
837EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500838 done
839 else
840 cat << EOF
841 - name: interactive_${uart_number}_${key}
842 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500843 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500844EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500845 if [ -z "${commands}" ]; then
846 cat <<EOF
847 - name: interactive_command_${uart_number}_${key}
848 command:
849EOF
850 else
851 for c in ${commands}; do
852 cat <<EOF
853 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300854 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500855EOF
856 done
857 fi
858 fi
859
860 IFS=$OLD_IFS
861 fi # end of interactive action
862
863 done # end of expect loop
864
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500865 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500866 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500867}
868
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500869docker_registry_append() {
870 # if docker_registry is empty, just use local docker registry
871 [ -z "$docker_registry" ] && return
872
873 local last=-1
874 local last_char="${docker_registry:last}"
875
876 if [ "$last_char" != '/' ]; then
877 docker_registry="${docker_registry}/";
878 fi
879 echo "$docker_registry"
880}
881
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000882# generate GPT image and archive it
883gen_gpt_bin() {
884 raw_image="fip_gpt.bin"
885 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
886 img_bank_uuid=`uuidgen`
887 disk_uuid=`uuidgen`
888 bin="${1:?}"
889
890 # maximum FIP size 2MB
891 fip_max_size=2097152
892 start_sector=34
893 sector_size=512
894 num_sectors=$(($fip_max_size/$sector_size))
895 bin_size=$(stat -c %s $bin)
896
897 if [[ $fip_max_size -lt $bin_size ]]
898 then
899 echo "FIP binary ($bin_size bytes) larger than max partition 1"
900 "size ($fip_max_size byte)"
901 return
902 fi
903
904 # create raw 5MB image
905 dd if=/dev/zero of=$raw_image bs=5M count=1
906
907 # create GPT image
908 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
909 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
910
911 echo "write binary $bin at sector $start_sector"
912 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
913 count=$num_sectors conv=notrunc
914
915 archive_file "fip_gpt.bin"
916}
917
Fathi Boudra422bf772019-12-02 11:10:16 +0200918set +u