3
topdir="${CURTIN_VMTEST_TOPDIR:-${WORKSPACE:-$PWD}/output}"
4
pkeep=${CURTIN_VMTEST_KEEP_DATA_PASS:-logs,collect}
5
fkeep=${CURTIN_VMTEST_KEEP_DATA_FAIL:-logs,collect}
6
reuse=${CURTIN_VMTEST_REUSE_TOPDIR:-0}
7
export CURTIN_VMTEST_TAR_DISKS=${CURTIN_VMTEST_TAR_DISKS:-0}
8
export CURTIN_VMTEST_REUSE_TOPDIR=$reuse
9
export CURTIN_VMTEST_IMAGE_SYNC=${CURTIN_VMTEST_IMAGE_SYNC:-0}
10
export CURTIN_VMTEST_KEEP_DATA_PASS=$pkeep
11
export CURTIN_VMTEST_KEEP_DATA_FAIL=$fkeep
12
export CURTIN_VMTEST_TOPDIR="$topdir"
13
export CURTIN_VMTEST_LOG="${CURTIN_VMTEST_LOG:-$topdir/debug.log}"
14
export CURTIN_VMTEST_PARALLEL=${CURTIN_VMTEST_PARALLEL:-0}
15
export IMAGE_DIR=${IMAGE_DIR:-/srv/images}
17
# empty TGT_* variables in current env to avoid killing a pid we didn't start.
21
error() { echo "$@" 1>&2; }
22
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
26
[ "$ret" -eq 0 ] && keep_rules="$pkeep" || keep_rules="$fkeep"
27
# kill a tgtd pid that was started here.
28
if [ -n "$TGT_PID" ]; then
30
if [ -n "${TGT_IPC_SOCKET}" ]; then
31
# var is <path>/socket but the actual socket is <path>/socket.0
32
rm -f "${TGT_IPC_SOCKET}" "${TGT_IPC_SOCKET}".* ||
33
error "WARN: failed removal of $TGT_IPC_SOCKET"
36
if [ -n "$TGT_LOG_D" ]; then
37
case ",${keep_rules}," in
39
*) rm -Rf "${TGT_LOG_D}";;
44
if [ "$reuse" != "1" ]; then
45
if [ -d "$topdir" ]; then
46
fail "topdir '$topdir' existed."
48
mkdir -p "$topdir" || fail "failed mkdir $topdir"
52
parallel=${CURTIN_VMTEST_PARALLEL}
54
while [ $# -ne 0 ]; do
56
-p|--parallel) parallel="$2"; shift;;
57
--parallel=*) parallel=${1#*=};;
58
-p[0-9]|-p-1|-p[0-9][0-9]) parallel=${1#-p};;
63
*) ntargs[${#ntargs[@]}]="$1";;
68
CURTIN_VMTEST_PARALLEL=$parallel
70
if [ ${#ntargs[@]} -eq 0 ]; then
71
set -- -vv --nologcapture tests/vmtests/
76
ntargs=( "${ntargs[@]}" "$@" )
79
if [ -n "$parallel" -a "$parallel" != "0" -a "$parallel" != "1" ]; then
80
pargs=( --process-timeout=86400 "--processes=$parallel" )
83
if [ -n "$TGT_IPC_SOCKET" ]; then
84
error "existing TGT_IPC_SOCKET=${TGT_IPC_SOCKET}"
85
elif command -v tgtd >/dev/null 2>&1; then
86
tgtdir="$topdir/tgt.d"
87
mkdir -p "$tgtdir" || fail "failed to create $tgtdir"
88
rm -f "$tgtdir/info" || fail "failed to remove $tgtdir/info"
89
./tools/find-tgt "$tgtdir" >"${tgtdir}/find-tgt.log" 2>&1 || {
90
cat "${tgtdir}/find-tgt.log" 1>&2
91
fail "could not start a tgt service"
94
. "$tgtdir/info" >"$tgtdir/source-output.txt" 2>&1
95
[ -n "$TGT_PID" ] || fail "find-tgt did not write TGT_PID"
96
[ -d "/proc/${TGT_PID}" ] || fail "no tgtd process in /proc/${TGT_PID}"
98
error "no tgtd command, iscsi tests will be skipped"
101
# dump CURTIN_* and TGT_* and proxy variables just for info
102
for v in ${!CURTIN_*} ${!TGT_*} http_proxy https_proxy no_proxy; do
106
# avoid LOG info by running python3 tests/vmtests/image_sync.py
107
# rather than python3 -m tests.vmtests.image_sync (LP: #1594465)
108
echo "Working with images in $IMAGE_DIR"
109
fmt=" %(release)-7s %(arch)s/%(subarch)s %(version_name)-10s"
110
PYTHONPATH="$PWD" python3 tests/vmtests/image_sync.py query \
111
--output-format="$fmt" "$IMAGE_DIR" ftype=root-image.gz ||
112
{ ret=$?; echo "FATAL: error querying images in $IMAGE_DIR" 1>&2;
115
echo "$(date -R): vmtest start: nosetests3 ${pargs[*]} ${ntargs[*]}"
116
nosetests3 "${pargs[@]}" "${ntargs[@]}"
119
echo "$(date -R): vmtest end [$ret] in $(($end_s-$start_s))s"
122
# vi: ts=4 expandtab syntax=sh