From nobody Mon Feb 9 20:32:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.46 as permitted sender) client-ip=209.85.128.46; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f46.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1603277454; cv=none; d=zohomail.com; s=zohoarc; b=C9i2SvyUq8oG/wk14j3oGr+shezuwaSRHD9GCYPoGAsMVeim1K90pYYvDhzh3Q4080/hvmOZUh4+Oeq6Emd3gyamGY4XQCvRWy05g/nMZcAfw5rLIkZ0gkjCkKMsLcW+M2lP1yCOeU2Pq88/ZBRNF1YZ/3UYXJc/OuC3jpLH8ZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603277454; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HDkuFBTSf9PfxMFUSQsII/3TQvG3KWBBsCKA4dEtXq0=; b=IfGDAHs1r6pwOj/7BwkWyw/FnPKlQjNjUOs1n6j8XQVkw2l35P4hosWWDyZchkRD4zsBvwdrd84yCf+z40ktLOEdwDpROpD+D3qLmGdzamUPUV+/IxoWX6XIoWMsRbD6wJwYYdzgCtq8cRkoF8H87ZbGFbilgkOwNYpr9p1lk5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mx.zohomail.com with SMTPS id 160327745399716.743534475690808; Wed, 21 Oct 2020 03:50:53 -0700 (PDT) Received: by mail-wm1-f46.google.com with SMTP id d78so1374352wmd.3 for ; Wed, 21 Oct 2020 03:50:53 -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 x65sm3079700wmg.1.2020.10.21.03.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 03:50:51 -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=HDkuFBTSf9PfxMFUSQsII/3TQvG3KWBBsCKA4dEtXq0=; b=bK5GYPDt7cantE00Sw1249BE4KvqtYpbDr/Sxxt37k1cYqjeoedUB9/p/VtP/1D/KI m3E0hXW/+KVxc2P/tN97AlUpI6+1yTl8tLlF9+yOQQcisHdqhqAdi6QM4BVVaZixINIp jwTtaBGqKy970mkL+1ibPoNXAesw2opNEyqpazTtjET4JHgAFRViNRlyuP9nFbkz7Wik u7twqUTVs834DOPVD2MA5034WsZCG7105beHpA0ROkiIDfEVKBObR7kMTZTYPaE2W6Us uq/S1s+0Haoi+7YiCj9gOzI9Pt8ZAt7eewDcy6hdbiSb9QpLraHRSCcMw81493gXcZr/ 8DuA== 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=HDkuFBTSf9PfxMFUSQsII/3TQvG3KWBBsCKA4dEtXq0=; b=o/2nWgiXHviPEJX2kzo1Iv5ih5lL0vZw81L4TYY0K06Pzhtr6oIpkx/CluNpQXFwZY 0mmSduYklbQtCXfx8NChpgNOWw0sUvnlD2G90RhD0GDy/Vl4sHaya3Wb/oickae2OTag QZtxC3IaOgPakhE0yT1SHb9pWZXvheLSjj7u9jGaP6FBxU9Vslt8tSDF0OJXFLKzvsUm +qPfswh6eSdd6zYx6oDHuqwz0R1IRtxoRw+CEnPH8LZ9Q7RmcKWL7xe/jSkKd1Nh5AJt oEYTdHLfuNvqydmQDvD7GxbLlaDH4EXMkQ9oc2KQf9nHbXh3fvMU+Jonf1rXBdEp0A3p HwXw== X-Gm-Message-State: AOAM533DqoOQftL7tegOLRyW91jsiOQUStOpLZl0/t+RG/9ByNtd5GAR ZHvMJE6REKxzTcjn2RDTiDg= X-Google-Smtp-Source: ABdhPJx5HxH9RBzULE6fqH/E7B8THu1Q/w0fZwryntr0toSwRMSG3bwXy1kqIBv6rjpDEHop8wuKjg== X-Received: by 2002:a1c:4856:: with SMTP id v83mr2948606wma.118.1603277452507; Wed, 21 Oct 2020 03:50:52 -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 3/6] tests/acceptance: Extract tesseract_available() helper in new namespace Date: Wed, 21 Oct 2020 12:50:32 +0200 Message-Id: <20201021105035.2477784-4-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 tesseract_available(). Extract it to a new 'tesseract_utils' namespace. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- tests/acceptance/machine_m68k_nextcube.py | 25 +++----------------- tests/acceptance/tesseract_utils.py | 28 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 tests/acceptance/tesseract_utils.py diff --git a/tests/acceptance/machine_m68k_nextcube.py b/tests/acceptance/m= achine_m68k_nextcube.py index 2baba5fdc26..3c7400c43e4 100644 --- a/tests/acceptance/machine_m68k_nextcube.py +++ b/tests/acceptance/machine_m68k_nextcube.py @@ -1,19 +1,19 @@ # Functional test that boots a VM and run OCR on the framebuffer # -# Copyright (c) Philippe Mathieu-Daud=C3=A9 +# Copyright (c) 2019 Philippe Mathieu-Daud=C3=A9 # # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. =20 import os -import re import time import logging =20 from avocado_qemu import Test from avocado import skipUnless from avocado.utils import process -from avocado.utils.path import find_command, CmdNotFoundError + +from tesseract_utils import tesseract_available =20 PIL_AVAILABLE =3D True try: @@ -22,25 +22,6 @@ PIL_AVAILABLE =3D False =20 =20 -def tesseract_available(expected_version): - try: - find_command('tesseract') - except CmdNotFoundError: - return False - res =3D process.run('tesseract --version') - try: - version =3D res.stdout_text.split()[1] - except IndexError: - version =3D res.stderr_text.split()[1] - return int(version.split('.')[0]) =3D=3D expected_version - - match =3D 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]) =3D=3D expected_version - - class NextCubeMachine(Test): """ :avocado: tags=3Darch:m68k diff --git a/tests/acceptance/tesseract_utils.py b/tests/acceptance/tessera= ct_utils.py new file mode 100644 index 00000000000..acd6e8c2faa --- /dev/null +++ b/tests/acceptance/tesseract_utils.py @@ -0,0 +1,28 @@ +# ... +# +# Copyright (c) 2019 Philippe Mathieu-Daud=C3=A9 +# +# 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 + +from avocado.utils.path import find_command, CmdNotFoundError + +def tesseract_available(expected_version): + try: + find_command('tesseract') + except CmdNotFoundError: + return False + res =3D process.run('tesseract --version') + try: + version =3D res.stdout_text.split()[1] + except IndexError: + version =3D res.stderr_text.split()[1] + return int(version.split('.')[0]) =3D=3D expected_version + + match =3D 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]) =3D=3D expected_version --=20 2.26.2