From patchwork Fri Jan 20 13:43:13 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: 644647 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp787867pvb; Fri, 20 Jan 2023 05:44:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9wk0Ch8bxyA6FswAEeCjZgGSzQLvPDJ7/dMx/koG0FHlLhHvhQyWGJ1Bx1mThu/Yc2/UK X-Received: by 2002:ac8:4710:0:b0:3a4:f758:fc6d with SMTP id f16-20020ac84710000000b003a4f758fc6dmr23117808qtp.46.1674222257732; Fri, 20 Jan 2023 05:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674222257; cv=none; d=google.com; s=arc-20160816; b=QWHh09njaOxE/5KPdBUc8IF8EuyZb/M/rRKyA9r1nKNKy18IrTZ2ud1zzIMva8Y0BW GRhKsoTngcVNmTX699PDWEqsmNaHRMp27jQIAt/9ZRrf8UnLafxsQ4db75e/Ql/pKKU+ CAElxM4CV7uIf5eEIJdec4kvajS6xwEc17MdwyUzBTGYfYtOusHYmqYvlLoHLXaFd6GC 1PvscEVGk7fjjrf6nxsj0w7F6Xt1Xgj2NJhvxGJ2LG1koyEV0tDsJII2zbtALPgbBIxt C0eNYUOw43sltxRlVomTsg/7LnzePZKXEFvGl7AN14idUUCDZikfWWFCf9qFZ96TeC1q Nl1g== 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=UNHd8/T89f0TRHea37adZgQvQ+f5+hWer7661K7hDXI=; b=m4GgQMNB0amiKMJT916dHfTbrAiR38L/MAFlHZH9J1mXzX1glM6pb35wP8CSWGCbKY 5FzhPAjRgr/yIWoKZrEcCmg7sUzAijwWKe+dFQAHJvZEAAdNOiLr24cs20XUO0j3cd72 FIHOYil0UHHTQvZkSiXlKjdFDKH5P0ljPjDJ9Mro5SOh3/0isBE2uZ//a3ApPmAIjx8e nFD5cshvjm6u+CvZFIxoouZCWaeeoeEkTuSQn3ZdVwP7QKEgk9nuQvQl6CVVxhdMYMyE LJdkQPddoNnunOINxz/1tjCqfomZ6MZN+ccG7x2vSyOrq/am8ie8uByTdLN6oZxq/RuE DX1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qHk0TYqX; 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 k20-20020ac86054000000b003b469bc8761si11346270qtm.540.2023.01.20.05.44.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Jan 2023 05:44:17 -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=qHk0TYqX; 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 1pIrfy-00013a-3Y; Fri, 20 Jan 2023 08:43:26 -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 1pIrfw-000138-Bo for qemu-devel@nongnu.org; Fri, 20 Jan 2023 08:43:24 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pIrfu-0007Wx-SL for qemu-devel@nongnu.org; Fri, 20 Jan 2023 08:43:24 -0500 Received: by mail-wm1-x32a.google.com with SMTP id g10so4114050wmo.1 for ; Fri, 20 Jan 2023 05:43:22 -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=UNHd8/T89f0TRHea37adZgQvQ+f5+hWer7661K7hDXI=; b=qHk0TYqXYGW8iALXaE11M3MlMIxhkCjmG4yJZismQtXQG97rzmhRqZ5r0GoMLNgsZ7 CN1qJ8bGYYWss5i1LGDomJnR+6JsKMZkqPzHOSqeAtLFWcLmHZA7akjkYXE4sqWhCqwt IdQ5sCwaQgWNmhy4XkOLQlXbU2mMvKczMjhJasZfEjXQhivjGnnALEgMqZZPrQD84rLD QBao2M9nkpE5JhiLb/vFWzUddlmrJ2/gN5Blhn9fMGz4SbOUh+NKA2hAVXREQujAiH3m bJx4SII0RkieQnjQAFpZHUOWB3zdMJ8lU78T78YQMUpCj82hSpkjIGrBIKVP6X6bWp7y Bs7Q== 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=UNHd8/T89f0TRHea37adZgQvQ+f5+hWer7661K7hDXI=; b=6MRDE6uWpaNNkUdxXYOvf4oJrCcziAh32/Da135BtyYi7LkhkXO7HaQxbY8ltn1t8s VVXFrZThZn6nPaC7FM9cTylNkSTeyjaktXLb/mUx6xV9mpgi0bQ4gLIHC2w0WGAkoRdK +FXFrnCfPK9rslVbIhPFbJclprH46FPmFpCX8rj9ouy2Qf8QLWEi+Y7qvZE4ahq3Lgcm hsc353ZPo6gK+9j1Lw5mQF+Ll4/qhDs01Gq8LB1gwJBhCUMHpSupQvZvdc17g4BkIc06 s2W/miVyhJ6g/VAmaIy7L/LWaqElIocuGUNL7gjFD7WE8pI9t9yyRQwsGYhvWehdA4jJ x1gQ== X-Gm-Message-State: AFqh2kriXkRtT207ld8l6pr1XLtcPo5Y3VWTRTgH8WfD8f3ldXbynbDy w1A0oT/XeWxs8w4CEd4p9ysiZQg1wd4O7MzK X-Received: by 2002:a05:600c:1712:b0:3d9:a145:91a with SMTP id c18-20020a05600c171200b003d9a145091amr14158241wmn.28.1674222201108; Fri, 20 Jan 2023 05:43:21 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id h13-20020a05600c2cad00b003cfa622a18asm2691725wmc.3.2023.01.20.05.43.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Jan 2023 05:43:20 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Beraldo Leal , Wainer dos Santos Moschetta , =?utf-8?q?Philippe_Mathi?= =?utf-8?q?eu-Daud=C3=A9?= , qemu-arm@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Cleber Rosa , Peter Maydell , Subbaraya Sundeep Subject: [PATCH v2 1/2] tests/avocado: Factor file_truncate() helper out Date: Fri, 20 Jan 2023 14:43:13 +0100 Message-Id: <20230120134314.81956-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230120134314.81956-1-philmd@linaro.org> References: <20230120134314.81956-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py index 8c1d981586..8a598be966 100644 --- a/tests/avocado/boot_linux_console.py +++ b/tests/avocado/boot_linux_console.py @@ -30,15 +30,16 @@ def pow2ceil(x): return 1 if x == 0 else 2**(x - 1).bit_length() +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) +def image_pow2ceil_expand(path, size): + file_truncate(path, pow2ceil(size)) class LinuxKernelTest(QemuSystemTest): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '