X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Fscripts%2Fagl-screenshot-test.sh;h=030ef34e23ae713dc093879fe953101806df212b;hb=f911ecf332aca722c13590a5c0bf085a37d4841e;hp=b0c79cd03b3082518fa66a7f37c94c16bb498053;hpb=b79f757e53d0ceddb835137ebc5bdf41c4148b1f;p=src%2Fqa-testdefinitions.git diff --git a/common/scripts/agl-screenshot-test.sh b/common/scripts/agl-screenshot-test.sh index b0c79cd..030ef34 100755 --- a/common/scripts/agl-screenshot-test.sh +++ b/common/scripts/agl-screenshot-test.sh @@ -1,8 +1,26 @@ #!/bin/bash -#set -x +set -x + +export TERM=dumb +export COLUMNS=1000 + +SCRIPTDIR=`dirname $(readlink -f $0)` +XDG_RUNTIME_DIR=/run/user/1001 +AGLDRIVER=agl-driver + +if [ -z $1 ] ; then + echo "No reference image passed" + exit 125 +fi + +REF_IMAGE=`readlink -f $1` + +# go to output directory +cd /home/$AGLDRIVER + + -REF_IMAGE="$1" if [ -z "${REF_IMAGE}" ]; then echo "No reference image passed" @@ -19,39 +37,50 @@ 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 +echo 'HOMESCREEN_DEMO_CI=1' > /etc/default/homescreen sync -systemctl daemon-reload +systemctl daemon-reload || true 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 +# create initial journal cursor file +journalctl /usr/bin/agl-compositor --cursor-file=/tmp/agl-screenshot-cursor > /tmp/first-log 2>&1 + +# stop homescreen (shell) and launcher +systemctl stop homescreen.service +systemctl stop launcher.service +# restart agl-compositor +systemctl restart agl-compositor.service +systemctl start homescreen.service + # e.g. qemu-system-arm takes loooong - echo "Waiting for compositor to initialize (+60sec)." +sleep 10 +echo "Waiting for compositor to initialize (+10sec)." + +LOOP=20 +while test $LOOP -ge 1 ; do + + ( mv /tmp/next-log /tmp/prev-log > /dev/null 2>&1 ) || true + journalctl /usr/bin/agl-compositor --cursor-file=/tmp/agl-screenshot-cursor > /tmp/next-log 2>&1 + if ! grep -q 'Usable area:' /tmp/next-log ; then + # e.g. qemu-system-arm takes loooong + echo "Waiting for compositor to initialize (+60sec). Loop: $LOOP" sleep 60 -fi -if ! grep -q 'Usable area:' /run/platform/display/compositor.log ; then - # e.g. qemu-system-arm takes loooong - echo "Waiting for compositor to initialize (+120sec)." - sleep 120 -fi + LOOP="$(($LOOP-1))" + continue + fi + break +done + +#read aw -# some take veeeeery long -if ! grep -q 'Usable area:' /run/platform/display/compositor.log ; then - # e.g. qemu-system-arm takes veeery loooong - echo "Waiting for compositor to initialize (+240sec)." - sleep 240 -fi # giving up now -if ! grep -q 'Usable area:' /run/platform/display/compositor.log ; then +if ! grep -q 'Usable area:' /tmp/next-log ; then echo "Marker ('Usable area:') not found. Dumping log." echo "##################################" - cat /run/platform/display/compositor.log + cat /tmp/first-log + cat /tmp/prev-log + cat /tmp/next-log echo "##################################" exit 127 #echo "CONTINUING ANYWAY !" @@ -59,59 +88,84 @@ fi AGL_SCREENSHOOTER=/usr/bin/agl-screenshooter + +#su - $AGLDRIVER -c "..." +do_screenshot() +{ + $AGL_SCREENSHOOTER -a + return $? +} + + 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 +rm -rf /home/agl-driver/agl-screenshot-*.png # give it a bit more time to display -sleep 30 +#sleep 60 + +$AGL_SCREENSHOOTER -l -if $AGL_SCREENSHOOTER; then +if do_screenshot ; then echo "Screenshot taken" else echo "##################################" - cat /run/platform/display/compositor.log + journalctl --no-pager -a -b /usr/bin/agl-compositor echo "##################################" exit 127 fi +ls agl-screenshot* + 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=1 + + +for SCREENSHOT in agl-screenshot-*.png ; do + IMAGE_SHA1SUM=`sha1sum $SCREENSHOT | awk -F ' ' '{print $1}'` + + if [ "${REF_IMAGE_SHA1SUM}" == "${IMAGE_SHA1SUM}" ]; then + echo "A Screenshot matches the reference image" FINALRET=0 -else - echo "Screenshot does not match the reference image" + break + else + echo "A 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 + +done + +if [ $FINALRET != 0 ] ; then + for i in agl-screenshot-*.png ; do + ${SCRIPTDIR}/./artiproxy-upload.sh $i "$i" + done + journalctl -b --no-pager -a > journal.txt + ${SCRIPTDIR}/./artiproxy-upload.sh journal.txt journal.txt + + echo "#########################" + cat /run/platform/display/*.log + echo "#########################" + set + 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 +rm -rf /etc/default/homescreen systemctl daemon-reload sync sleep 2 -systemctl restart weston@display.service +systemctl restart agl-compositor.service +systemctl restart homescreen.service +systemctl restart launcher.service + sleep 10 exit $FINALRET