refactor: use Bash expressions to generate boot arguments
This change removes the final remaining macro used by the LAVA job
template files, which is `BOOT_ARGUMENTS`. In its place, use a simple
Bash expression which loops over the boot arguments and generates the
boot argument array entries.
Signed-off-by: Chris Kay <chris.kay@arm.com>
Change-Id: I688c819179ed0a4dea48d23a222acb1c3ef55625
diff --git a/fvp_utils.sh b/fvp_utils.sh
index 6c7f2e9..f381990 100644
--- a/fvp_utils.sh
+++ b/fvp_utils.sh
@@ -485,9 +485,8 @@
fi
done
- # copied files are the working files
- expand_template "${yaml_template_file}" > "${yaml_file}"
- cp "$archive/model_params" "$lava_model_params"
+ # Derive LAVA model parameters from the non-LAVA ones
+ cp "${archive}/model_params" "${lava_model_params}"
# Ensure braces in the FVP model parameters are not accidentally interpreted
# as LAVA macros.
@@ -501,14 +500,12 @@
"${lava_model_params}"
done
- # include the model parameters
- while read -r line; do
- if [ -n "$line" ]; then
- yaml_line="- $(echo "${line}" | jq -R .)"
- sed -i -e "/{BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
- fi
- done < "$lava_model_params"
- sed -i -e '/{BOOT_ARGUMENTS}/d' "$yaml_file"
+ # Read boot arguments into an array so that the job template file can
+ # iterate over them.
+ readarray -t boot_arguments < "${lava_model_params}"
+
+ # Generate the LAVA job definition, minus the test expectations
+ expand_template "${yaml_template_file}" > "${yaml_file}"
# Append expect commands into the job definition through test-interactive commands
gen_fvp_yaml_expect >> "$yaml_file"
diff --git a/script/lava-templates/fvp-linux.yaml b/script/lava-templates/fvp-linux.yaml
index e871aff..96f69fe 100644
--- a/script/lava-templates/fvp-linux.yaml
+++ b/script/lava-templates/fvp-linux.yaml
@@ -70,4 +70,9 @@
timeout:
minutes: 30
arguments:
-{BOOT_ARGUMENTS}
+
+$(for boot_argument in "${boot_arguments[@]:?}"; do
+ cat <<-YAML
+ - $(echo "${boot_argument}" | jq -R .)
+ YAML
+done)
diff --git a/script/lava-templates/fvp-tftf.yaml b/script/lava-templates/fvp-tftf.yaml
index c9b435c..c4e00b8 100644
--- a/script/lava-templates/fvp-tftf.yaml
+++ b/script/lava-templates/fvp-tftf.yaml
@@ -81,4 +81,9 @@
- '(?P<NAME>terminal_2): Listening for serial connection on port (?P<PORT>\d+)'
- '(?P<NAME>terminal_3): Listening for serial connection on port (?P<PORT>\d+)'
arguments:
-{BOOT_ARGUMENTS}
+
+$(for boot_argument in "${boot_arguments[@]:?}"; do
+ cat <<-YAML
+ - $(echo "${boot_argument}" | jq -R .)
+ YAML
+done)