#!/usr/bin/env bash set -o nounset set -o errexit set -o errtrace # check for typical shell script errors export PS4='+${LINENO}+ ' ktest_dir=$(dirname "$(readlink -f "$0")") ktest_kernel_binary="" # dir that has the kernel to run # set with: -k . "$ktest_dir/lib/util.sh" . "$ktest_dir/lib/libktest.sh" usage() { echo "ktest: Run generic virtual machine tests" echo "Usage: ktest cmd [options]" ktest_usage_cmds echo echo " options:" ktest_usage_opts echo echo " options for ktest run:" ktest_usage_run_opts echo ktest_usage_post } if [[ $# = 0 ]]; then usage exit 1 fi cmd_run() { if [[ $# = 0 ]]; then echo "ktest: missing test" exit 1 fi ktest_test=$1 shift ktest_testargs="$@" echo Running test $(basename "$ktest_test") parse_test_deps "$ktest_test" start_vm } #parse command and shift for rest of arg parsing CMD="$1" shift # check if command is valid if [[ $(type -t "cmd_$CMD") == function ]]; then CMD="cmd_$CMD" elif [[ $(type -t "ktest_$CMD") == function ]]; then CMD="ktest_$CMD" else usage exit 1 fi while getopts "h${ktest_args}" arg; do case $arg in h) usage exit 0 ;; esac parse_ktest_arg $arg done shift $((OPTIND - 1)) parse_args_post $CMD "$@"