From: Simon Tatham Date: Sun, 19 Jan 2025 11:09:07 +0000 (+0000) Subject: Add an autopkgtest. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~sgtatham/git?a=commitdiff_plain;h=0aaca7b51da2d514c27b11278a40738450c8fae0;p=xsession-traditional.git Add an autopkgtest. This sets up a test user, configures lightdm to auto-login as that user, configures the user to use xsession-traditional as its preferred login session type, and writes a .xsession that creates an "it worked" indicator file. So it can run without any interactive intervention and prove that the user's .xsession really was run. --- diff --git a/debian/tests/autologin b/debian/tests/autologin new file mode 100644 index 0000000..a438c37 --- /dev/null +++ b/debian/tests/autologin @@ -0,0 +1,48 @@ +#!/bin/sh + +set -ex + +# Make a test user account +useradd -m testuser + +# Give that user a ~/.dmrc that selects the session type under test +cat >> /home/testuser/.dmrc << EOF +[Desktop] +Session=xsession-traditional +EOF +chown testuser:testuser /home/testuser/.dmrc +chmod 644 /home/testuser/.dmrc + +# Make the user's ~/.xsession write to a named pipe to prove that it +# ran. Then it just sleeps in a loop, to avoid ending the session and +# worrying lightdm. +cat >> /home/testuser/.xsession << EOF +#!/bin/sh +echo 'Hello from the test .xsession!' > /home/testuser/fifo +while :; do sleep 60; done +EOF +chown testuser:testuser /home/testuser/.xsession +chmod 755 /home/testuser/.xsession +mkfifo -m 0666 /home/testuser/fifo + +# Configure lightdm to auto-login as the test user, to avoid needing +# interactive input to the test run +cat > /etc/lightdm/lightdm.conf << EOF +[Seat:*] +autologin-guest=false +autologin-user=testuser +autologin-user-timeout=0 +EOF + +# Now start lightdm, which should log in as testuser, which should run +# testuser's .xsession, which should create the file saying it worked. +systemctl start lightdm + +# Read from the fifo, and expect to see the hello message. +# +# It would be nice to somehow detect conditions that proved the test +# _hadn't_ worked, e.g. by accidentally launching some other session +# type. Then this test could be made to fail quickly. But I can't +# think of any sensible way to do that, so instead I just use a crude +# timeout. +timeout 5m cat /home/testuser/fifo >&2 diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..713206f --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,3 @@ +Tests: autologin +Depends: xserver-xorg, lightdm, passwd, @ +Restrictions: isolation-container, needs-root, allow-stderr