[linux-cip-ci][PATCH 3/3] lava_templates: Add test script for generated yaml file


Nobuhiro Iwamatsu
 

This will add a script that will output the final YAML generated.
This is used to verify YAML.

```
$ ./lava_templates/show_generated_yaml.sh de0-nano-soc arm \
deby-buster-ltp ltp-ipc-tests true
```

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@...>
---
lava_templates/show_generated_yaml.sh | 74 +++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
create mode 100755 lava_templates/show_generated_yaml.sh

diff --git a/lava_templates/show_generated_yaml.sh b/lava_templates/show_generated_yaml.sh
new file mode 100755
index 0000000..e383765
--- /dev/null
+++ b/lava_templates/show_generated_yaml.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+# Copyright (C) 2020, Renesas Electronics Europe GmbH, Chris Paterson <chris.paterson2@...>
+# Copyright (C) 2020, Toshiba Nobuhiro Iwamtasu <nobuhiro1.iwamatsu@...>
+#
+
+set -e
+
+# $1: OS type
+# $2: Test name
+create_job_definition () {
+ local base_os="$1"
+ local testname="$2"
+
+ local dtb_url="$AWS_URL_DOWN/$DTB"
+ local kernel_url="$AWS_URL_DOWN/$KERNEL"
+ local modules_url="$AWS_URL_DOWN/$MODULES"
+
+ local commit_ref=$(echo "${CI_COMMIT_REF_NAME}" | sed 's/\//-/g')
+
+ if $USE_DTB; then
+ local job_name="${commit_ref}_${VERSION}_${BUILD_ARCH}_${CONFIG}_${DTB_NAME}_${testname}"
+ else
+ local job_name="${commit_ref}_${VERSION}_${BUILD_ARCH}_${CONFIG}_${testname}"
+ fi
+
+ local job_definition="$TMP_DIR/${INDEX}_${job_name}.yaml"
+ INDEX=$((INDEX+1))
+
+ cat ${TEMPLATE_DIR}/header_base.yaml > "${job_definition}"
+ if [ "${DEVICE}" = "qemu" ] ; then
+ local device_name="${DEVICE}_${BUILD_ARCH}"
+ cat ${TEMPLATE_DIR}/context_${device_name}.yaml >> "${job_definition}"
+ else
+ local device_name="${DEVICE}"
+ fi
+
+ cat ${TEMPLATE_DIR}/timeouts_"${testname}".yaml \
+ ${TEMPLATE_DIR}/action_"${base_os}"_"${device_name}".yaml \
+ ${TEMPLATE_DIR}/boot_"${base_os}"_"${device_name}".yaml \
+ ${TEMPLATE_DIR}/test_"${testname}".yaml \
+ >> "${job_definition}"
+
+ sed -i "s|DEVICE_NAME|${DEVICE}|g" "$job_definition"
+ sed -i "s|JOB_NAME|$job_name|g" "$job_definition"
+ if $USE_MODULES; then
+ sed -i "/DTB_URL/ a \ modules:\n url: $modules_url\n compression: gz" "$job_definition"
+ fi
+ if $USE_DTB; then
+ sed -i "s|DTB_URL|$dtb_url|g" "$job_definition"
+ fi
+ sed -i "s|KERNEL_URL|$kernel_url|g" "$job_definition"
+
+ echo ${job_definition}
+ cat ${job_definition}
+}
+
+SCRIPT_DIR=$(cd $(dirname $0);pwd)
+
+TEMPLATE_DIR="${SCRIPT_DIR}"
+TMP_DIR="/tmp/"
+AWS_URL_DOWN="exmample.org"
+KERNEL="zImage"
+DTB="foo.dtb"
+MODULES="bar.tar.gz"
+VERSION="4.19.1-1"
+CI_COMMIT_REF_NAME="a/b/c/d"
+CONFIG="testconfig"
+DTB_NAME="test-dtb"
+INDEX="1"
+DEVICE=$1
+BUILD_ARCH=$2
+USE_DTB=$5
+
+create_job_definition $3 $4
--
2.27.0

Join cip-dev@lists.cip-project.org to automatically receive all group messages.