diff options
author | Thomas Haller <thaller@redhat.com> | 2023-02-03 11:05:33 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-02-08 09:51:25 +0100 |
commit | b76bb7333e11448b4692bf57c123d564eaf0864e (patch) | |
tree | 115fbf3881dce51a78adc4872b3f3b7ff3fdbade | |
parent | f6805debee86a603ef290fe0242548990075cf19 (diff) | |
download | NetworkManager-b76bb7333e11448b4692bf57c123d564eaf0864e.tar.gz |
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
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | src/tests/client/meson.build | 1 | ||||
-rwxr-xr-x | src/tests/client/test-client.sh | 61 |
3 files changed, 53 insertions, 11 deletions
diff --git a/Makefile.am b/Makefile.am index 3d43c010a7..43c82a9088 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5456,7 +5456,7 @@ endif ############################################################################### 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 diff --git a/src/tests/client/meson.build b/src/tests/client/meson.build index b2e455bbbd..9dd58623a6 100644 --- a/src/tests/client/meson.build +++ b/src/tests/client/meson.build @@ -7,6 +7,7 @@ test( build_root, source_root, python.path(), + '--', ], timeout: 120, ) diff --git a/src/tests/client/test-client.sh b/src/tests/client/test-client.sh index 985d07c91a..a636f5fb93 100755 --- a/src/tests/client/test-client.sh +++ b/src/tests/client/test-client.sh @@ -1,5 +1,30 @@ #!/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 die() { @@ -7,29 +32,45 @@ die() { exit 1 } -if [ "$2" != "" ]; then - SRCDIR="$(realpath "$2")" +if [ "$4" = "--" ] ; then + 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 SRCDIR="$(realpath "$(dirname "$BASH_SOURCE")/../../..")" fi -if [ "$1" != "" ]; then - BUILDDIR="$(realpath "$1")" +if [ "${ARGS[0]}" != "" ]; then + BUILDDIR="$(realpath "${ARGS[0]}")" elif test -d "$SRCDIR/build" ; then BUILDDIR="$(realpath "$SRCDIR/build")" else BUILDDIR="$SRCDIR" fi -test -d "$BUILDDIR" || die "BUILDDIR \"$BUILDDIR\" does not exist?" -test -d "$SRCDIR" || die "SRCDIR \"$SRCDIR\" does not exist?" - -if [ "$3" != "" ]; then - PYTHON="$3" +if [ "${ARGS[2]}" != "" ]; then + PYTHON="${ARGS[2]}" elif [ "$PYTHON" == "" ]; then PYTHON="$(command -v python)" || die "python not found?" 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?" 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. 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" |