test-client: pass extra argument in "test-client.sh" to python test
For example:
$ src/tests/client/test-client.sh -- TestNmcli.test_004
$ src/tests/client/test-client.sh -- -k monitor
(cherry picked from commit b76bb7333e
)
This commit is contained in:
@@ -5456,7 +5456,7 @@ endif
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
check-local-tests-client: src/nmcli/nmcli src/tests/client/test-client.py
|
check-local-tests-client: src/nmcli/nmcli src/tests/client/test-client.py
|
||||||
"$(srcdir)/src/tests/client/test-client.sh" "$(builddir)" "$(srcdir)" "$(PYTHON)"
|
"$(srcdir)/src/tests/client/test-client.sh" "$(builddir)" "$(srcdir)" "$(PYTHON)" --
|
||||||
|
|
||||||
check_local += check-local-tests-client
|
check_local += check-local-tests-client
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ test(
|
|||||||
build_root,
|
build_root,
|
||||||
source_root,
|
source_root,
|
||||||
python.path(),
|
python.path(),
|
||||||
|
'--',
|
||||||
],
|
],
|
||||||
timeout: 120,
|
timeout: 120,
|
||||||
)
|
)
|
||||||
|
@@ -1,5 +1,30 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Runs the "test-python.sh" test, setting proper environment variables
|
||||||
|
# for the build tree.
|
||||||
|
#
|
||||||
|
# - the first three arguments are the BUILDDIR, SRCDIR and PYTHON paths.
|
||||||
|
# The following arguments are passed on to "test-python.sh".
|
||||||
|
#
|
||||||
|
# - you can use "--" to separate the extra arguments.
|
||||||
|
#
|
||||||
|
# The full format is
|
||||||
|
#
|
||||||
|
# $ src/tests/client/test-client.sh "$BUILDDIR" "$SRCDIR" "$PYTHON" -- "${EXTRA[@]}"
|
||||||
|
#
|
||||||
|
# - "$BUILDDIR" "$SRCDIR" and "$PYTHON" can be set to "", to fallback
|
||||||
|
# to a default.
|
||||||
|
#
|
||||||
|
# The safe way to call it is thus
|
||||||
|
#
|
||||||
|
# $ src/tests/client/test-client.sh "" "" "" -- "${EXTRA[@]}"
|
||||||
|
#
|
||||||
|
# but for brevity, you can also call
|
||||||
|
#
|
||||||
|
# $ src/tests/client/test-client.sh -- "${EXTRA[@]}"
|
||||||
|
#
|
||||||
|
# if (and only if) "${EXTRA[@]}" does not contain "--".
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
@@ -7,29 +32,45 @@ die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$2" != "" ]; then
|
if [ "$4" = "--" ] ; then
|
||||||
SRCDIR="$(realpath "$2")"
|
ARGS=("${@:1:3}")
|
||||||
|
EXTRA=("${@:5}")
|
||||||
|
elif [ "$3" = "--" ]; then
|
||||||
|
ARGS=("${@:1:2}")
|
||||||
|
EXTRA=("${@:4}")
|
||||||
|
elif [ "$2" = "--" ]; then
|
||||||
|
ARGS=("${@:1:1}")
|
||||||
|
EXTRA=("${@:3}")
|
||||||
|
elif [ "$1" = "--" ]; then
|
||||||
|
ARGS=()
|
||||||
|
EXTRA=("${@:2}")
|
||||||
|
else
|
||||||
|
ARGS=("${@:1:3}")
|
||||||
|
EXTRA=("${@:4}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${ARGS[1]}" != "" ]; then
|
||||||
|
SRCDIR="$(realpath "${ARGS[1]}")"
|
||||||
else
|
else
|
||||||
SRCDIR="$(realpath "$(dirname "$BASH_SOURCE")/../../..")"
|
SRCDIR="$(realpath "$(dirname "$BASH_SOURCE")/../../..")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" != "" ]; then
|
if [ "${ARGS[0]}" != "" ]; then
|
||||||
BUILDDIR="$(realpath "$1")"
|
BUILDDIR="$(realpath "${ARGS[0]}")"
|
||||||
elif test -d "$SRCDIR/build" ; then
|
elif test -d "$SRCDIR/build" ; then
|
||||||
BUILDDIR="$(realpath "$SRCDIR/build")"
|
BUILDDIR="$(realpath "$SRCDIR/build")"
|
||||||
else
|
else
|
||||||
BUILDDIR="$SRCDIR"
|
BUILDDIR="$SRCDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test -d "$BUILDDIR" || die "BUILDDIR \"$BUILDDIR\" does not exist?"
|
if [ "${ARGS[2]}" != "" ]; then
|
||||||
test -d "$SRCDIR" || die "SRCDIR \"$SRCDIR\" does not exist?"
|
PYTHON="${ARGS[2]}"
|
||||||
|
|
||||||
if [ "$3" != "" ]; then
|
|
||||||
PYTHON="$3"
|
|
||||||
elif [ "$PYTHON" == "" ]; then
|
elif [ "$PYTHON" == "" ]; then
|
||||||
PYTHON="$(command -v python)" || die "python not found?"
|
PYTHON="$(command -v python)" || die "python not found?"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
test -d "$BUILDDIR" || die "BUILDDIR \"$BUILDDIR\" does not exist?"
|
||||||
|
test -d "$SRCDIR" || die "SRCDIR \"$SRCDIR\" does not exist?"
|
||||||
test -f "$BUILDDIR/src/nmcli/nmcli" || die "\"$BUILDDIR/src/nmcli/nmcli\" does not exist?"
|
test -f "$BUILDDIR/src/nmcli/nmcli" || die "\"$BUILDDIR/src/nmcli/nmcli\" does not exist?"
|
||||||
|
|
||||||
if test -f "$BUILDDIR/src/libnm-client-impl/.libs/libnm.so" ; then
|
if test -f "$BUILDDIR/src/libnm-client-impl/.libs/libnm.so" ; then
|
||||||
@@ -57,7 +98,7 @@ export NM_TEST_CLIENT_BUILDDIR="$BUILDDIR"
|
|||||||
# test output is grouped together.
|
# test output is grouped together.
|
||||||
|
|
||||||
r="ok"
|
r="ok"
|
||||||
"$PYTHON" "$SRCDIR/src/tests/client/test-client.py" -v &> "$BUILDDIR/src/tests/client/test-client.log" || r=fail
|
"$PYTHON" "$SRCDIR/src/tests/client/test-client.py" -v "${EXTRA[@]}" &> "$BUILDDIR/src/tests/client/test-client.log" || r=fail
|
||||||
|
|
||||||
cat "$BUILDDIR/src/tests/client/test-client.log"
|
cat "$BUILDDIR/src/tests/client/test-client.log"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user