From: Tom Hromatka Date: Wed, 23 Mar 2022 15:13:27 +0000 (-0600) Subject: ftests: Add support for make distcheck X-Git-Tag: v3.1.0~308^2~2^2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8faad2c53d79e8a6e4052eed608d43b0f20a22c;p=thirdparty%2Flibcgroup.git ftests: Add support for make distcheck make distcheck builds libcgroup in a different directory from where it runs the tests. Add smarts to ftests.sh and ftests-nocontainer.sh to support this case by copying the requisite python files. After the tests complete, the python files are then removed. Signed-off-by: Tom Hromatka --- diff --git a/ftests/ftests-nocontainer.sh b/ftests/ftests-nocontainer.sh index ec35eeca..975ccc34 100755 --- a/ftests/ftests-nocontainer.sh +++ b/ftests/ftests-nocontainer.sh @@ -1,4 +1,26 @@ #!/bin/bash # SPDX-License-Identifier: LGPL-2.1-only -./ftests.py -l 10 -L ftests-nocontainer.log --no-container +START_DIR=$PWD +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +if [ "$START_DIR" != "$SCRIPT_DIR" ]; then + cp "$SCRIPT_DIR"/*.py "$START_DIR" +fi + +if [ -d ../../src/python/build/lib.* ]; then + pushd ../../src/python/build/lib.* + export PYTHONPATH="$PYTHONPATH:$(pwd)" + popd +fi + +./ftests.py -l 10 -L "$START_DIR/ftests-nocontainer.py.log" --no-container +RET=$? + +if [ "$START_DIR" != "$SCRIPT_DIR" ]; then + rm -f "$START_DIR"/*.py + rm -fr "$START_DIR"/__pycache__ + rm -f ftests-nocontainer.py.log +fi + +exit $RET diff --git a/ftests/ftests.sh b/ftests/ftests.sh index 2ff86a36..f9a42546 100755 --- a/ftests/ftests.sh +++ b/ftests/ftests.sh @@ -1,4 +1,26 @@ #!/bin/bash # SPDX-License-Identifier: LGPL-2.1-only -./ftests.py -l 10 -L ftests.log +START_DIR=$PWD +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +if [ "$START_DIR" != "$SCRIPT_DIR" ]; then + cp "$SCRIPT_DIR"/*.py "$START_DIR" +fi + +if [ -d ../../src/python/build/lib.* ]; then + pushd ../../src/python/build/lib.* + export PYTHONPATH="$PYTHONPATH:$(pwd)" + popd +fi + +./ftests.py -l 10 -L "$START_DIR/ftests.py.log" +RET=$? + +if [ "$START_DIR" != "$SCRIPT_DIR" ]; then + rm -f "$START_DIR"/*.py + rm -fr "$START_DIR"/__pycache__ + rm -f ftests.py.log +fi + +exit $RET