summary refs log tree commit diff stats
path: root/tests/avocado/tesseract_utils.py
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2024-08-30 15:38:22 +0200
committerThomas Huth <thuth@redhat.com>2024-09-04 11:14:33 +0200
commit576fffbc8eefd806c47850f8e1c60fdcb37733e3 (patch)
treea2302ba894f02795a2217b655fda044d0e6543f7 /tests/avocado/tesseract_utils.py
parent88c907199aba4ff78985a5727fa56ec667a94cda (diff)
downloadfocaccia-qemu-576fffbc8eefd806c47850f8e1c60fdcb37733e3.tar.gz
focaccia-qemu-576fffbc8eefd806c47850f8e1c60fdcb37733e3.zip
tests/functional: Convert the m68k nextcube test with tesseract
The code that handles running of tesseract needs to be tweaked a little
bit to be able to run without the functions from avocado.utils, and
while we're at it, drop some legacy stuff that was still there due to
Tesseract 3 support that we already dropped a while ago.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240830133841.142644-29-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/avocado/tesseract_utils.py')
-rw-r--r--tests/avocado/tesseract_utils.py46
1 files changed, 0 insertions, 46 deletions
diff --git a/tests/avocado/tesseract_utils.py b/tests/avocado/tesseract_utils.py
deleted file mode 100644
index 476f528147..0000000000
--- a/tests/avocado/tesseract_utils.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# ...
-#
-# Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
-#
-# This work is licensed under the terms of the GNU GPL, version 2 or
-# later. See the COPYING file in the top-level directory.
-
-import re
-import logging
-
-from avocado.utils import process
-from avocado.utils.path import find_command, CmdNotFoundError
-
-def tesseract_available(expected_version):
-    try:
-        find_command('tesseract')
-    except CmdNotFoundError:
-        return False
-    res = process.run('tesseract --version')
-    try:
-        version = res.stdout_text.split()[1]
-    except IndexError:
-        version = res.stderr_text.split()[1]
-    return int(version.split('.')[0]) >= expected_version
-
-    match = re.match(r'tesseract\s(\d)', res)
-    if match is None:
-        return False
-    # now this is guaranteed to be a digit
-    return int(match.groups()[0]) >= expected_version
-
-
-def tesseract_ocr(image_path, tesseract_args='', tesseract_version=3):
-    console_logger = logging.getLogger('tesseract')
-    console_logger.debug(image_path)
-    if tesseract_version == 4:
-        tesseract_args += ' --oem 1'
-    proc = process.run("tesseract {} {} stdout".format(tesseract_args,
-                                                       image_path))
-    lines = []
-    for line in proc.stdout_text.split('\n'):
-        sline = line.strip()
-        if len(sline):
-            console_logger.debug(sline)
-            lines += [sline]
-    return lines