From patchwork Fri May 27 15:35:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 576482 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:8607:0:0:0:0 with SMTP id bb7csp751383mab; Fri, 27 May 2022 08:46:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPTjcrRo2buwrTleH9Es+UltmcRfZrczW6btYxcxrEqpiqKmuidiJn5viCTCllxfdzAvzW X-Received: by 2002:ac8:58cd:0:b0:2f9:3b39:6255 with SMTP id u13-20020ac858cd000000b002f93b396255mr18692897qta.39.1653666392682; Fri, 27 May 2022 08:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653666392; cv=none; d=google.com; s=arc-20160816; b=rRbSAKdou9aYwvb+gsXp6uBnb+oUskBo525mZQxKBFixm1XzJonL/5LroUQbg4vVGd qquPXLPj2ys/N3hd/IZCXMo/RwRXF6GoJyp9MvLOZqJsfsxP7bXDB0K8ZbPn8JFmgwPl eLyurciLvuPazRvsK2BMvOBLi7pveMGfdrl3cmENU0P7rHgoYd9JZT99FcfHpBwKmGDu TAHVw0jc7RGcgk8uQPQZNa0LHvV/lxublh7Jb0XLJSVNM5Ztar/oP1WX3OYGtp32oksW P/TNt2vOUis31ecI3ZSZhXF66hCuaOPwvijCc9uZTtFA+pfdnLIgoEVejAdQ9FZ0Y0Ca F9Gw== 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=mlFf5+cAO5/IMX6mjeJdfBCz2OpTu8g+EZZGQA1K/6E=; b=yL7og9NycwEVRPQYbQ0FtgQ7pakxe7yUVbiVBm/zgG6L3ARsy7tS+f0wg6XoAzWAwq C8KK3WgkEPSeWQJNTBnkyrQ7MnOtLG/BI2LiOBkoatjvOnbHueCLUM76AEMUP1XVXLOn h0Vi4Yo4tUA1BR8PwCGOHM6woPkNE5L2Gp5PGOseeiTog1CXV7TecS6a7qSl6B0mhnqq uSbBm45+42bawPeCaR6kUpRduC1H5I24tk5jEX0cCVbRPhAfWxXMlelA/Y47Lu1Cjj7c iWsd+3meRH9+xOUMYxfTUJYOEDDDTOVRkdrB/Fg2luDQzB3r7Fzc6T4ug7feVR0pFusk NL/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zu7KqvAn; 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 q12-20020ad4574c000000b00461e45d4b47si2962482qvx.293.2022.05.27.08.46.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 May 2022 08:46:32 -0700 (PDT) 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=Zu7KqvAn; 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]:55976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nucAY-00051p-0b for patch@linaro.org; Fri, 27 May 2022 11:46:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuc0f-0000PN-Gt for qemu-devel@nongnu.org; Fri, 27 May 2022 11:36:18 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:45725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nuc0c-0002PB-VG for qemu-devel@nongnu.org; Fri, 27 May 2022 11:36:17 -0400 Received: by mail-ej1-x62a.google.com with SMTP id jx22so9411759ejb.12 for ; Fri, 27 May 2022 08:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mlFf5+cAO5/IMX6mjeJdfBCz2OpTu8g+EZZGQA1K/6E=; b=Zu7KqvAnZGuk88o0oSEZMrNwHh5u9TnDxRAM+J82xZMZCckMvBLuQ23S69b0D1tewS Z810rBMMmlp+cBotjusj5YIi+eNf2rq9NTSddBLUEC78aTFQDNFnGXoRZbcbWbwkm1pF LSQ/w58xm8oRGmJ0QRgHLDKIZMI4oaK6fl1y0lvnY9l4IRryQWwBxsR4CLzgu1cKjB3B auI9KuOS+WdmrzQJr5m/HEQRWOePrMxeOXv22/DRw8WOxVUOJ955+qiZeaVYzy4x+X1n O0Lrkqt7NDSFqSugHMu5CA6DjIWD/pze9W6BqjLHXrjHpL3+MN4e9vJd/qTSdRvOUCN6 KjQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mlFf5+cAO5/IMX6mjeJdfBCz2OpTu8g+EZZGQA1K/6E=; b=iV0Uwz1ClRlYo2n++EEv5zKAWHW1tFcqLkaIwi9whMapfhk3pCS4eJ9jGcjaChC6S9 t8sXdTceIS52DW4ZHggeDzvorPFATrxL4SYq7Sru5uob2v50PvbQJDN+/3USr1CAGrlc pQPJozP/TKR6d2lpzXEVyxx6UA3eVwCXfHi7MsRcCUe9Mko5FSM2V8ZKCZ4uuHc036sq tkzhiSFRpX1Ddn34PlGgmWP6sIcHvP4SlZae61JuHQQwdCCquzR3m6rKOl9R8DBIHXtm /Ij7u12pKaokUrzasH/FgOEWQUACLaf5mXn2jCIPkoR1gKo4U2ZkAHQvnyqvgDnDv1mD jYqw== X-Gm-Message-State: AOAM5329HWe3/1aJERP9o06ViOAhrS3nPxfonWxsE3BB9txGenJfEvFg NK65vd+Fdz2iX5USWiP+V7v3Cg== X-Received: by 2002:a17:906:99c2:b0:6f4:a99c:8dfc with SMTP id s2-20020a17090699c200b006f4a99c8dfcmr42074310ejn.386.1653665774224; Fri, 27 May 2022 08:36:14 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r25-20020a50aad9000000b0042bda1327ddsm2216304edc.73.2022.05.27.08.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 May 2022 08:36:08 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 189F91FFBD; Fri, 27 May 2022 16:36:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: fam@euphon.net, berrange@redhat.com, f4bug@amsat.org, aurelien@aurel32.net, pbonzini@redhat.com, stefanha@redhat.com, crosa@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Wainer dos Santos Moschetta , Beraldo Leal Subject: [PATCH v1 05/33] tests/lcitool: fix up indentation to correct style Date: Fri, 27 May 2022 16:35:35 +0100 Message-Id: <20220527153603.887929-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527153603.887929-1-alex.bennee@linaro.org> References: <20220527153603.887929-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62a.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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" 3 space indentation snuck into the initial commit. Clean it up before we let it get established. I've also: - removed unused os import - added double lines between functions - added some comments and grouped and sorted the generation stanzas My lint tool is also recommending using f-strings but that requires python 3.6. Signed-off-by: Alex Bennée Cc: Daniel P. Berrangé Reviewed-by: Daniel P. Berrangé --- tests/lcitool/refresh | 134 ++++++++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 58 deletions(-) diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh index fb49bbc441..dc1fc21ef9 100755 --- a/tests/lcitool/refresh +++ b/tests/lcitool/refresh @@ -13,14 +13,13 @@ # the top-level directory. import sys -import os import subprocess from pathlib import Path if len(sys.argv) != 1: - print("syntax: %s" % sys.argv[0], file=sys.stderr) - sys.exit(1) + print("syntax: %s" % sys.argv[0], file=sys.stderr) + sys.exit(1) self_dir = Path(__file__).parent src_dir = self_dir.parent.parent @@ -30,76 +29,95 @@ lcitool_path = Path(self_dir, "libvirt-ci", "lcitool") lcitool_cmd = [lcitool_path, "--data-dir", self_dir] + def atomic_write(filename, content): - tmp = filename.with_suffix(filename.suffix + ".tmp") - try: - with tmp.open("w") as fp: - print(content, file=fp, end="") - tmp.rename(filename) - except Exception as ex: - tmp.unlink() - raise + tmp = filename.with_suffix(filename.suffix + ".tmp") + try: + with tmp.open("w") as fp: + print(content, file=fp, end="") + tmp.rename(filename) + except Exception as ex: + tmp.unlink() + raise + def generate(filename, cmd, trailer): - print("Generate %s" % filename) - lcitool=subprocess.run(cmd, capture_output=True) + print("Generate %s" % filename) + lcitool = subprocess.run(cmd, capture_output=True) - if lcitool.returncode != 0: - raise Exception("Failed to generate %s: %s" % (filename, lcitool.stderr)) + if lcitool.returncode != 0: + raise Exception("Failed to generate %s: %s" % (filename, lcitool.stderr)) + + content = lcitool.stdout.decode("utf8") + if trailer is not None: + content += trailer + atomic_write(filename, content) - content = lcitool.stdout.decode("utf8") - if trailer is not None: - content += trailer - atomic_write(filename, content) def generate_dockerfile(host, target, cross=None, trailer=None): - filename = Path(src_dir, "tests", "docker", "dockerfiles", host + ".docker") - cmd = lcitool_cmd + ["dockerfile"] - if cross is not None: - cmd.extend(["--cross", cross]) - cmd.extend([target, "qemu"]) - generate(filename, cmd, trailer) + filename = Path(src_dir, "tests", "docker", "dockerfiles", host + ".docker") + cmd = lcitool_cmd + ["dockerfile"] + if cross is not None: + cmd.extend(["--cross", cross]) + cmd.extend([target, "qemu"]) + generate(filename, cmd, trailer) + def generate_cirrus(target, trailer=None): - filename = Path(src_dir, ".gitlab-ci.d", "cirrus", target + ".vars") - cmd = lcitool_cmd + ["variables", target, "qemu"] - generate(filename, cmd, trailer) + filename = Path(src_dir, ".gitlab-ci.d", "cirrus", target + ".vars") + cmd = lcitool_cmd + ["variables", target, "qemu"] + generate(filename, cmd, trailer) + ubuntu2004_tsanhack = [ - "# Apply patch https://reviews.llvm.org/D75820\n", - "# This is required for TSan in clang-10 to compile with QEMU.\n", - "RUN sed -i 's/^const/static const/g' /usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h\n" + "# Apply patch https://reviews.llvm.org/D75820\n", + "# This is required for TSan in clang-10 to compile with QEMU.\n", + "RUN sed -i 's/^const/static const/g' /usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h\n" ] + def debian_cross_build(prefix, targets): - conf = "ENV QEMU_CONFIGURE_OPTS --cross-prefix=%s\n" % (prefix) - targets = "ENV DEF_TARGET_LIST %s\n" % (targets) - return "".join([conf, targets]) + conf = "ENV QEMU_CONFIGURE_OPTS --cross-prefix=%s\n" % (prefix) + targets = "ENV DEF_TARGET_LIST %s\n" % (targets) + return "".join([conf, targets]) +# +# Update all the various build configurations. +# Please keep each group sorted alphabetically for easy reading. +# try: - generate_dockerfile("centos8", "centos-stream-8") - generate_dockerfile("fedora", "fedora-35") - generate_dockerfile("ubuntu2004", "ubuntu-2004", - trailer="".join(ubuntu2004_tsanhack)) - generate_dockerfile("opensuse-leap", "opensuse-leap-152") - generate_dockerfile("alpine", "alpine-edge") - - generate_dockerfile("debian-arm64-cross", "debian-11", - cross="aarch64", - trailer=debian_cross_build("aarch64-linux-gnu-", - "aarch64-softmmu,aarch64-linux-user")) - - generate_dockerfile("debian-s390x-cross", "debian-11", - cross="s390x", - trailer=debian_cross_build("s390x-linux-gnu-", - "s390x-softmmu,s390x-linux-user")) - - generate_cirrus("freebsd-12") - generate_cirrus("freebsd-13") - generate_cirrus("macos-11") - - sys.exit(0) + # + # Standard native builds + # + generate_dockerfile("alpine", "alpine-edge") + generate_dockerfile("centos8", "centos-stream-8") + generate_dockerfile("fedora", "fedora-35") + generate_dockerfile("opensuse-leap", "opensuse-leap-152") + generate_dockerfile("ubuntu2004", "ubuntu-2004", + trailer="".join(ubuntu2004_tsanhack)) + + # + # Cross compiling builds + # + generate_dockerfile("debian-arm64-cross", "debian-11", + cross="aarch64", + trailer=debian_cross_build("aarch64-linux-gnu-", + "aarch64-softmmu,aarch64-linux-user")) + + generate_dockerfile("debian-s390x-cross", "debian-11", + cross="s390x", + trailer=debian_cross_build("s390x-linux-gnu-", + "s390x-softmmu,s390x-linux-user")) + + # + # Cirrus packages lists for GitLab + # + generate_cirrus("freebsd-12") + generate_cirrus("freebsd-13") + generate_cirrus("macos-11") + + sys.exit(0) except Exception as ex: - print(str(ex), file=sys.stderr) - sys.exit(1) + print(str(ex), file=sys.stderr) + sys.exit(1)