summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2023-02-06 13:24:11 +0000
committerSimon McVittie <smcv@collabora.com>2023-02-06 13:24:11 +0000
commit25e1512c17be88b3dfdfd576969dcc5503495b68 (patch)
tree63611302cbc9c5f474e42123996e6613794fc33c
parentdfa7eede446de6c2711cb6b2e5a91667880d2c22 (diff)
downloaddbus-25e1512c17be88b3dfdfd576969dcc5503495b68.tar.gz
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 <smcv@collabora.com>
-rwxr-xr-xtools/ci-build.sh31
1 files changed, 23 insertions, 8 deletions
diff --git a/tools/ci-build.sh b/tools/ci-build.sh
index 989e1fc3..df22b8ba 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
;;