Replace autopkgtests with the tests used by freerdp3

This commit is contained in:
Jeremy Bícha 2024-10-04 12:05:57 -04:00
parent 6187297b6e
commit 48be888513
4 changed files with 24 additions and 46 deletions

40
debian/tests/compare vendored
View File

@ -1,40 +0,0 @@
#!/bin/sh
set -x
screenshot=xrdp-screenshot.png
magickout=match-matrix
testdir=$(dirname "$0")
sudo systemctl start xrdp
# Start XRDP and try to connect to it via Freerdp2, the package being tested.
# Take a screenshot of the X virtual framebuffer, which should contain the
# login screen.
xvfb-run -l "$testdir/connect-and-capture" "$screenshot"
# Try to remove the background to leave just the login window in the image
cp -a "$screenshot" "${screenshot}.before.mogrify.png"
mogrify -fuzz 4% -define trim:percent-background=0% -trim +repage -format png "$screenshot"
# Resize the search image to match nearly the really displayed size
convert -resize 50% /usr/share/xrdp/xrdp_logo.bmp xrdp_logo_50percent.png
# Confirm that the XRDP logo is in the log in screen (so as to confirm that the
# login screen is really there).
# https://stackoverflow.com/questions/31867093/how-to-search-an-image-for-subimages-using-linux-console
# compare creates two output files, $magickout-{0,1}; The latter
# is a grayscale pattern, in which a white pixel represents a match.
# If the images don't even resemble each other in any way, the compare
# will fail but we don't need to check that specifically, because so
# will the if below.
compare -metric RMSE -subimage-search \
"$screenshot" xrdp_logo_50percent.png png:"$magickout"
# In case of match, output will be like
# "520,347: (255,255,255) #FFFFFF gray(255)"
# in which the first field is the coordinates of the match.
if ! convert "$magickout-1" -threshold 95% txt: | grep -qi '#FFFFFF'; then
2>&1 printf "%s\n" "Imagemagick did not find any occurence of the XRDP" \
"logo inside the screenshot of the remote desktop." \
"This test therefore failed."
exit 2
fi

22
debian/tests/connect vendored Normal file
View File

@ -0,0 +1,22 @@
#!/bin/sh -x
isNaturalNumber(){
case "$1" in
''|*[!0-9]*) return 0;;
*) return 1;;
esac
}
sudo systemctl start xrdp
# XXX: Is there a better way to get the port number other than by parsing the
# configuration file?
port=$(sed -n '/^port=[0123456789]/{s/port=//p;q;}' /etc/xrdp/xrdp.ini)
if test ! isNaturalNumber "$port"; then
exit 1
fi
timeout 2s xvfb-run -l xfreerdp /v:localhost:"$port" /p: /u: /d:
if test $? != 124; then
2>&1 printf "%s\n" "Xfreerdp exited before the timeout, it has likely " \
"failed to connect. The test has therefore failed."
exit 2
fi

View File

@ -1,4 +0,0 @@
#!/bin/sh
xfreerdp /f /v:localhost:3389 /p: /u: /d: /cert-tofu &
sleep 12
import -window root "$1"

View File

@ -1,3 +1,3 @@
Tests: compare
Depends: @, xauth, xrdp, xvfb, imagemagick
Tests: connect
Depends: @, xauth, xrdp, xvfb
Restrictions: allow-stderr, needs-sudo