|
24 | 24 | # - execute "sendkey ctrl-shift-f1" (switch to TTY1)
|
25 | 25 | # - login with "root"
|
26 | 26 | let
|
27 |
| - baseS3URL = "https://dividat-playos-test-disks.s3.amazonaws.com/by-tag"; |
| 27 | + # Note: we use HTTP instead of HTTPS, because pkgs.fetchurl fails |
| 28 | + # when __structuredAttrs is enabled (due to mysterious OpenSSL/TLS errors) |
| 29 | + # and also fails when __structuredAttrs is disabled (due to |
| 30 | + # https://github.com/NixOS/nixpkgs/issues/177660). |
| 31 | + # HTTP usage is fine since the output hash is fixed and verifies the download. |
| 32 | + baseS3URL = "http://dividat-playos-test-disks.s3.amazonaws.com/by-tag"; |
28 | 33 | # Generated via ./build release-disk and .github/workflows/release-tag.yml
|
29 | 34 | # See https://github.com/dividat/playos/releases
|
30 | 35 | diskImageURLs = {
|
31 |
| - "1.0.0-TEST" = { |
32 |
| - url = "${baseS3URL}/playos-disk-1.0.0-TEST.img.zst"; |
33 |
| - hash = "sha256-7cyStGfsxVyQ2ugkI9XRFnNrnPhd5QRf+oAQxLu3ovM="; |
| 36 | + "2023.9.1-DISK" = { |
| 37 | + url = "${baseS3URL}/playos-release-disk-2023.9.1-DISK.img.zst"; |
| 38 | + hash = "sha256-eTyNcDkYSsMUsUHToZJ4tEKag9WSi8gA2SAihFFCqH0="; |
| 39 | + }; |
| 40 | + "2024.7.0-DISK" = { |
| 41 | + url = "${baseS3URL}/playos-release-disk-2024.7.0-DISK.img.zst"; |
| 42 | + hash = "sha256-vJDB99ICt0W1PmONikNY5wwIF7oQU388DzYRgPqkooY="; |
34 | 43 | };
|
35 | 44 | };
|
36 | 45 | in
|
|
48 | 57 | kioskUrlDomain ? "kiosk-server.local",
|
49 | 58 |
|
50 | 59 | # PlayOS system we are updating from
|
51 |
| - baseSystemVersion ? "1.0.0-TEST", |
| 60 | + baseSystemVersion ? "2024.7.0-DISK", |
52 | 61 |
|
53 |
| - # A downloadable URL containing a zstd compressed disk image |
| 62 | + # A zstd-compressed PlayOS disk image |
54 | 63 | baseSystemDiskImage ? (pkgs.fetchurl diskImageURLs.${baseSystemVersion})
|
55 | 64 | .overrideAttrs {
|
56 | 65 | __structuredAttrs = true;
|
@@ -150,20 +159,23 @@ pkgs.testers.runNixOSTest {
|
150 | 159 | "-monitor" "vc"
|
151 | 160 | ];
|
152 | 161 |
|
153 |
| - enableOCR = true; |
154 |
| - |
155 | 162 | extraPythonPackages = ps: [
|
156 | 163 | ps.colorama
|
157 | 164 | ps.types-colorama
|
158 | 165 | ps.requests
|
159 | 166 | ps.types-requests
|
160 | 167 | ps.tesserocr
|
| 168 | + ps.pillow |
| 169 | + ps.types-pillow |
161 | 170 | ];
|
162 | 171 |
|
163 | 172 | testScript = {nodes}: ''
|
164 | 173 | ${builtins.readFile ./helpers/nixos-test-script-helpers.py}
|
165 | 174 | ${builtins.readFile ./end-to-end/tests/base/proxy-and-update-helpers.py}
|
166 | 175 | import tesserocr # type: ignore
|
| 176 | +import PIL.Image |
| 177 | +import PIL.ImageEnhance |
| 178 | +import PIL.ImageOps |
167 | 179 | import tempfile
|
168 | 180 | import time
|
169 | 181 | import atexit
|
@@ -191,13 +203,17 @@ extract_base_system_disk("${baseSystemDiskImage}", "${overlayPath}")
|
191 | 203 | playos.start(allow_reboot=True)
|
192 | 204 | sidekick.start()
|
193 | 205 |
|
194 |
| -# Less accurate, but much faster OCR than NixOS `get_screen_text`, |
195 |
| -# which takes almost 20 seconds per call. |
196 |
| -# Fails to identify white text on dark backgrounds. |
| 206 | +# Faster OCR than NixOS `get_screen_text`, which takes almost 20 seconds per |
| 207 | +# call. Fails to identify white text on dark backgrounds. |
197 | 208 | def screenshot_and_ocr(vm):
|
198 | 209 | with tempfile.TemporaryDirectory() as d:
|
199 | 210 | vm.screenshot(d + "/screenshot.png")
|
200 |
| - return tesserocr.file_to_text(d + "/screenshot.png") |
| 211 | + im = PIL.Image.open(d + "/screenshot.png") |
| 212 | + im = PIL.ImageOps.grayscale(im) |
| 213 | + im = PIL.ImageEnhance.Brightness(im).enhance(1.5) |
| 214 | + im = PIL.ImageEnhance.Contrast(im).enhance(4.0) |
| 215 | + return tesserocr.image_to_text(im) |
| 216 | +
|
201 | 217 |
|
202 | 218 | def wait_until_passes(test, retries=10, sleep=1):
|
203 | 219 | while True:
|
|
0 commit comments