Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/testing: add ghostscript runtime test
@ 2024-02-09 19:29 Julien Olivain
  2024-02-11 21:48 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain @ 2024-02-09 19:29 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 DEVELOPERS                                    |  2 +
 .../testing/tests/package/test_ghostscript.py | 48 +++++++++++++++++++
 .../rootfs-overlay/root/document.ps           |  9 ++++
 3 files changed, 59 insertions(+)
 create mode 100644 support/testing/tests/package/test_ghostscript.py
 create mode 100644 support/testing/tests/package/test_ghostscript/rootfs-overlay/root/document.ps

diff --git a/DEVELOPERS b/DEVELOPERS
index 1c6c84b05b..db0821c82b 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1783,6 +1783,8 @@ F:	support/testing/tests/package/test_fluidsynth.py
 F:	support/testing/tests/package/test_fluidsynth/
 F:	support/testing/tests/package/test_fping.py
 F:	support/testing/tests/package/test_gawk.py
+F:	support/testing/tests/package/test_ghostscript.py
+F:	support/testing/tests/package/test_ghostscript/
 F:	support/testing/tests/package/test_glslsandbox_player.py
 F:	support/testing/tests/package/test_glslsandbox_player/
 F:	support/testing/tests/package/test_gnupg2.py
diff --git a/support/testing/tests/package/test_ghostscript.py b/support/testing/tests/package/test_ghostscript.py
new file mode 100644
index 0000000000..3c6c16ef2c
--- /dev/null
+++ b/support/testing/tests/package/test_ghostscript.py
@@ -0,0 +1,48 @@
+import os
+
+import infra.basetest
+
+
+class TestGhostscript(infra.basetest.BRTest):
+    rootfs_overlay = \
+        infra.filepath("tests/package/test_ghostscript/rootfs-overlay")
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        f"""
+        BR2_PACKAGE_GHOSTSCRIPT=y
+        BR2_PACKAGE_TESSERACT_OCR=y
+        BR2_PACKAGE_TESSERACT_OCR_LANG_ENG=y
+        BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        # Check the program can execute.
+        self.assertRunOk("gs --version")
+
+        doc_basename = "document"
+        ps_file = doc_basename + ".ps"
+        pgm_file = doc_basename + ".pgm"
+        txt_file = doc_basename + ".txt"
+
+        # Render a basic PostScript file to an image file.
+        cmd = "gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pgmraw -r150"
+        cmd += f" -dTextAlphaBits=4 -sOutputFile='{pgm_file}' {ps_file}"
+        self.assertRunOk(cmd)
+
+        # Run text recognition on the image file.
+        cmd = f"tesseract {pgm_file} {doc_basename}"
+        self.assertRunOk(cmd, timeout=30)
+
+        # Check we extracted the expected string from the input
+        # PostScript file.
+        cmd = f"cat {txt_file}"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[0], "Hello Buildroot!")
diff --git a/support/testing/tests/package/test_ghostscript/rootfs-overlay/root/document.ps b/support/testing/tests/package/test_ghostscript/rootfs-overlay/root/document.ps
new file mode 100644
index 0000000000..5ca2b3581f
--- /dev/null
+++ b/support/testing/tests/package/test_ghostscript/rootfs-overlay/root/document.ps
@@ -0,0 +1,9 @@
+%!PS
+% See: PostScript: Language Reference, third edition
+% Example 5.1, page 314
+% https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf
+/Helvetica findfont
+16 scalefont setfont
+54 720 moveto
+(Hello Buildroot!) show
+showpage
-- 
2.43.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH 1/1] support/testing: add ghostscript runtime test
  2024-02-09 19:29 [Buildroot] [PATCH 1/1] support/testing: add ghostscript runtime test Julien Olivain
@ 2024-02-11 21:48 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-02-11 21:48 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot

On Fri,  9 Feb 2024 20:29:23 +0100
Julien Olivain <ju.o@free.fr> wrote:

> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
>  DEVELOPERS                                    |  2 +
>  .../testing/tests/package/test_ghostscript.py | 48 +++++++++++++++++++
>  .../rootfs-overlay/root/document.ps           |  9 ++++
>  3 files changed, 59 insertions(+)
>  create mode 100644 support/testing/tests/package/test_ghostscript.py
>  create mode 100644 support/testing/tests/package/test_ghostscript/rootfs-overlay/root/document.ps

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-11 21:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-09 19:29 [Buildroot] [PATCH 1/1] support/testing: add ghostscript runtime test Julien Olivain
2024-02-11 21:48 ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox