From: Simon McVittie Date: Mon, 6 Feb 2023 13:24:11 +0000 (+0000) Subject: CI: Re-run some tests as root or as non-root, as appropriate X-Git-Tag: dbus-1.15.4~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25e1512c17be88b3dfdfd576969dcc5503495b68;p=thirdparty%2Fdbus.git CI: Re-run some tests as root or as non-root, as appropriate On Gitlab-CI we're always running the overall script as root (and therefore we'll only enter the code path to re-run as non-root), but when using these scripts for manual testing they might be run as non-root to begin with. Signed-off-by: Simon McVittie --- diff --git a/tools/ci-build.sh b/tools/ci-build.sh index 989e1fc3f..df22b8ba8 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -371,19 +371,34 @@ case "$ci_buildsys" in maybe_fail_tests cat test/test-suite.log || : - # re-run them with gnome-desktop-testing + # Re-run them with gnome-desktop-testing. + # Also, one test needs a finite fd limit to be useful, so we + # can set that here. env LD_LIBRARY_PATH=/usr/local/lib \ + bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \ gnome-desktop-testing-runner -d /usr/local/share dbus/ || \ maybe_fail_tests - # these tests benefit from being re-run as root, and one - # test needs a finite fd limit to be useful - sudo env LD_LIBRARY_PATH=/usr/local/lib \ - bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \ + # Some tests benefit from being re-run as non-root, if we were + # not already... + if [ "$(id -u)" = 0 ] && [ "$ci_in_docker" = yes ]; then + sudo -u user \ + env LD_LIBRARY_PATH=/usr/local/lib \ gnome-desktop-testing-runner -d /usr/local/share \ - dbus/test-dbus-daemon_with_config.test \ - dbus/test-uid-permissions_with_config.test || \ - maybe_fail_tests + dbus/test-dbus-daemon_with_config.test \ + || maybe_fail_tests + fi + + # ... while other tests benefit from being re-run as root, if + # we were not already + if [ "$(id -u)" != 0 ]; then + sudo env LD_LIBRARY_PATH=/usr/local/lib \ + bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \ + gnome-desktop-testing-runner -d /usr/local/share \ + dbus/test-dbus-daemon_with_config.test \ + dbus/test-uid-permissions_with_config.test || \ + maybe_fail_tests + fi fi ;;