From 00c953a534f55881ff245a929f1882902523b4c5 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 11 Sep 2018 15:22:51 -0400 Subject: [PATCH] WIP: Add a `kola` verb Blocked by https://github.com/coreos/mantle/issues/918 --- src/cmd-kola | 12 ++++++++++++ src/cmd-run | 9 +++++---- src/cmdlib.sh | 13 +++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 src/cmd-kola diff --git a/src/cmd-kola b/src/cmd-kola new file mode 100644 index 0000000000..5099646a8f --- /dev/null +++ b/src/cmd-kola @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -xeuo pipefail + +dn=$(dirname $0) +. ${dn}/cmdlib.sh + +latest_qcow=$(get_latest_qcow) +if [ -z "${latest_qcow}" ]; then + fatal "No latest build" +fi + +exec sudo kola -b rhcos --tapfile test.tap --qemu-image ${latest_qcow} run rhcos.basic diff --git a/src/cmd-run b/src/cmd-run index b4f3c8d1a6..a1fdc491dc 100755 --- a/src/cmd-run +++ b/src/cmd-run @@ -7,6 +7,9 @@ set -euo pipefail +dn=$(dirname $0) +. ${dn}/cmdlib.sh + VM_DISK= VM_MEMORY=2048 VM_PERSIST=0 @@ -71,10 +74,8 @@ while [ $# -ge 1 ]; do done if [ -z "${VM_DISK}" ]; then - if [ -L ./builds/latest ]; then - latest_build=$(readlink builds/latest) - VM_DISK=$(ls builds/${latest_build}/*-qemu.qcow2) - else + VM_DISK=$(get_latest_qcow) + if [ -z "${VM_DISK}" ]; then die "No builds/latest, and no -d argument provided" fi fi diff --git a/src/cmdlib.sh b/src/cmdlib.sh index 5ba0f4ec97..78f870f2e9 100755 --- a/src/cmdlib.sh +++ b/src/cmdlib.sh @@ -57,3 +57,16 @@ runcompose() { sudo rpm-ostree compose tree --repo=${workdir}/repo-build --cachedir=${workdir}/cache ${treecompose_args} \ ${TREECOMPOSE_FLAGS:-} ${manifest} "$@" } + +get_latest_build() { + if [ -L builds/latest ]; then + readlink builds/latest + fi +} + +get_latest_qcow() { + local latest=$(get_latest_build) + if [ -n "$latest" ]; then + ls builds/${latest}/*-qemu.qcow2 + fi +}