freerdp2/debian/tests/compare
Nathan Pratta Teodosio df721c20b4 Add autopkgtest to test whether a client can connect
to an XRDP server via freerdp2 and that the login screen shows up

Closes: #1073156
LP: #2060976

Gbp-Dch: Full
2024-06-13 13:26:42 -04:00

34 lines
1.4 KiB
Bash

#!/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"
# 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" /usr/share/xrdp/xrdp_logo.bmp 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