From nobody Mon Feb 9 22:38:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.45 as permitted sender) client-ip=209.85.128.45; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f45.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.45 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1603277458; cv=none; d=zohomail.com; s=zohoarc; b=QpCgT+MfUa/5jZxEdXDqjMO2VsScmqKcEFH43Czjrlp+hwzAv7u5r2OqVuHqvu1U/hNIhrKLo34ga98FBhpub+OSeFHx6XneDj+ZSogtitMRM6w8bdVPSQ5dsxYecj8SLDWSXLFDybCtpruFvg6M8ENuCpe5GYygprl0CMcwayA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603277458; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u8MIW0fZuo8s+yk9Tsr3op5QbGANqrFw34tCgPBF3cw=; b=Fu/CT5U/jGPeBiVD1HtrN2r+QMOM9b6IvHeH2Zn/4skjvMxL3ngVklXhbGnYmKFsN4G/2GfqWfofYxvLXNkCnrXff8lLTIYaVc3sC3a3SPDBdk1ic1EGKFVD0FUyMIgWmmUBuT8WD2pzcuCCBi1J1f02014NKbjaabCwFbBJsF4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.45 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by mx.zohomail.com with SMTPS id 1603277458795750.1302185672854; Wed, 21 Oct 2020 03:50:58 -0700 (PDT) Received: by mail-wm1-f45.google.com with SMTP id 13so1377867wmf.0 for ; Wed, 21 Oct 2020 03:50:58 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id z6sm2781092wmi.28.2020.10.21.03.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 03:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u8MIW0fZuo8s+yk9Tsr3op5QbGANqrFw34tCgPBF3cw=; b=fSoX3I/r74xELcpRZ3OdZaYY+ZfCUTskrMBMgjWVe4FbwR/txGkVTyawTWQQ+vHKNE sBU0L5sSs0pfSJ70pK4frMRhldqv2Z7tXM9WPaoM+mz/tfY6bcD0m1nVIq+YHckx1gNJ FP8Tzo8xvRYGx29Ih/bbYAsCTYvE5YGeFOzhaa0kSZjskFdcCmcsWKn32Z/X6jYIMhSc WTsXhgxyKPJkLsoL3Px3FdmLCeV8+DsyGvq0S/0DTEr0H6b6cvzq+mR4YMuUWDvxrwg5 5zEFwzEe4fiVCPkJPtEilvh2QOIx9tKo51DZ7BB04JQyyxSsqw4GoT+qAN2qPs7qWOoz 6LBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=u8MIW0fZuo8s+yk9Tsr3op5QbGANqrFw34tCgPBF3cw=; b=nzCByT3Ys/ibvtloOBendeGG+GMB9T2r7oXP/IQqfr/KAkyGklbNAbOGNNycc7gluT sYUzX5kargV/MSzFAFJK1uBquHmFLx9v0NMpDN++SPbfYC/BQ7afV2O3PSeJqpLViB5L 2OX9+pe8P9EWsrGLBNB4rp1SnmYftYGCpPprWMHnca91PqO+3XAWFQ+gxH+S6f/vMF54 rc7qUWB6/k8+6/8IOZOnFDYTf/fYBh+Hi9kviD3NqkrAsTgD7A5nosxMoJJYOe3Cmi46 Sed3jKxmg/5hwvGLLmFupkPCHXdMCQKWVtMrP+Uau0ZSmaAZE2NP7mJXv20cq/5CmQDi hH4g== X-Gm-Message-State: AOAM531GrTKP0TB9SgugmMvZT/zfByv+xR7dWHEcsmsRLcsadwP1m4kA r6+40JyvKe2RIzY/zHF/Q5M= X-Google-Smtp-Source: ABdhPJw4WuLXr4fMv1GVowlFCqxkzdgn0xn2wi9PmCKKIJ7Wo0gIYde7vbK77YJLUEIvrk8XzROSRA== X-Received: by 2002:a7b:cb81:: with SMTP id m1mr3065574wmi.140.1603277457309; Wed, 21 Oct 2020 03:50:57 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Daniel P . Berrange" , Thomas Huth , Wainer dos Santos Moschetta , Huacai Chen , Jiaxun Yang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mark Cave-Ayland , Cleber Rosa Subject: [PATCH 4/6] tests/acceptance: Introduce tesseract_ocr() helper Date: Wed, 21 Oct 2020 12:50:33 +0200 Message-Id: <20201021105035.2477784-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201021105035.2477784-1-f4bug@amsat.org> References: <20201021105035.2477784-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) We are going to reuse the tesseract OCR code. Create a new tesseract_ocr() helper and use it. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/acceptance/machine_m68k_nextcube.py | 21 +++++---------------- tests/acceptance/tesseract_utils.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/tests/acceptance/machine_m68k_nextcube.py b/tests/acceptance/m= achine_m68k_nextcube.py index 3c7400c43e4..09e2745cc52 100644 --- a/tests/acceptance/machine_m68k_nextcube.py +++ b/tests/acceptance/machine_m68k_nextcube.py @@ -7,13 +7,11 @@ =20 import os import time -import logging =20 from avocado_qemu import Test from avocado import skipUnless -from avocado.utils import process =20 -from tesseract_utils import tesseract_available +from tesseract_utils import tesseract_available, tesseract_ocr =20 PIL_AVAILABLE =3D True try: @@ -61,12 +59,8 @@ def test_bootrom_framebuffer_size(self): def test_bootrom_framebuffer_ocr_with_tesseract_v3(self): screenshot_path =3D os.path.join(self.workdir, "dump.ppm") self.check_bootrom_framebuffer(screenshot_path) - - console_logger =3D logging.getLogger('console') - text =3D process.run("tesseract %s stdout" % screenshot_path).stdo= ut_text - for line in text.split('\n'): - if len(line): - console_logger.debug(line) + lines =3D tesseract_ocr(screenshot_path, tesseract_version=3D3) + text =3D '\n'.join(lines) self.assertIn('Backplane', text) self.assertIn('Ethernet address', text) =20 @@ -77,13 +71,8 @@ def test_bootrom_framebuffer_ocr_with_tesseract_v3(self): def test_bootrom_framebuffer_ocr_with_tesseract_v4(self): screenshot_path =3D os.path.join(self.workdir, "dump.ppm") self.check_bootrom_framebuffer(screenshot_path) - - console_logger =3D logging.getLogger('console') - proc =3D process.run("tesseract --oem 1 %s stdout" % screenshot_pa= th) - text =3D proc.stdout_text - for line in text.split('\n'): - if len(line): - console_logger.debug(line) + lines =3D tesseract_ocr(screenshot_path, tesseract_version=3D4) + text =3D '\n'.join(lines) self.assertIn('Testing the FPU, SCC', text) self.assertIn('System test failed. Error code', text) self.assertIn('Boot command', text) diff --git a/tests/acceptance/tesseract_utils.py b/tests/acceptance/tessera= ct_utils.py index acd6e8c2faa..72cd9ab7989 100644 --- a/tests/acceptance/tesseract_utils.py +++ b/tests/acceptance/tesseract_utils.py @@ -6,7 +6,9 @@ # later. See the COPYING file in the top-level directory. =20 import re +import logging =20 +from avocado.utils import process from avocado.utils.path import find_command, CmdNotFoundError =20 def tesseract_available(expected_version): @@ -26,3 +28,19 @@ def tesseract_available(expected_version): return False # now this is guaranteed to be a digit return int(match.groups()[0]) =3D=3D expected_version + + +def tesseract_ocr(image_path, tesseract_args=3D'', tesseract_version=3D3): + console_logger =3D logging.getLogger('tesseract') + console_logger.debug(image_path) + if tesseract_version =3D=3D 4: + tesseract_args +=3D ' --oem 1' + proc =3D process.run("tesseract {} {} stdout".format(tesseract_args, + image_path)) + lines =3D [] + for line in proc.stdout_text.split('\n'): + sline =3D line.strip() + if len(sline): + console_logger.debug(sline) + lines +=3D [sline] + return lines --=20 2.26.2