summaryrefslogtreecommitdiff
path: root/ktest
diff options
context:
space:
mode:
authorSlava Pestov <sp@daterainc.com>2014-10-18 19:12:35 -0700
committerSlava Pestov <sp@daterainc.com>2014-10-20 11:25:27 -0700
commit443e5a9eb4e5e2614f633d1b959cde48c8c48925 (patch)
tree43815be798a095d6389795fce10c1ae75fa16acf /ktest
parentfae09fcbcde7870cccd33ec3e708c6202b762de1 (diff)
ktest: add -o flag for output directory
Change-Id: Ic8177219c7795923f04bcd531c20ae91b19f1552
Diffstat (limited to 'ktest')
-rwxr-xr-xktest38
1 files changed, 20 insertions, 18 deletions
diff --git a/ktest b/ktest
index 6364bb7..e9efddb 100755
--- a/ktest
+++ b/ktest
@@ -30,10 +30,7 @@ KERNEL="" # dir that has the kernel to run
# set with: -k <path>
WORK_DIR="" # dir where vm meta data (id, logs, etc) gets stored
# set with: -w <path>
-LOG_INTERNAL="log.internal"
- # dir name which is mapped with virtfs to inside vm
- # at /var/log/datera
- # path: $WORK_DIR/$LOG_INTERNAL
+LOG_INTERNAL="" # dir name which is mounted at /var/log/datera in VM
SCRATCH_DIR="/tmp" # dir where scratch drives are created
# defaults: /tmp
# auto-override: $HOME/.ktest/tmp
@@ -75,7 +72,8 @@ usage()
echo " options:"
echo " -x bash debug statements"
echo " -k <dir> build directory for kernel (default: kernel_source/.ktest)"
- echo " -w <dir> work directory (default: kernel build directory)"
+ echo " -w <dir> work directory (default: kernel_source/ktest.<pid>)"
+ echo " -o <dir> output directory (default: kernel_source/ktest.<pid>/output)"
echo " -i <dir> VM root filesystem image (run cmd only)"
echo " -I disable timeout and VM stop on pass/fail (run cmd only)"
echo " -S disable timeout and VM stop on fail (run cmd only)"
@@ -92,7 +90,7 @@ fi
CMD="cmd_$1"
shift
-while getopts "hp:i:k:ISw:x" arg; do
+while getopts "hp:i:k:ISw:o:x" arg; do
case $arg in
h)
usage
@@ -114,7 +112,10 @@ while getopts "hp:i:k:ISw:x" arg; do
EXIT_ON_SUCCESS=1
;;
w)
- WORK_DIR=$OPTARG
+ WORK_DIR="$OPTARG"
+ ;;
+ o)
+ LOG_INTERNAL="$OPTARG"
;;
x)
set -x
@@ -129,6 +130,7 @@ if [ -z "$KERNEL" ]; then
fi
[ -z "$WORK_DIR" ] && WORK_DIR="./ktest.$$"
+[ -z "$LOG_INTERNAL" ] && LOG_INTERNAL="$WORK_DIR/output"
mkdir -p "$WORK_DIR"
WORK_DIR=$(readlink -e "$WORK_DIR")
@@ -220,8 +222,7 @@ prepare_vm()
genisoimage_sudo=""
# setup directory where logfs will be mounted from
- rm -rf "$WORK_DIR/$LOG_INTERNAL"
- mkdir -p "$WORK_DIR/$LOG_INTERNAL"
+ mkdir -p "$LOG_INTERNAL"
build_file_list "$@"
@@ -240,7 +241,7 @@ run_lcov()
{
which lcov >/dev/null 2>&1 || return 0
- [ -d "$WORK_DIR/$LOG_INTERNAL/gcov.0" ] || return 0
+ [ -d "$LOG_INTERNAL/gcov.0" ] || return 0
local gcov_out=$WORK_DIR/gcov
@@ -251,7 +252,7 @@ run_lcov()
local html=$gcov_out/gcov.html
local tracefiles=""
- for i in $WORK_DIR/$LOG_INTERNAL/gcov.*; do
+ for i in $LOG_INTERNAL/gcov.*; do
local out=$gcov_out/$(basename "$i").info
tracefiles+=" --add-tracefile $out"
@@ -284,7 +285,7 @@ run_vmstart()
-k "$KERNEL/vmlinuz" \
-c "$WORK_DIR/run.iso" \
--id "$WORK_DIR/id" \
- --fs "$WORK_DIR/$LOG_INTERNAL" logfs \
+ --fs "$LOG_INTERNAL" logfs \
--append="root=/dev/sda rw crashkernel=128M" \
"$KGDB" \
"$@"
@@ -304,10 +305,11 @@ cmd_run()
exit 1
fi
+ LOG_INTERNAL="$LOG_INTERNAL/$(basename "$1")"
prepare_vm "$1"
- rm -f "$WORK_DIR/output"
- mkfifo "$WORK_DIR/output"
+ rm -f "$WORK_DIR/fifo"
+ mkfifo "$WORK_DIR/fifo"
# shellcheck disable=SC2086
run_vmstart \
@@ -316,20 +318,20 @@ cmd_run()
--cpus "$_CPUS" \
$_SCRATCH \
$_INFINIBAND \
- $_VMCLUSTER </dev/null 2>&1 > "$WORK_DIR/output" &
+ $_VMCLUSTER </dev/null 2>&1 > "$WORK_DIR/fifo" &
err=0
if [ "$EXIT_ON_SUCCESS" = 1 ]; then
sed -u -e '/TEST SUCCESS/ { p; Q0 }' \
- < "$WORK_DIR/output" || err=1
+ < "$WORK_DIR/fifo" || err=1
elif [ "$INTERACTIVE" = 1 ]; then
- cat "$WORK_DIR/output"
+ cat "$WORK_DIR/fifo"
else
timeout "$_TIMEOUT" \
sed -u -e '/TEST SUCCESS/ { p; Q0 }' \
-e '/TEST FAILED/ { p; Q1 }' \
- < "$WORK_DIR/output" || err=1
+ < "$WORK_DIR/fifo" || err=1
fi
$VMSTART stop "$(cat "$WORK_DIR/id")"