diff options
author | Klement Sekera <ksekera@cisco.com> | 2021-05-31 16:08:53 +0200 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2022-02-17 18:02:35 +0000 |
commit | b23ffd7ef216463c35b75c831e6a27e58971f4ec (patch) | |
tree | 84983bd698b2b3da6c6278e870ef978f69dbda43 /test/scripts | |
parent | 8ccc6b350703d3390633636d2b1c2f578f37cb21 (diff) |
tests: make tests less make dependent
Implement command line argument parsing instead of passing arguments via
environment variables. Add script for running tests without having to
invoke make. Deprecate running tests via make.
Type: improvement
Change-Id: I2e3054a61a2ae25d460e9be00be7d7705fbf943e
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'test/scripts')
-rwxr-xr-x | test/scripts/run.sh | 71 | ||||
-rwxr-xr-x | test/scripts/setsid_wrapper.sh | 11 |
2 files changed, 79 insertions, 3 deletions
diff --git a/test/scripts/run.sh b/test/scripts/run.sh new file mode 100755 index 00000000000..544a536ed36 --- /dev/null +++ b/test/scripts/run.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +ff="0" +items= +for i in "$@" +do +case $i in + --venv-dir=*) + venv_dir="${i#*=}" + if [ -d $venv_dir ] + then + venv_dir=$(cd $venv_dir; pwd) + else + echo "ERROR: '$venv_dir' is not a directory" + exit 1 + fi + items="$items --venv-dir=\"$venv_dir\"" + ;; + --vpp-ws-dir=*) + ws_dir="${i#*=}" + if [ -d $ws_dir ] + then + ws_dir=$(cd $ws_dir; pwd) + else + echo "ERROR: '$ws_dir' is not a directory" + exit 1 + fi + items="$items --vpp-ws-dir=\"$ws_dir\"" + ;; + --force-foreground) + ff="1" + items="$items \"$i\"" + ;; + --vpp-tag=*) + tag="${i#*=}" + items="$items \"$i\"" + ;; + --python-opts=*) + python_opts="${i#*=}" + ;; + *) + # unknown option - skip + items="$items \"$i\"" + ;; +esac +done + +extra_args="" +if [ -z "$ws_dir" ] +then + ws_dir=$(pwd) + echo "Argument --vpp-ws-dir not specified, defaulting to '$ws_dir'" + extra_args="$extra_args --vpp-ws-dir=$ws_dir" +fi + +if [ -z "$venv_dir" ] +then + venv_dir="$ws_dir/test/venv" + echo "Argument --venv-path not specified, defaulting to '$venv_dir'" + extra_args="$extra_args --venv-dir=$venv_dir" +fi + +if [ -z "$tag" ] +then + tag="vpp_debug" + echo "Argument --vpp-tag not specified, defaulting to '$tag'" + extra_args="$extra_args --vpp-tag=$tag" +fi + +eval set -- $items +$ws_dir/test/scripts/setsid_wrapper.sh $ws_dir/test/scripts/run_in_venv_with_cleanup.sh $ff $venv_dir/bin/activate python3 $python_opts $ws_dir/test/run_tests.py $extra_args $* diff --git a/test/scripts/setsid_wrapper.sh b/test/scripts/setsid_wrapper.sh index 6d63426becc..030c3b079de 100755 --- a/test/scripts/setsid_wrapper.sh +++ b/test/scripts/setsid_wrapper.sh @@ -1,10 +1,15 @@ #!/bin/bash -if [[ "$1" == "1" ]] +cmd=$1 +force_foreground=$2 +shift +shift + +if [[ "$force_foreground" == "1" ]] then - setsid scripts/run_in_venv_with_cleanup.sh $* + setsid $cmd $force_foreground $* else - setsid scripts/run_in_venv_with_cleanup.sh $* & + setsid $cmd $force_foreground $* & pid=$! trap "echo setsid_wrapper.sh: got signal, killing child pid ${pid}; kill ${pid}; sleep .1;" SIGINT SIGTERM wait ${pid} |