diff mbox series

[bug#64356,v3,4/4] tests: xvnc: Group up GDM test.

Message ID 27c51859d81c8f2e55d41efd6b02e151d7531854.1688133473.git.mirai@makinata.eu
State New
Headers show
Series Fix GDM + VNC tests | expand

Commit Message

Bruno Victal June 30, 2023, 1:58 p.m. UTC
* gnu/tests/vnc.scm (run-xvnc-test): Group up GDM test. Use GNU Ocrad.
---
 gnu/tests/vnc.scm | 59 +++++++++++++++++++++++++----------------------
 1 file changed, 31 insertions(+), 28 deletions(-)

Comments

Maxim Cournoyer July 19, 2023, 2:47 p.m. UTC | #1
Hi,

Bruno Victal <mirai@makinata.eu> writes:

> * gnu/tests/vnc.scm (run-xvnc-test): Group up GDM test. Use GNU Ocrad.
> ---
>  gnu/tests/vnc.scm | 59 +++++++++++++++++++++++++----------------------
>  1 file changed, 31 insertions(+), 28 deletions(-)
>
> diff --git a/gnu/tests/vnc.scm b/gnu/tests/vnc.scm
> index e59972eee4..40f8348db9 100644
> --- a/gnu/tests/vnc.scm
> +++ b/gnu/tests/vnc.scm
> @@ -1,5 +1,6 @@

[...]

>  
>                  ;; Run vncviewer and expect the GDM login screen (accessed via
>                  ;; XDMCP).  This can take a while to appear on slower machines.
> -                (ratpoison-exec "vncviewer localhost:5905")
> -                ;; XXX: tesseract narrowly recognizes "Guix" as "uix" from the
> -                ;; background image; ocrad fares worst.  Sadly, 'Username' is
> -                ;; not recognized at all.

I've kept most of the comment; otherwise it'd be hard to understand for
a newcomer that Guix is matched from the background (e.g. when the
background changes and breaks this assumption...).

> +              (ratpoison-exec "vncviewer localhost:5905")
> +
> +              (test-assert "GDM login screen ready"
>                  (wait-for-screen-text marionette
> -                                      (cut string-contains <> "uix")
> -                                      #:ocr #$(file-append tesseract-ocr
> -                                                           "/bin/tesseract")
> -                                      #:timeout 120)))
> +                                      (cut string-contains <> "Guix")
> +                                      #:ocr #$ocr
> +                                      #:ocr-arguments '("--invert"))))

I've preserved the timeout, which is important for slow systems (I added
a comment).
diff mbox series

Patch

diff --git a/gnu/tests/vnc.scm b/gnu/tests/vnc.scm
index e59972eee4..40f8348db9 100644
--- a/gnu/tests/vnc.scm
+++ b/gnu/tests/vnc.scm
@@ -1,5 +1,6 @@ 
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>.
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -104,6 +105,8 @@  (define (run-xvnc-test)
               (operating-system os)
               (memory-size 1024)))
 
+  (define ocr (file-append ocrad "/bin/ocrad"))
+
   (define test
     (with-imported-modules (source-module-closure
                             '((gnu build marionette)
@@ -152,43 +155,43 @@  (define (run-xvnc-test)
 | grep -Fq nothing"))
                marionette))
 
-            (test-assert "vnc lands on the gdm login screen"
+            (test-group "vnc lands on the gdm login screen"
               ;; This test runs vncviewer on the local VM and verifies that it
               ;; manages to access the GDM login screen (via XDMCP).
-              (begin
-                (define (ratpoison-abort)
-                  (marionette-control "sendkey ctrl-g" marionette))
-
-                (define (ratpoison-help)
-                  (marionette-control "sendkey ctrl-t" marionette)
-                  (marionette-type "?" marionette)
-                  (sleep 1))            ;wait for help screen to appear
-
-                (define (ratpoison-exec command)
-                  (marionette-control "sendkey ctrl-t" marionette)
-                  (marionette-type "!" marionette)
-                  (marionette-type (string-append command "\n") marionette))
-
-                ;; Wait until the ratpoison help screen can be displayed; this
-                ;; means the window manager is ready.
+              (define (ratpoison-abort)
+                (marionette-control "sendkey ctrl-g" marionette))
+
+              (define (ratpoison-help)
+                (marionette-control "sendkey ctrl-t" marionette)
+                (marionette-type "?" marionette)
+                (sleep 1))            ;wait for help screen to appear
+
+              (define (ratpoison-exec command)
+                (marionette-control "sendkey ctrl-t" marionette)
+                (marionette-type "!" marionette)
+                (marionette-type (string-append command "\n") marionette))
+
+              ;; Wait until the ratpoison help screen can be displayed; this
+              ;; means the window manager is ready.
+              ;; XXX: The letters are half of the height preferred by
+              ;; GNU Ocrad, scale it by 2.
+              (test-assert "window manager is ready"
                 (wait-for-screen-text marionette
                                       (cut string-contains <> "key bindings")
-                                      #:ocr #$(file-append tesseract-ocr
-                                                           "/bin/tesseract")
+                                      #:ocr #$ocr
+                                      #:ocr-arguments '("--scale=2")
                                       #:pre-action ratpoison-help
-                                      #:post-action ratpoison-abort)
+                                      #:post-action ratpoison-abort))
 
                 ;; Run vncviewer and expect the GDM login screen (accessed via
                 ;; XDMCP).  This can take a while to appear on slower machines.
-                (ratpoison-exec "vncviewer localhost:5905")
-                ;; XXX: tesseract narrowly recognizes "Guix" as "uix" from the
-                ;; background image; ocrad fares worst.  Sadly, 'Username' is
-                ;; not recognized at all.
+              (ratpoison-exec "vncviewer localhost:5905")
+
+              (test-assert "GDM login screen ready"
                 (wait-for-screen-text marionette
-                                      (cut string-contains <> "uix")
-                                      #:ocr #$(file-append tesseract-ocr
-                                                           "/bin/tesseract")
-                                      #:timeout 120)))
+                                      (cut string-contains <> "Guix")
+                                      #:ocr #$ocr
+                                      #:ocr-arguments '("--invert"))))
 
             (test-end)))))