From 72eb8ac08615d7769e5f94e1c02d169f8a7974d3 Mon Sep 17 00:00:00 2001 From: Simon McVittie <simon.mcvittie@collabora.co.uk> Date: Fri, 9 Sep 2016 11:30:05 +0100 Subject: [PATCH] sanity-check: make this more usable as a manual test Previously, this test didn't provide an obvious indication that it had all succeeded, and assumed that it was run as root with $(pwd) in /usr/lib/apertis-tests or a git clone of apertis-tests. To use this as a manual test: Prerequisites: - apertis-tests installed (sudo apt install apertis-tests) Steps: sudo /usr/lib/apertis-tests/common/sanity-check Successful result: Output ends with "# Sanity check successful" Failing result: Output ends with "Failed, see above for details" or ends with neither of the expected messages Diagnosing failures: Look for "TEST_RESULT:fail:" in the output (it may appear more than once), and look for warnings/errors shortly before each occurrence of that message Reviewed-by: Luis Araujo <luis.araujo@collabora.co.uk> Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk> Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Differential Revision: https://phabricator.apertis.org/D4284 --- common/sanity-check | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/common/sanity-check b/common/sanity-check index 18d153d..9c31645 100755 --- a/common/sanity-check +++ b/common/sanity-check @@ -15,6 +15,14 @@ set -e +if [ "$(id -u)" != 0 ]; then + echo "This test must be run as root" >&2 + exit 1 +fi + +pkglibdir="$(cd "$(dirname $0)/.." && pwd)" +common="${pkglibdir}/common" + failed=0 fail () { @@ -35,12 +43,12 @@ getent passwd root || fail getent-passwd-root getent passwd user || fail getent-passwd-user env || fail lava-env -common/run-test-in-systemd --name=system-env common/sanity-check-env system || : -common/run-test-in-systemd --name=user-env --user=user common/sanity-check-env user || : +"$common/run-test-in-systemd" --name=system-env "$common/sanity-check-env" system || : +"$common/run-test-in-systemd" --name=user-env --user=user "$common/sanity-check-env" user || : id || fail lava-id -common/run-test-in-systemd --name=system-id id || : -common/run-test-in-systemd --name=user-id --user=user id || : +"$common/run-test-in-systemd" --name=system-id id || : +"$common/run-test-in-systemd" --name=user-id --user=user id || : test -S /run/dbus/system_bus_socket || fail system-bus-is-up test -d /run/user/$(id -u user)/systemd || fail user-session-is-up @@ -52,14 +60,17 @@ grep -E '^NAME=("?)Apertis\1$' /etc/os-release || fail os-release-name grep -E '^ID=("?)apertis\1$' /etc/os-release || fail os-release-id if ! test -S /run/user/$(id -u user)/wayland-0; then - common/run-test-in-systemd --user=user --name=x11-works -- xterm -e /bin/true + "$common/run-test-in-systemd" --user=user --name=x11-works -- xterm -e /bin/true fi +set +x # remaining commands run are uninteresting + if test "x$failed" != "x0"; then echo "Failed, see above for details" >&2 exit "$failed" fi +echo "# Sanity check successful" exit 0 # vim:set sw=4 sts=4 et: -- GitLab