Turns out it wasn't as hard as I'd thought it would be.
Also note that for now I am still restricting the number of jobs running
in parallel to two, because each needs a lot of memory and I don't want to
assume too much about the test host. I am open to ideas about better ways
to do this.
---
tests/kickstart_tests/run_kickstart_tests.sh | 62 ++++++++++++++--------------
1 file changed, 31 insertions(+), 31 deletions(-)
diff --git a/tests/kickstart_tests/run_kickstart_tests.sh
b/tests/kickstart_tests/run_kickstart_tests.sh
index 613ebe6..39c9d34 100755
--- a/tests/kickstart_tests/run_kickstart_tests.sh
+++ b/tests/kickstart_tests/run_kickstart_tests.sh
@@ -38,13 +38,25 @@ if [[ ! -e "${IMAGE}" ]]; then
exit 77
fi
-run() {
- tmpdir=$1
- ks=$2
+runone() {
+ img=$1
+ t=$2
+
+ ks=${t/.sh/.ks}
+ . $t
+
+ echo ${ks}
+ echo ==============================
+
+ # qemu user needs to be able to read the directory.
+ tmpdir=$(mktemp -d --tmpdir=/var/tmp)
+ chmod 755 ${tmpdir}
ksfile=$(prepare ${ks} ${tmpdir})
if [[ $? != 0 ]]; then
echo Test prep failed: ${ksfile}
+ rm -rf ${tmpdir}
+ unset kernel_args prep validate
return 1
fi
@@ -55,7 +67,7 @@ run() {
livemedia-creator ${kargs} \
--make-disk \
- --iso "${IMAGE}" \
+ --iso "${img}" \
--ks ${ksfile} \
--tmp ${tmpdir} \
--logfile ${tmpdir}/livemedia.log \
@@ -67,6 +79,8 @@ run() {
--vnc vnc
if [[ $? != 0 ]]; then
echo $(grep CRIT ${tmpdir}/virt-install.log)
+ rm -rf ${tmpdir}
+ unset kernel_args prep validate
return 1
elif [[ -f ${tmpdir}/livemedia.log ]]; then
img=$(grep disk_img ${tmpdir}/livemedia.log | cut -d= -f2)
@@ -74,48 +88,34 @@ run() {
if [[ ! -f ${trimmed} ]]; then
echo Disk image ${trimmed} does not exist.
+ rm -rf ${tmpdir}
+ unset kernel_args prep validate
return 1
fi
validate ${trimmed}
if [[ $? != 0 ]]; then
echo FAILED
+ rm -rf ${tmpdir}
+ unset kernel_args prep validate
return 1
elif [[ "${result}" != "SUCCESS" ]]; then
echo ${result}
+ rm -rf ${tmpdir}
+ unset kernel_args prep validate
return 1
fi
fi
echo SUCCESS
+ rm -rf ${tmpdir}
+ unset kernel_args prep validate
return 0
}
-status=0
-for t in kickstart_tests/*sh; do
- # Skip this file, and also provide a way to skip tests by only running
- # those that are executable.
- if [[ $t == "kickstart_tests/run_kickstart_tests.sh" || ! -x $t ]]; then
- continue
- fi
-
- ks=${t/.sh/.ks}
- . $t
-
- echo ${ks}
- echo ==============================
-
- # qemu user needs to be able to read the directory.
- tmpdir=$(mktemp -d --tmpdir=/var/tmp)
- chmod 755 ${tmpdir}
-
- run ${tmpdir} ${ks}
- if [[ $? = 1 ]]; then
- status=1
- fi
-
- rm -rf ${tmpdir}
- unset kernel_args prep validate
-done
+export -f runone
-exit ${status}
+# Round up all the kickstart tests we want to run, skipping those that are not
+# executable as well as this file itself.
+find kickstart_tests -name '*sh' -a -perm -o+x -a \! -wholename
'kickstart_tests/run_kickstart_tests.sh' | \
+parallel --jobs 2 runone ${IMAGE} {}
--
1.9.3