Re: [hatari-devel] Hatari screen test

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On 5/29/20 1:02 PM, Thomas Huth wrote:
Am Thu, 28 May 2020 21:22:00 +0200
schrieb Thomas Huth <th.huth@xxxxxxxxx>:

Am Thu, 28 May 2020 02:23:38 +0300
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
[...]
However, the really interesting thing is that
*5* additional VBLs are needed for screenshot
to look correct! [1]

Looking at the assembly code, install_all()
subroutine sets A0 value first, then does
2 vsyncs, and get_lines() subroutine does also
2 vsyncs.  These are before the real fullscreen
routine starts, which explains the need for
extra 5 VBLs.

Are you sure that your breakpoint triggered at the right point in
time? A0 is only set to FFFF820A in the open_top2 section during
fullvbl ... which should be called only after all the initialization
stuff has been done. During install_all, A0 is set to FFFF8201
instead. ==> Please double check that your breakpoint really triggers
at the right location.

I just notice another thing: Please check your --frameskips setting. If
it is set to something different than 0 (it is "auto" by default), then
you could run into the situation that the screen is not updated yet,
though it should be correct already from the ST side.

Good catch, that was it.


With frameskip disabled, one can use this:
----------------------------------------------
# parse screenshot.ini on VBL where A0 has required value
breakpoint  VBL ! VBL  &&  a0 = 0xFFFF820A  :trace :file screenshot.ini
----------------------------------------------


Or if VBL change info output is annoying, this:
----------------------------------------------
# parse screenshot.ini on next VBL after A0 has required value
breakpoint  a0 = 0xFFFF820A  &&   VBL ! VBL  :2 :trace :file screenshot.ini
----------------------------------------------


Attached is patch to change the test to use
latter.  Is handling of paths by 'cd'ing to
test dir OK?


	- Eero
commit 26487f57fd199d6765f9f604604d1cc6509503ea
Author: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date:   Fri May 29 13:42:28 2020 +0300

    Change fullscreen test to use debugger scripting
    
    Checked register is set on one frame *before* screen looks correct, so
    there's a (very small) possibility that test would sometimes fail when
    using cmd-fifo for checks.
    
    Using conditional breakpoint to check the register and do screenshot
    on next VBL makes this robust.
    
    For conditional breakpoint file chaining to work, test needs either to
    generate the debugger input files with correct paths to test dir, or
    current workdir needs to be change to where they are.  Latter let me
    to simplify the script a lot, so I chose that.
    
    Frame skipping needs also to be disabled, as otherwise screenshot
    content may not be converted on next VBL.

diff --git a/tests/screen/CMakeLists.txt b/tests/screen/CMakeLists.txt
index f350cbd5..ce07cb5a 100644
--- a/tests/screen/CMakeLists.txt
+++ b/tests/screen/CMakeLists.txt
@@ -9,9 +9,7 @@ if(ENABLE_SDL2)
  if(GM OR IDENTIFY)
 
   add_test(NAME screen-fullscreen
-           COMMAND ${testrunner} $<TARGET_FILE:hatari>
-                   ${CMAKE_CURRENT_SOURCE_DIR}/flixfull.prg
-                   ${CMAKE_CURRENT_SOURCE_DIR}/flixref.png)
+           COMMAND ${testrunner} $<TARGET_FILE:hatari>)
 
  endif(GM OR IDENTIFY)
 
diff --git a/tests/screen/debugger.ini b/tests/screen/debugger.ini
new file mode 100644
index 00000000..6bae479e
--- /dev/null
+++ b/tests/screen/debugger.ini
@@ -0,0 +1,2 @@
+# parse screenshot.ini on next VBL after A0 has required value
+breakpoint  a0 = 0xFFFF820A  &&  VBL ! VBL  :2 :trace :file screenshot.ini
diff --git a/tests/screen/run_test.sh b/tests/screen/run_test.sh
index 6e22b559..0b77f692 100755
--- a/tests/screen/run_test.sh
+++ b/tests/screen/run_test.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
-if [ $# -lt 3 -o "$1" = "-h" -o "$1" = "--help" ]; then
-	echo "Usage: $0 <hatari> <prg> <ref.png> ..."
+if [ $# -lt 1 -o "$1" = "-h" -o "$1" = "--help" ]; then
+	echo "Usage: $0 <hatari> ..."
 	exit 1
 fi
 
@@ -14,6 +14,18 @@ else
 	exit 1
 fi
 
+# need to be in script directory so that all the necessary files
+# are found from the current directory:
+# - test program
+# - reference screenshot
+# - debugger.ini file
+# - screenshot.ini file
+#
+# Otherwise paths need to be added for first two, and debugger
+# files generated from this script with correct paths.
+basedir=$(dirname $0)
+cd $basedir
+
 hatari=$1
 shift
 if [ ! -x "$hatari" ]; then
@@ -21,13 +33,6 @@ if [ ! -x "$hatari" ]; then
 	exit 1
 fi;
 
-prg=$1
-shift
-
-refpng=$1
-shift
-
-basedir=$(dirname $0)
 testdir=$(mktemp -d)
 cmdfifo="$testdir/cmdfifo"
 
@@ -35,35 +40,16 @@ export SDL_VIDEODRIVER=dummy
 export SDL_AUDIODRIVER=dummy
 unset TERM
 
-HOME="$testdir" $hatari --log-level fatal --sound off --fast-forward on -z 1 \
-	--max-width 416 --confirm-quit false --tos none --statusbar off \
-	--cmd-fifo "$cmdfifo" --screenshot-dir "$testdir" $* "$prg" \
-	> "$testdir/out.txt" 2>&1 &
-
-# Wait until the fifo has been created by Hatari
-while ! test -p "$cmdfifo" ; do
-	sleep 0.1
-done
-
-# Wait until the program is ready, i.e. it is writing to 0xFFFF820A
-while ! grep -q -i FFFF820A "$testdir/out.txt" ; do
-	echo "hatari-debug r" > "$cmdfifo"
-	sleep 0.1
-done
-
-echo "hatari-shortcut screenshot" > "$cmdfifo"
-
-while ! grep -q "Screen dump saved" "$testdir/out.txt" ; do
-	sleep 0.1
-done
-
-echo "hatari-shortcut quit" > "$cmdfifo"
+HOME="$testdir" $hatari --log-level fatal --confirm-quit false --zoom 1 \
+	--sound off --statusbar off --max-width 416 --tos none \
+	--fast-forward on --frameskips 0 --parse debugger.ini \
+	--cmd-fifo "$cmdfifo" --screenshot-dir "$testdir" $* flixfull.prg \
+	> "$testdir/out.txt" 2>&1
+exitstat=$?
 
-ref_signature=$($identify -format "%#" "$refpng")
-tst_signature=$($identify -format "%#" "$testdir"/grab0001.*)
+ref_signature=$($identify -format "%#" "flixref.png")
+tst_signature=$($identify -format "%#" "$testdir/verify.png")
 
-wait $hatari_pid
-exitstat=$?
 if [ $exitstat -ne 0 ]; then
 	echo "Running hatari FAILED. Status=${exitstat}. Hatari output:"
 	cat "$testdir/out.txt"
diff --git a/tests/screen/screenshot.ini b/tests/screen/screenshot.ini
new file mode 100644
index 00000000..1a86b44b
--- /dev/null
+++ b/tests/screen/screenshot.ini
@@ -0,0 +1,3 @@
+# take screenshot and quit Hatari
+screenshot verify.png
+quit


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/