iopsys-feed/iop/scripts/taas.sh
2020-11-08 01:12:27 +01:00

81 lines
2 KiB
Bash

# Shorthand command for doing a HIL runtime smoketest on the
# latest built image. Does the image boot up correctly?
# More info here:
# https://dev.iopsys.eu/iopsys/iopsys-taas
#--------------------------------------------------------------
function taas-init() {
# Path to TaaS binarys. Try some likely ones.
if ! which taas-smoketest >/dev/null; then
PATH="${PATH}:${PWD}/../iopsys-taas/bin"
PATH="${PATH}:${PWD}/../taas/bin"
PATH="${PATH}:${HOME}/iopsys-taas/bin"
PATH="${PATH}:${HOME}/taas/bin"
PATH="${PATH}:${HOME}/bin"
PATH="${PATH}:/opt/iopsys-taas/bin"
PATH="${PATH}:/opt/taas/bin"
fi
if ! which taas-smoketest >/dev/null; then
echo "Error; missing command \"taas-smoketest\". Install it with:"
echo "git clone git@dev.iopsys.eu:iopsys/iopsys-taas.git ../iopsys-taas"
exit 1
fi
# Prerequisites?
for app in expect socat timeout stdbuf bash env head strings \
tee cut tr grep curl ssh trickle; do
if ! which $app >/dev/null; then
echo "Error; missing command \"$app\""
echo "Install it from your Linux distro!"
exit 1
fi
done
}
#--------------------------------------------------------------
function taas-smoketest {
local image app
taas-init || return
# Find the default latest image (.y3 or FIT).
for image in bin/targets/iopsys-*/generic/last.y3 \
bin/targets/iopsys-*/generic/last.pkgtb; do
[ -s "$image" ] || continue
# Convert Iopsys target name to the TaaS product name format.
product=$(grep CONFIG_TARGET_PROFILE .config | \
tr -s "=\"" " " | cut -d " " -f 2)
case "$product" in
smarthub3)
product="SmartHub3a"
;;
dg400prime|eg400)
product=$(echo -n "$product" | tr [[:lower:]] [[:upper:]])
;;
*)
product=""
;;
esac
if [ -n "$product" ]; then
command taas-smoketest "$image" "$product" || exit
echo "Smoketest OK"
else
echo "Unsupported target; skipping smoketest."
fi
exit 0
done
echo "No image found"
exit 1
}
register_command "taas-smoketest" "Write image to a device in the lab and check if it boots up."