From 36bfc4c76c9c1f44c3232baa6d8576db8bc488d2 Mon Sep 17 00:00:00 2001 From: Corentin LABBE Date: Fri, 15 Jan 2021 12:47:16 +0000 Subject: [PATCH] SPEC-3764: add screenshoot test Add basic screenshooter test. Change-Id: I8be9c6b4f621dc757c7e8ab846384c0fb32561df Bug-AGL: SPEC-3764 Signed-off-by: Corentin LABBE --- common/scripts/agl-screenshot-test.sh | 100 +++++++++++++++++++++++++++++ reference-images/reference-image.png | Bin 0 -> 8602 bytes test-suites/short-smoke/screenshooter.yaml | 9 +++ 3 files changed, 109 insertions(+) create mode 100755 common/scripts/agl-screenshot-test.sh create mode 100644 reference-images/reference-image.png create mode 100644 test-suites/short-smoke/screenshooter.yaml diff --git a/common/scripts/agl-screenshot-test.sh b/common/scripts/agl-screenshot-test.sh new file mode 100755 index 0000000..b9d934f --- /dev/null +++ b/common/scripts/agl-screenshot-test.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +#set -x + +REF_IMAGE="$1" + +if [ -z "${REF_IMAGE}" ]; then + echo "No reference image passed" + exit 125 +fi + +if [ ! -f "${REF_IMAGE}" ]; then + echo "Reference image is not found" + exit 125 +fi + +# Enable the test picture and disable cursor and any other application from being displayed +sed -i '/^\[core\]/a activate-by-default=false' /etc/xdg/weston/weston.ini +# setup homescreen env variable +sed -i '/^\[core\]/a hide-cursor=true' /etc/xdg/weston/weston.ini +# enable red/green/blue test screen +echo 'HOMESCREEN_DEMO_CI=1' > /etc/afm/unit.env.d/screenshot +sync +systemctl daemon-reload +sleep 2 +# restart weston@display +systemctl restart weston@display.service +# e.g. qemu-system-arm takes loooong +sleep 60 +echo "Waiting for compositor to initialize (+60sec)." + +if ! grep -q 'Usable area:' /run/platform/display/compositor.log ; then +# e.g. qemu-system-arm takes loooong + echo "Waiting for compositor to initialize (+60sec)." + sleep 60 +fi +if ! grep -q 'Usable area:' /run/platform/display/compositor.log ; then + echo "Marker ('Usable area:') not found. Dumping log." + echo "##################################" + cat /run/platform/display/compositor.log + echo "##################################" + exit 127 + #echo "CONTINUING ANYWAY !" +fi + +AGL_SCREENSHOOTER=/usr/bin/agl-screenshooter + +if [ -z "$AGL_SCREENSHOOTER" ]; then + echo "Failed to find agl-screenshooter. Compositor too old?" + exit 127 +fi + +#echo "Found agl-screenshoooter in $AGL_SCREENSHOOTER" +rm -rf agl-screenshot-*.png + +if $AGL_SCREENSHOOTER; then + echo "Screenshot taken" +else + echo "##################################" + cat /run/platform/display/compositor.log + echo "##################################" + exit 127 +fi + +REF_IMAGE_SHA1SUM=`sha1sum ${REF_IMAGE} | awk -F ' ' '{print $1}'` +IMAGE_SHA1SUM=`sha1sum agl-screenshot-*.png | awk -F ' ' '{print $1}'` + +if [ "${REF_IMAGE_SHA1SUM}" == "${IMAGE_SHA1SUM}" ]; then + echo "Screenshot matches the reference image" + FINALRET=0 +else + echo "Screenshot does not match the reference image" + FINALRET=127 + for i in agl-screenshot-*.png ; do + #set +x + echo "################################################################" + ( curl --upload-file "$i" https://transfer.sh/$(basename "$i") && echo "" ) || true + echo "################################################################" + #set -x + done + echo "#########################" + cat /run/platform/display/*.log + echo "#########################" + journalctl -b --no-pager -a + echo "#########################" +fi + + +# cleanup +sed -i '/activate-by-default=false/d' /etc/xdg/weston/weston.ini +sed -i '/hide-cursor=true/d' /etc/xdg/weston/weston.ini +#rm -rf /etc/systemd/system/weston@.service.d +rm -rf /etc/afm/unit.env.d/screenshot +systemctl daemon-reload +sync +sleep 2 +systemctl restart weston@display.service +sleep 10 + +exit $FINALRET diff --git a/reference-images/reference-image.png b/reference-images/reference-image.png new file mode 100644 index 0000000000000000000000000000000000000000..d6579e045e6059adf91cd877b2d056866430caec GIT binary patch literal 8602 zcmeAS@N?(olHy`uVBq!ia0y~yU~gbxV6os}0*a(>3=;uTY)RhkE)4%caKYZ?lNlHk z7(87ZLn`LHxp9#5fC0||hvk#YKbLVOa+C|dSZn;5H|O`W9Ce^ZhM1>&ZnGME&S3{} z7z)&xr9gB;3nMRxb~x0)2BH-b9hgD%1cL>PAlgIX0*GQz;mH8gLTn~rnsZe9XwZ!& z8&F;t%`&6K1t=Yi7L}vb1SlPhR*?)0qs@cSmK887jJ7IAn+KpGakMuv+B^WIgVA2( zX!8J+4n~^?qs;?gG8k(S3(F7{r($!@RAK z;oSs9$gpk%2V^*RR2n?$JsK>d$pM&a8b)&oc+zLIbQmo(f!SfSR2(f8M@z*akqyq; p%62j^Fgk