From patchwork Fri Jan 20 12:28:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 644643 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp751154pvb; Fri, 20 Jan 2023 04:31:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXsbzHNTWdCWC7BLE/6zineWBQBDTWSlb1xDNjlJzQsEvUAwf+XF9p0JnaNodtAkZ+CM+Yhy X-Received: by 2002:a05:6214:3909:b0:532:21f8:ea76 with SMTP id nh9-20020a056214390900b0053221f8ea76mr22694212qvb.44.1674217859873; Fri, 20 Jan 2023 04:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674217859; cv=none; d=google.com; s=arc-20160816; b=msXrD3RmsEyjqL64lH5cwuvfVzJOgzunV9LJSRmOa7ZoGlVHyzW8QE9+IK/JAP3+dP kHXfBJ0SLZnN4bYupw2PkoXaj7zxX5RE3WX3fqgovW3iUarjhywf1y5K2mczk0Q6xA2h zokIKgCPY9TtVZMDV0pTCXZI5eRKEPeSzOCdisNgBuYhhRe8pVkQPmqUNtjUYBnBXrj9 jHWU0JCl7qBhcFkdjcct8USFap5NRdtU9zRnvnUt7YtmQcOOz2ILF1bsXekBut+onYBI MX5dP7v15EaHbXgZayZeWSbPxZPEXu8SYQR6+XJc4DBMfO1HIySZJ7Pvdtsly9PcXc4Y DZTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y5K7GVk319HceZFwLFPBQxm2KAN+sqelChVQ5yqjTG4=; b=bCaukn/W8Fzh4u38WVyB4EDsbf5RJHWGL2DSDVK6Y2xCxtem5VS/FxIhm8MKoFKajP s0jNjxBFwCYzRZMtWMOcDXJo8mwRzyslPUvg2YU1tgoq0Lgq56f8FTU9aemZWgDtrtYY 0aN5pcXU9bKYJEjX8bXsbK4wHJOSLWclcCM0GZbY7p71i0dbnfV2yHPKp3W9KM5Lm0+n vTA+YxRQuvn/U1RFb8aTT+ewVYWWZN5mgq4X4YevE4gj7EvXAOi3+b9FK6MKLKjRkcNM QRUekktDHpgcF5IblGqISwdkzi+jHc+S0ZJZgYnxcnB0MCvJWEAHJJTLptRqbzCmpJsr 7GOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x2B8LUiw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jr14-20020a0562142a8e00b0053543310b03si4838489qvb.408.2023.01.20.04.30.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Jan 2023 04:30:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x2B8LUiw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIqVp-0001vX-QI; Fri, 20 Jan 2023 07:28:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIqVj-0001PO-3K for qemu-devel@nongnu.org; Fri, 20 Jan 2023 07:28:47 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pIqVh-0000hp-CZ for qemu-devel@nongnu.org; Fri, 20 Jan 2023 07:28:46 -0500 Received: by mail-wr1-x42f.google.com with SMTP id z5so4712842wrt.6 for ; Fri, 20 Jan 2023 04:28:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y5K7GVk319HceZFwLFPBQxm2KAN+sqelChVQ5yqjTG4=; b=x2B8LUiw2OU1kAfbDg55M2Oa9VuscQakN/yOnl34OC9zhLeFjNUFJTzUtjNqmfTpSg TQr+NZbUEEdFTV5o5FpTPxitmw+fS9q22QmUEIAosB2W2TIhjX7ZN6fEt4tKGfEFbPLW dWBSXNlAHmfymw7iisoECyMN0PB8pZE0uUwfGjXkzhDpPkJhvctA5Jk6Httb49XI5w04 w6q4WAX/Z6loBcU39gNoamDdN5KR67OgZ7iVku3K7lx2YL4wXmDUdxq3hltkekUlVCNg FgnQ4Y0a/iOp6FGTfOqTFjF4sYO9t5YAULCyja6vxXnz+Rvh/TaJaITGHRjgzNdXdQZg AdKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y5K7GVk319HceZFwLFPBQxm2KAN+sqelChVQ5yqjTG4=; b=M8SVLHXEI3prg+ikkU2Sm7jPJ1P/cBtFQDrT/3o4kCwseJtiqYua7GrfCw2PwqUH1B pF06YwJ5rCzSL4MtBFx8v4VPzYqe2BMY0vgx5bR6N2F+JIFqLwsEuR2mS5pX/iAh09qh Co/YFukdfm63AlV0IhXxWxeuGr+sOhhmxZGwW/VoCxredkIjoIX90G0aMAtrD/UoDxP3 A+bIl6mGccN0+DD1y1hZ1OYfveO++Rzyi//8YMRitx895SkDynSMr9o/e0TK+OmT1mhn 9TiNIw0RMMEi9OQEfj3M+qIVxJDQT79jwUfBv1nDmrYhjmfDIGq63CEvk9jwntuKzTtu EFZg== X-Gm-Message-State: AFqh2kqLDz7N+BJJyiTDBkQLzTcge4bhx0nLD7OKMe43IZZhDzNhtbQh cMXsWz/G7E82xVkDfwTMDn+blnmaUu0lh/SC X-Received: by 2002:adf:ffc3:0:b0:2bb:ede4:5dd4 with SMTP id x3-20020adfffc3000000b002bbede45dd4mr23298180wrs.34.1674217723825; Fri, 20 Jan 2023 04:28:43 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id l7-20020a5d6747000000b002b57bae7174sm36386286wrw.5.2023.01.20.04.28.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Jan 2023 04:28:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-arm@nongnu.org, Cleber Rosa , Beraldo Leal , Subbaraya Sundeep , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Wainer dos Santos Moschetta Subject: [PATCH 1/2] tests/avocado: Factor file_truncate() helper out Date: Fri, 20 Jan 2023 13:28:35 +0100 Message-Id: <20230120122836.81675-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230120122836.81675-1-philmd@linaro.org> References: <20230120122836.81675-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Factor file_truncate() helper out of image_pow2ceil_expand() for reuse. Signed-off-by: Philippe Mathieu-Daudé --- tests/avocado/boot_linux_console.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py index 8c1d981586..49a4b22fe1 100644 --- a/tests/avocado/boot_linux_console.py +++ b/tests/avocado/boot_linux_console.py @@ -30,15 +30,19 @@ def pow2ceil(x): return 1 if x == 0 else 2**(x - 1).bit_length() +""" +Truncate file +""" +def file_truncate(path, size): + if size != os.path.getsize(path): + with open(path, 'ab+') as fd: + fd.truncate(size) + """ Expand file size to next power of 2 """ def image_pow2ceil_expand(path): - size = os.path.getsize(path) - size_aligned = pow2ceil(size) - if size != size_aligned: - with open(path, 'ab+') as fd: - fd.truncate(size_aligned) + file_truncate(path, pow2ceil(size)) class LinuxKernelTest(QemuSystemTest): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '