blob: 023a2bc74ea80cd4515419468d8ae5eeaee50124 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Rupinderjit Singh385f17d2022-07-18 20:28:10 +01003# Copyright (c) 2020-2022, 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"
laurenw-arm06c4a192022-07-12 14:55:28 -050085[cortex-a78cx4]="${fvp_arm_std_library};FVP_Base_Cortex-A78Cx4"
johpow011008edc2022-02-01 18:50:33 -060086[cortex-x2]="${fvp_arm_std_library};FVP_Base_Cortex-X2x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060087[neoverse_e1x1]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x1"
88[neoverse_e1x2]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x2"
89[neoverse_e1x4]="${fvp_arm_std_library};FVP_Base_Neoverse-E1x4"
Leonardo Sandoval54f1ade2021-06-26 19:20:48 -050090[neoverse_n1]="${fvp_arm_std_library};FVP_Base_Neoverse-N1x4"
Maksims Svecovsd10c1b92021-10-06 10:25:40 +010091[neoverse_n2]="${fvp_arm_std_library_11_12};FVP_Base_Neoverse-N1x4"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060092[neoverse-v1x4]=";;;"
Manish V Badarkhecbed15e2021-07-02 09:34:53 +010093[cortexa710x4]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060094[css-rdv1]=";;;"
95[css-rde1edge]=";;;"
96[css-rdn1edge]=";;;"
97[css-rdn1edgex2]=";;;"
98[css-sgi575]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -060099[tc0]=";;;"
Usama Arifcba711d2021-08-04 15:53:42 +0100100[tc1]=";;;"
Rupinderjit Singh385f17d2022-07-18 20:28:10 +0100101[tc2]=";;;"
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600102)
103
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500104
Fathi Boudra422bf772019-12-02 11:10:16 +0200105# FVP Kernel URLs
106declare -A fvp_kernels
107fvp_kernels=(
108[fvp-aarch32-zimage]="$linaro_release/fvp32-latest-busybox-uboot/Image"
109[fvp-busybox-uboot]="$linaro_release/fvp-latest-busybox-uboot/Image"
110[fvp-oe-uboot32]="$linaro_release/fvp32-latest-oe-uboot/Image"
111[fvp-oe-uboot]="$linaro_release/fvp-latest-oe-uboot/Image"
112[fvp-quad-busybox-uboot]="$tfa_downloads/quad_cluster/Image"
113)
114
Fathi Boudra422bf772019-12-02 11:10:16 +0200115# FVP initrd URLs
116declare -A fvp_initrd_urls
117fvp_initrd_urls=(
118[aarch32-ramdisk]="$linaro_release/fvp32-latest-busybox-uboot/ramdisk.img"
Fathi Boudra422bf772019-12-02 11:10:16 +0200119[dummy-ramdisk]="$linaro_release/fvp-latest-oe-uboot/ramdisk.img"
120[dummy-ramdisk32]="$linaro_release/fvp32-latest-oe-uboot/ramdisk.img"
121[default]="$linaro_release/fvp-latest-busybox-uboot/ramdisk.img"
122)
123
Fathi Boudra422bf772019-12-02 11:10:16 +0200124get_optee_bin() {
Sandrine Bailleux25ff2942021-02-25 14:00:10 +0100125 url="$tfa_downloads/optee/tee.bin" \
126 saveas="bl32.bin" fetch_file
Fathi Boudra422bf772019-12-02 11:10:16 +0200127 archive_file "bl32.bin"
128}
129
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100130# For Measured Boot tests using a TA based on OPTEE, it is necessary to use a
131# specific build rather than the default one generated by Jenkins.
132get_ftpm_optee_bin() {
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100133 url="$tfa_downloads/ftpm/optee/tee-header_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100134 saveas="bl32.bin" fetch_file
135 archive_file "bl32.bin"
136
Javier Almansa Sobrinode647722020-10-08 19:17:44 +0100137 url="$tfa_downloads/ftpm/optee/tee-pager_v2.bin" \
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100138 saveas="bl32_extra1.bin" fetch_file
139 archive_file "bl32_extra1.bin"
140
Leonardo Sandovalda5f78d2021-03-18 11:09:30 -0600141 # tee-pageable_v2.bin is just a empty file, named as bl32_extra2.bin,
142 # so just create the file
143 touch "bl32_extra2.bin"
Javier Almansa Sobrino98de5032020-09-17 12:47:05 +0100144 archive_file "bl32_extra2.bin"
145}
146
Fathi Boudra422bf772019-12-02 11:10:16 +0200147get_uboot32_bin() {
148 local tmpdir="$(mktempdir)"
149
150 pushd "$tmpdir"
151 extract_fip "$uboot32_fip_url"
152 mv "nt-fw.bin" "uboot.bin"
153 archive_file "uboot.bin"
154 popd
155}
156
157get_uboot_bin() {
158 local uboot_url="$linaro_release/fvp-latest-busybox-uboot/bl33-uboot.bin"
159
160 url="$uboot_url" saveas="uboot.bin" fetch_file
161 archive_file "uboot.bin"
162}
163
164get_uefi_bin() {
Zelalem219df412020-05-17 19:21:20 -0500165 uefi_downloads="${uefi_downloads:-http://files.oss.arm.com/downloads/uefi}"
166 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 +0200167
168 url=$uefi_ci_bin_url saveas="uefi.bin" fetch_file
169 archive_file "uefi.bin"
170}
171
172get_kernel() {
173 local kernel_type="${kernel_type:?}"
174 local url="${fvp_kernels[$kernel_type]}"
175
176 url="${url:?}" saveas="kernel.bin" fetch_file
177 archive_file "kernel.bin"
178}
179
180get_initrd() {
181 local initrd_type="${initrd_type:?}"
182 local url="${fvp_initrd_urls[$initrd_type]}"
183
184 url="${url:?}" saveas="initrd.bin" fetch_file
185 archive_file "initrd.bin"
186}
187
188get_dtb() {
189 local dtb_type="${dtb_type:?}"
190 local dtb_url
191 local dtb_saveas="$workspace/dtb.bin"
Zelalem219df412020-05-17 19:21:20 -0500192 local cc="$(get_tf_opt CROSS_COMPILE)"
193 local pp_flags="-P -nostdinc -undef -x assembler-with-cpp"
Fathi Boudra422bf772019-12-02 11:10:16 +0200194
195 case "$dtb_type" in
196 "fvp-base-quad-cluster-gicv3-psci")
197 # Get the quad-cluster FDT from pdsw area
198 dtb_url="$tfa_downloads/quad_cluster/fvp-base-quad-cluster-gicv3-psci.dtb"
199 url="$dtb_url" saveas="$dtb_saveas" fetch_file
200 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200201 *)
Zelalem219df412020-05-17 19:21:20 -0500202 # Preprocess DTS file
203 ${cc}gcc -E ${pp_flags} -I"$tf_root/fdts" -I"$tf_root/include" \
204 -o "$workspace/${dtb_type}.pre.dts" \
205 "$tf_root/fdts/${dtb_type}.dts"
206 # Generate DTB file from DTS
Fathi Boudra422bf772019-12-02 11:10:16 +0200207 dtc -I dts -O dtb \
Zelalem219df412020-05-17 19:21:20 -0500208 "$workspace/${dtb_type}.pre.dts" -o "$dtb_saveas"
Fathi Boudra422bf772019-12-02 11:10:16 +0200209 esac
210
211 archive_file "$dtb_saveas"
212}
213
214get_rootfs() {
215 local tmpdir
216 local fs_base="$(echo $(basename $rootfs_url) | sed 's/\.gz$//')"
217 local cached="$project_filer/ci-files/$fs_base"
218
219 if upon "$jenkins_run" && [ -f "$cached" ]; then
220 # Job workspace is limited in size, and the root file system is
221 # quite large. This means, parallel runs of root file system
222 # tests could fail. So, for Jenkins runs, copy and use the root
223 # file system image from the $CI_SCRATCH location
224 local private="$CI_SCRATCH/$JOB_NAME-$BUILD_NUMBER"
225 mkdir -p "$private"
226 rm -f "$private/rootfs.bin"
227 url="$cached" saveas="$private/rootfs.bin" fetch_file
228 ln -s "$private/rootfs.bin" "$archive/rootfs.bin"
229 return
230 fi
231
232 tmpdir="$(mktempdir)"
233 pushd "$tmpdir"
234 url="$rootfs_url" saveas="rootfs.bin" fetch_file
235
236 # Possibly, the filesystem image we just downloaded is compressed.
237 # Decompress it if required.
238 if file "rootfs.bin" | grep -iq 'gzip compressed data'; then
239 echo "Decompressing root file system image rootfs.bin ..."
240 gunzip --stdout "rootfs.bin" > uncompressed_fs.bin
241 mv uncompressed_fs.bin "rootfs.bin"
242 fi
243
244 archive_file "rootfs.bin"
245 popd
246}
247
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200248fvp_romlib_jmptbl_backup="$(mktempdir)/jmptbl.i"
249
Fathi Boudra422bf772019-12-02 11:10:16 +0200250fvp_romlib_runtime() {
251 local tmpdir="$(mktempdir)"
252
253 # Save BL1 and romlib binaries from original build
254 mv "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin" "$tmpdir/romlib.bin"
255 mv "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin" "$tmpdir/bl1.bin"
256
257 # Patch index file
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200258 cp "${tf_root:?}/plat/arm/board/fvp/jmptbl.i" "$fvp_romlib_jmptbl_backup"
259 sed -i '/fdt/ s/.$/&\ patch/' ${tf_root:?}/plat/arm/board/fvp/jmptbl.i
Fathi Boudra422bf772019-12-02 11:10:16 +0200260
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200261 # Rebuild with patched file
262 echo "Building patched romlib:"
263 build_tf
Fathi Boudra422bf772019-12-02 11:10:16 +0200264
Fathi Boudra422bf772019-12-02 11:10:16 +0200265 # Retrieve original BL1 and romlib binaries
266 mv "$tmpdir/romlib.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/romlib/romlib.bin"
267 mv "$tmpdir/bl1.bin" "${tf_build_root:?}/${plat:?}/${mode:?}/bl1.bin"
268}
269
Sandrine Bailleux14a692d2022-06-29 15:39:42 +0200270fvp_romlib_cleanup() {
271 # Restore original index
272 mv "$fvp_romlib_jmptbl_backup" "${tf_root:?}/plat/arm/board/fvp/jmptbl.i"
273}
274
275
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500276fvp_gen_bin_url() {
277 local bin_mode="${bin_mode:?}"
278 local bin="${1:?}"
279
280 if upon "$jenkins_run"; then
281 echo "$jenkins_url/job/$JOB_NAME/$BUILD_NUMBER/artifact/artefacts/$bin_mode/$bin"
282 else
283 echo "file://$workspace/artefacts/$bin_mode/$bin"
284 fi
285}
286
287gen_fvp_yaml_template() {
288 local yaml_template_file="$workspace/fvp_template.yaml"
289
290 # must parameters for yaml generation
291 local payload_type="${payload_type:?}"
292
293 "$ci_root/script/gen_fvp_${payload_type}_yaml.sh" > "$yaml_template_file"
294
295 archive_file "$yaml_template_file"
296}
297
298gen_fvp_yaml() {
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600299 local model="${model:?}"
300
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500301 local yaml_template_file="$workspace/fvp_template.yaml"
302 local yaml_file="$workspace/fvp.yaml"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500303 local yaml_job_file="$workspace/job.yaml"
304 local lava_model_params="$workspace/lava_model_params"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500305
Leonardo Sandovalfda4f292020-10-06 15:59:26 -0500306 # this function expects a template, quit if it is not present
307 if [ ! -f "$yaml_template_file" ]; then
308 return
309 fi
310
Leonardo Sandoval00ced1f2020-12-07 12:55:08 -0600311 local model_params="${fvp_models[$model]}"
312 local model_name="$(echo "${model_params}" | awk -F ';' '{print $1}')"
313 local model_dir="$(echo "${model_params}" | awk -F ';' '{print $2}')"
314 local model_bin="$(echo "${model_params}" | awk -F ';' '{print $3}')"
315
316 # model params are required for correct yaml creation, quit if empty
317 if [ -z "${model_name}" ]; then
318 echo "FVP model param 'model_name' variable empty, yaml not produced"
319 return
320 elif [ -z "${model_dir}" ]; then
321 echo "FVP model param 'model_dir' variable empty, yaml not produced"
322 return
323 elif [ -z "${model_bin}" ]; then
324 echo "FVP model param 'model_bin' variable empty, yaml not produced"
325 return
326 fi
327
328 echo "FVP model params: model_name=$model_name model_dir=$model_dir model_bin=$model_bin"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500329
330 # optional parameters, defaults to globals
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500331 local model_dtb="${model_dtb:-$default_model_dtb}"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500332
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600333 # possible artefacts
334 backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500335 bl1="$(fvp_gen_bin_url bl1.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600336 bl2="$(fvp_gen_bin_url bl2.bin)"
337 bl31="$(fvp_gen_bin_url bl31.bin)"
338 bl32="$(fvp_gen_bin_url bl32.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600339 busybox="$(fvp_gen_bin_url busybox.bin.gz)"
340 cactus_primary="$(fvp_gen_bin_url cactus-primary.pkg)"
341 cactus_secondary="$(fvp_gen_bin_url cactus-secondary.pkg)"
342 cactus_tertiary="$(fvp_gen_bin_url cactus-tertiary.pkg)"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500343 coverage_trace_plugin="${coverage_trace_plugin}"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500344 dtb="$(fvp_gen_bin_url ${model_dtb})"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600345 el3_payload="$(fvp_gen_bin_url el3_payload.bin)"
346 fip="$(fvp_gen_bin_url fip.bin)"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500347 fip_gpt="$(fvp_gen_bin_url fip_gpt.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600348 fvp_spmc_manifest_dtb="$(fvp_gen_bin_url fvp_spmc_manifest.dtb)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600349 fwu_fip="$(fvp_gen_bin_url fwu_fip.bin)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600350 generic_trace="${tfa_downloads}/FastModelsPortfolio_${model_version}/plugins/${model_flavour}/GenericTrace.so"
351 hafnium="$(fvp_gen_bin_url hafnium.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500352 image="$(fvp_gen_bin_url kernel.bin)"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600353 ivy="$(fvp_gen_bin_url ivy.pkg)"
354 manifest_dtb="$(fvp_gen_bin_url manifest.dtb)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600355 mcp_rom="$(fvp_gen_bin_url mcp_rom.bin)"
356 mcp_rom_hyphen="$(fvp_gen_bin_url mcp-rom.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500357 ns_bl1u="$(fvp_gen_bin_url ns_bl1u.bin)"
358 ns_bl2u="$(fvp_gen_bin_url ns_bl2u.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600359 ramdisk="$(fvp_gen_bin_url initrd.bin)"
360 romlib="$(fvp_gen_bin_url romlib.bin)"
361 rootfs="$(fvp_gen_bin_url rootfs.bin.gz)"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600362 secure_hafnium="$(fvp_gen_bin_url secure_hafnium.bin)"
363 scp_ram="$(fvp_gen_bin_url scp_ram.bin)"
364 scp_ram_hyphen="$(fvp_gen_bin_url scp-ram.bin)"
365 scp_rom="$(fvp_gen_bin_url scp_rom.bin)"
366 scp_rom_hyphen="$(fvp_gen_bin_url scp-rom.bin)"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600367 spm="$(fvp_gen_bin_url spm.bin)"
368 tftf="$(fvp_gen_bin_url tftf.bin)"
369 tmp="$(fvp_gen_bin_url tmp.bin)"
370 uboot="$(fvp_gen_bin_url uboot.bin)"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500371
372 docker_registry="${docker_registry:-}"
373 docker_registry="$(docker_registry_append)"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500374 docker_name="${docker_registry}$model_name"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600375 prompt1='/ #'
376 prompt2='root@genericarmv8:~#'
377 version_string="\"Fast Models"' [^\\n]+'"\""
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500378
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500379 test_config="${TEST_CONFIG}"
380
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600381 # arrays that relates variables and template macros
382 # NOTE: any addition on these arrays, requires an addition in the
383 # fvp templates
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500384 declare -A metadata_macros
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600385 declare -A yaml_macros
386 declare -A artefacts_macros
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500387 metadata_macros=(
388 [test_config]="{TEST_CONFIG}"
389 )
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600390 yaml_macros=(
391 [armlmd_license_file]="{ARMLMD_LICENSE_FILE}"
392 [docker_name]="{BOOT_DOCKER_NAME}"
393 [model]="{MODEL}"
394 [model_bin]="{BOOT_IMAGE_BIN}"
395 [model_dir]="{BOOT_IMAGE_DIR}"
396 [prompt1]="{PROMPT1}"
397 [prompt2]="{PROMPT2}"
398 [version_string]="{BOOT_VERSION_STRING}"
399 )
400 artefacts_macros=(
401 [backup_fip]="{BACKUP_FIP}"
402 [bl1]="{BL1}"
403 [bl2]="{BL2}"
404 [bl31]="{BL31}"
405 [bl32]="{BL32}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600406 [cactus_primary]="{CACTUS_PRIMARY}"
407 [cactus_secondary]="{CACTUS_SECONDARY}"
408 [cactus_tertiary]="{CACTUS_TERTIARY}"
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500409 [coverage_trace_plugin]="{COVERAGE_TRACE_PLUGIN}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600410 [fvp_spmc_manifest_dtb]="{FVP_SPMC_MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600411 [busybox]="{BUSYBOX}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600412 [dtb]="{DTB}"
413 [el3_payload]="{EL3_PAYLOAD}"
Leonardo Sandovalcc52beb2021-05-05 19:05:31 -0500414 [fip_gpt]="{FIP_GPT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600415 [fwu_fip]="{FWU_FIP}"
416 [fip]="{FIP}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600417 [generic_trace]="{GENERIC_TRACE}"
418 [hafnium]="{HAFNIUM}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600419 [image]="{IMAGE}"
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600420 [ivy]="{IVY}"
421 [manifest_dtb]="{MANIFEST_DTB}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600422 [mcp_rom]="{MCP_ROM}"
423 [mcp_rom_hyphen]="{MCP_ROM_HYPHEN}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600424 [ns_bl1u]="{NS_BL1U}"
425 [ns_bl2u]="{NS_BL2U}"
426 [ramdisk]="{RAMDISK}"
427 [romlib]="{ROMLIB}"
428 [rootfs]="{ROOTFS}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600429 [secure_hafnium]="{SECURE_HAFNIUM}"
430 [scp_ram]="{SCP_RAM}"
431 [scp_ram_hyphen]="{SCP_RAM_HYPHEN}"
432 [scp_rom]="{SCP_ROM}"
433 [scp_rom_hyphen]="{SCP_ROM_HYPHEN}"
434 [spm]="{SPM}"
435 [tftf]="{TFTF}"
436 [tmp]="{TMP}"
437 [uboot]="{UBOOT}"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600438 )
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500439
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600440 # templates cover all possible artefacts, but model parameters may
441 # not required all, i.e. romlib.bin, so delete those irrelevant from
442 # the template
443 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600444 # there are artefacts where deletion is handled in special case, so treat them accordingly
445 case "$m" in
446 busybox)
447 # besides the macro removal, remove the compression field
448 if ! grep -q "${m}.bin" "$archive/model_params"; then
449 sed -i "/$m:\$/d" "${yaml_template_file}"
450 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
451 fi
452 ;;
453 cactus_primary)
454 # cactus packages have a hyphen, not an underscore
455 if ! grep -E -q "cactus-primary.pkg" "$archive/model_params"; then
456 sed -i "/$m:\$/d" "${yaml_template_file}"
457 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
458 fi
459 ;;
460 cactus_secondary)
461 # cactus packages have a hyphen, not an underscore
462 if ! grep -E -q "cactus-secondary.pkg" "$archive/model_params"; then
463 sed -i "/$m:\$/d" "${yaml_template_file}"
464 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
465 fi
466 ;;
467 cactus_tertiary)
468 # cactus packages have a hyphen, not an underscore
469 if ! grep -E -q "cactus-tertiary.pkg" "$archive/model_params"; then
470 sed -i "/$m:\$/d" "${yaml_template_file}"
471 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
472 fi
473 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500474 coverage_trace_plugin)
475 if ! grep -q "coverage_trace.so" "$archive/model_params"; then
476 sed -i "/$m:\$/d" "${yaml_template_file}"
477 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
478 fi
479 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600480 fvp_spmc_manifest_dtb)
481 # handles fvp_spmc_manifest.dtb as DTB file
482 if ! grep -q "=fvp_spmc_manifest.dtb" "$archive/model_params"; then
483 sed -i "/ $m:\$/d" "${yaml_template_file}"
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600484 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
485 fi
486 ;;
487 generic_trace)
488 # the image (Linux Kernel) is named as kernel.bin
489 if ! grep -q "GenericTrace.so" "$archive/model_params"; then
490 sed -i "/$m:\$/d" "${yaml_template_file}"
491 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
492 fi
493 ;;
494 image)
495 # the image (Linux Kernel) is named as kernel.bin
496 if ! grep -q "kernel.bin" "$archive/model_params"; then
497 sed -i "/$m:\$/d" "${yaml_template_file}"
498 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
499 fi
500 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600501 ivy)
502 # the ivy package
503 if ! grep -q "ivy.pkg" "$archive/model_params"; then
504 sed -i "/$m:\$/d" "${yaml_template_file}"
505 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
506 fi
507 ;;
508 manifest_dtb)
509 # handles manifest.dtb as DTB file
510 if ! grep -q "=manifest.dtb" "$archive/model_params"; then
511 sed -i "/ $m:\$/d" "${yaml_template_file}"
512 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
513 fi
514 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600515 mcp_rom_hyphen)
516 # mcp rom is either present as mcp-rom or mcp_rom, handle the former case
517 if ! grep -q "mcp-rom.bin" "$archive/model_params"; then
518 sed -i "/$m:\$/d" "${yaml_template_file}"
519 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
520 fi
521 ;;
522 ramdisk)
523 # ramdisk is named initrd and is present with to extensions: bin or img
524 if ! grep -E -q "initrd.bin|initrd.img" "$archive/model_params"; then
525 sed -i "/$m:\$/d" "${yaml_template_file}"
526 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
527 fi
528 ;;
529 rootfs)
530 # besides the macro removal, remove the compression field
531 if ! grep -q "rootfs.bin" "$archive/model_params"; then
532 sed -i "/$m:\$/d" "${yaml_template_file}"
533 sed -i "/url: ${artefacts_macros[$m]}\$/,/compression: gz\$/d" "${yaml_template_file}"
534 fi
535 ;;
536 scp_ram_hyphen)
537 # scp ram is either present as scp-ram or scp_ram, handle the former case
538 if ! grep -q "scp-ram.bin" "$archive/model_params"; then
539 sed -i "/$m:\$/d" "${yaml_template_file}"
540 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
541 fi
542 ;;
543 scp_rom_hyphen)
544 # scp rom is either present as scp-rom or scp_rom, handle the former case
545 if ! grep -q "scp-rom.bin" "$archive/model_params"; then
546 sed -i "/$m:\$/d" "${yaml_template_file}"
547 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
548 fi
549 ;;
550 *)
551 if ! grep -q "${m}.bin" "$archive/model_params"; then
552 sed -i "/$m:\$/d" "${yaml_template_file}"
553 sed -i "/url: ${artefacts_macros[$m]}\$/d" "${yaml_template_file}"
554 fi
555 ;;
556 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600557 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500558
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600559 # copied files are the working files
560 cp "${yaml_template_file}" "${yaml_file}"
561 cp "$archive/model_params" "$lava_model_params"
562
Leonardo Sandoval5d87b702021-05-10 11:53:13 -0500563 # replace metadata macros with real values
564 for m in "${!metadata_macros[@]}"; do
565 sed -i -e "s|${metadata_macros[$m]}|${!m}|" "$yaml_file"
566 done
567
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600568 # replace yaml macros with real values
569 for m in "${!yaml_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600570 sed -i -e "s|${yaml_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600571 done
572
573 # replace artefact macros with real values
574 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600575 sed -i -e "s|${artefacts_macros[$m]}|${!m}|" "$yaml_file"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600576 done
577
578 # LAVA expects parameters as 'macros', i.e. {X} instead of x.bin, so
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600579 # replace them. As in the macro removal above, handle special cases for several
580 # artefacts
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600581 for m in "${!artefacts_macros[@]}"; do
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600582 case "$m" in
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600583 cactus_primary)
584 sed -i -e "s|=cactus-primary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
585 ;;
586 cactus_secondary)
587 sed -i -e "s|=cactus-secondary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
588 ;;
589 cactus_tertiary)
590 sed -i -e "s|=cactus-tertiary.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
591 ;;
Leonardo Sandovald98f8332021-04-13 16:46:38 -0500592 coverage_trace_plugin)
593 sed -i -e "s|--plugin .*coverage_trace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
594 sed -i -e "s|--plugin=.*coverage_trace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
595 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600596 fvp_spmc_manifest_dtb)
597 sed -i -e "s|=fvp_spmc_manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
598 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600599 generic_trace)
600 sed -i -e "s|--plugin .*GenericTrace.so|--plugin ${artefacts_macros[$m]}|" "$lava_model_params"
601 sed -i -e "s|--plugin=.*GenericTrace.so|--plugin=${artefacts_macros[$m]}|" "$lava_model_params"
602 ;;
603 image)
604 sed -i -e "s|=kernel.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
605 ;;
Leonardo Sandovalb1fb6342021-11-18 15:34:25 -0600606 ivy)
607 sed -i -e "s|=ivy.pkg|=${artefacts_macros[$m]}|" "$lava_model_params"
608 ;;
609 manifest_dtb)
610 sed -i -e "s|=manifest.dtb|=${artefacts_macros[$m]}|" "$lava_model_params"
611 ;;
Leonardo Sandovaldf9c92f2021-03-12 11:31:09 -0600612 mcp_rom_hyphen)
613 sed -i -e "s|=mcp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
614 ;;
615 ramdisk)
616 sed -i -e "s|=initrd.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
617 sed -i -e "s|=initrd.img|=${artefacts_macros[$m]}|" "$lava_model_params"
618 ;;
619 scp_ram_hyphen)
620 sed -i -e "s|=scp-ram.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
621 ;;
622 scp_rom_hyphen)
623 sed -i -e "s|=scp-rom.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
624 ;;
625 tmp | hafnium | secure_hafnium)
626 sed -i -e "s|=.*/${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
627 ;;
628 *)
629 sed -i -e "s|=${m}.bin|=${artefacts_macros[$m]}|" "$lava_model_params"
630 ;;
631 esac
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600632 done
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500633
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500634 # include the model parameters
635 while read -r line; do
636 if [ -n "$line" ]; then
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600637 yaml_line="- \"${line}\""
638 sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500639 fi
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500640 done < "$lava_model_params"
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600641 sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
Leonardo Sandovalbe690bd2020-10-12 17:59:39 -0500642
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500643 # Append expect commands into the job definition through test-interactive commands
644 gen_fvp_yaml_expect >> "$yaml_file"
645
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600646 # create job.yaml
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500647 cp "$yaml_file" "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500648
Leonardo Sandoval850a4862021-02-16 13:56:18 -0600649 # archive both yamls
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500650 archive_file "$yaml_file"
Leonardo Sandoval5d90dff2020-10-12 17:59:39 -0500651 archive_file "$yaml_job_file"
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500652}
653
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500654gen_fvp_yaml_expect() {
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500655
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500656 run_root="$archive/run"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500657
658 # Loop through all uarts expect files
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500659 for expect_file in $(find $run_root -name expect); do
660
661 # TODO: currently, only handle UART 0
662 case $expect_file in
663 *uart0* )
664 uart_number=uart0
665 ;;
666 *)
667 continue
668 ;;
669 esac
670
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500671 # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
672 # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
673 # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
674 # monitor expect scripts are converted into LAVA Monitor Test Actions (see
675 # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
676 #
677 # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
678 # where multiple successes or failures or commands are separated by @
679 #
680 # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
681 # where multiple patterns are separated by @
682 #
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500683 expect_string=()
684
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500685 # Get the real name of the expect file
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500686 expect_file=$(cat $expect_file)
687
688 # Source the run_config enviroment variables
689 env=$run_root/$uart_number/env
690 if [ -e $env ]; then
691 source $env
692 fi
693
694 # Get all expect strings
Paul Sokolovskyeece6f72021-12-01 15:04:29 +0300695 expect_file=$ci_root/expect-lava/${expect_file}
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500696 source $expect_file
697
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500698
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500699 if [ ${#expect_string[@]} -gt 0 ]; then
700
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500701 # expect loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500702 for key in "${!expect_string[@]}"; do
703
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500704 # single raw expect string
705 es="${expect_string[${key}]}"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500706
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500707 # action type: either m or i
708 action="$(echo "${es}" | awk -F ';' '{print $1}')"
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500709
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500710 if [ "${action}" = "m" ]; then
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500711
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500712 start="$(echo "${es}" | awk -F ';' '{print $2}')"
713 end="$(echo "${es}" | awk -F ';' '{print $3}')"
714 patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
715
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500716 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500717- test:
718 monitors:
719 - name: tests
720 start: '${start}'
721 end: '${end}'
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500722EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500723 # Patterns are separated by '@'
724 OLD_IFS=$IFS; IFS=$'@'
725 for p in ${patterns}; do
726 cat << EOF
727 pattern: '$p'
728EOF
729 done
730 IFS=$OLD_IFS
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500731 cat << EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500732 fixupdict:
733 PASS: pass
734 FAIL: fail
735EOF
736 fi # end of monitor action
737
738 if [ "${action}" = "i" ]; then
739
740 prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
741 successes="$(echo "${es}" | awk -F ';' '{print $3}')"
742 failures="$(echo "${es}" | awk -F ';' '{print $4}')"
743 commands="$(echo "${es}" | awk -F ';' '{print $5}')"
744
745 cat << EOF
746- test:
747 interactive:
748EOF
749 OLD_IFS=$IFS; IFS=$'@'
750
751 if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
752 cat << EOF
753 - name: interactive_${uart_number}_${key}
754 prompts: ['${prompts}']
755 script:
756EOF
757 if [ -z "${commands}" ]; then
758 cat <<EOF
759 - name: interactive_command_${uart_number}_${key}
760 command:
761EOF
762 else
763 for c in ${commands}; do
764 cat <<EOF
765 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300766 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500767EOF
768 done
769 fi
770 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500771 successes:
772EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500773 for s in ${successes}; do
774 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500775 - message: '$s'
776EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500777 done
778 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500779 failures:
780EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500781 for f in ${failures}; do
782 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500783 - message: '$f'
784EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500785 done
786 elif [[ -n "${prompts}" && -n "${successes}" ]]; then
787 cat << EOF
788 - name: interactive_${uart_number}_${key}
789 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500790 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500791EOF
792
793 if [ -z "${commands}" ]; then
794 cat <<EOF
795 - name: interactive_command_${uart_number}_${key}
796 command:
797EOF
798 else
799 for c in ${commands}; do
800 cat <<EOF
801 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300802 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500803EOF
804 done
805 fi
806 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500807 successes:
808EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500809 for s in ${successes}; do
810 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500811 - message: '$s'
812EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500813 done
814
815 elif [[ -n "${prompts}" && -n "${failures}" ]]; then
816 cat << EOF
817 - name: interactive_${uart_number}_${key}
818 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500819 script:
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500820EOF
821 if [ -z "${commands}" ]; then
822 cat <<EOF
823 - name: interactive_command_${uart_number}_${key}
824 command:
825EOF
826 else
827 for c in ${commands}; do
828 cat <<EOF
829 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300830 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500831EOF
832 done
833 fi
834 cat << EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500835 failures:
836EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500837 for f in ${failures}; do
838 cat <<EOF
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500839 - message: '$f'
840EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500841 done
842 else
843 cat << EOF
844 - name: interactive_${uart_number}_${key}
845 prompts: ['${prompts}']
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500846 script:
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500847EOF
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500848 if [ -z "${commands}" ]; then
849 cat <<EOF
850 - name: interactive_command_${uart_number}_${key}
851 command:
852EOF
853 else
854 for c in ${commands}; do
855 cat <<EOF
856 - name: interactive_command_${uart_number}_${key}
Paul Sokolovskydf445242021-12-15 16:57:51 +0300857 command: "$c"
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500858EOF
859 done
860 fi
861 fi
862
863 IFS=$OLD_IFS
864 fi # end of interactive action
865
866 done # end of expect loop
867
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500868 fi
Leonardo Sandoval5cfc11f2021-09-08 16:08:13 -0500869 done # end of uart loop
Leonardo Sandovalcd06bf42021-04-08 11:53:39 -0500870}
871
Leonardo Sandovald76d1e22020-10-06 16:02:52 -0500872docker_registry_append() {
873 # if docker_registry is empty, just use local docker registry
874 [ -z "$docker_registry" ] && return
875
876 local last=-1
877 local last_char="${docker_registry:last}"
878
879 if [ "$last_char" != '/' ]; then
880 docker_registry="${docker_registry}/";
881 fi
882 echo "$docker_registry"
883}
884
Manish V Badarkheea3e0942021-03-05 11:51:48 +0000885# generate GPT image and archive it
886gen_gpt_bin() {
887 raw_image="fip_gpt.bin"
888 img_uuid="FB90808A-BA9A-4D42-B9A2-A7A937144AEE"
889 img_bank_uuid=`uuidgen`
890 disk_uuid=`uuidgen`
891 bin="${1:?}"
892
893 # maximum FIP size 2MB
894 fip_max_size=2097152
895 start_sector=34
896 sector_size=512
897 num_sectors=$(($fip_max_size/$sector_size))
898 bin_size=$(stat -c %s $bin)
899
900 if [[ $fip_max_size -lt $bin_size ]]
901 then
902 echo "FIP binary ($bin_size bytes) larger than max partition 1"
903 "size ($fip_max_size byte)"
904 return
905 fi
906
907 # create raw 5MB image
908 dd if=/dev/zero of=$raw_image bs=5M count=1
909
910 # create GPT image
911 sgdisk -a 1 -U $disk_uuid -n 1:$start_sector:+$num_sectors \
912 -c 1:FIP_A -t 1:$img_uuid $raw_image -u $img_bank_uuid
913
914 echo "write binary $bin at sector $start_sector"
915 dd if=$bin of=$raw_image bs=$sector_size seek=$start_sector \
916 count=$num_sectors conv=notrunc
917
918 archive_file "fip_gpt.bin"
919}
920
Fathi Boudra422bf772019-12-02 11:10:16 +0200921set +u