From 48be8885132774192e2a611d820cdb4ef536ac00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20B=C3=ADcha?= Date: Fri, 4 Oct 2024 12:05:57 -0400 Subject: [PATCH] Replace autopkgtests with the tests used by freerdp3 --- debian/tests/compare | 40 -------------------------------- debian/tests/connect | 22 ++++++++++++++++++ debian/tests/connect-and-capture | 4 ---- debian/tests/control | 4 ++-- 4 files changed, 24 insertions(+), 46 deletions(-) delete mode 100644 debian/tests/compare create mode 100644 debian/tests/connect delete mode 100755 debian/tests/connect-and-capture diff --git a/debian/tests/compare b/debian/tests/compare deleted file mode 100644 index 5dd3d31..0000000 --- a/debian/tests/compare +++ /dev/null @@ -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 diff --git a/debian/tests/connect b/debian/tests/connect new file mode 100644 index 0000000..9cbcacb --- /dev/null +++ b/debian/tests/connect @@ -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 diff --git a/debian/tests/connect-and-capture b/debian/tests/connect-and-capture deleted file mode 100755 index 5b98fd7..0000000 --- a/debian/tests/connect-and-capture +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -xfreerdp /f /v:localhost:3389 /p: /u: /d: /cert-tofu & -sleep 12 -import -window root "$1" diff --git a/debian/tests/control b/debian/tests/control index 9088ece..8062dd0 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -1,3 +1,3 @@ -Tests: compare -Depends: @, xauth, xrdp, xvfb, imagemagick +Tests: connect +Depends: @, xauth, xrdp, xvfb Restrictions: allow-stderr, needs-sudo