From patchwork Wed May 1 11:29:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1930120 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=OHAVo4gv; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fKW/5i2r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VTvxt1D11z1ydT for ; Wed, 1 May 2024 21:30:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4havk5PN36AuNwgFgcQ5+/CM/BvhRnG8IKzTsdv3RJo=; b=OHAVo4gviFN/iu QOA0uukXdn9SDBlqXdEV5ByTcZM928toBDWMN7LCSqVt3yGI5F0ObARRr27RVdB3LvsU8jol/ou/7 nOp+Qvn46nua9xeUC0o20F4HD792NUIZStPa6QA2x9hU1vZUJFG8lXmve5XgK/ncODx0mcW9aoWVN oWBUq8HEJqopnQbfiV9uOSg4ehnig4XX5+Wnm+Bb1WqJm5grAdphUa4HyV2SVfEzvuNdsCsiWOBHG XgSJJ1k2TxarT/0tUBrko1lIT03OZRtqBYWPHqF5nvpFIzf9xElvydThzrKW4uDYKEZ/whMlA07Rb ag1dbrxdZoTK26zbW1rA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s28AK-00000009CoL-1uuL; Wed, 01 May 2024 11:30:24 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s28AH-00000009CkP-3Kpm for kvm-riscv@lists.infradead.org; Wed, 01 May 2024 11:30:23 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e86d56b3bcso61113435ad.1 for ; Wed, 01 May 2024 04:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714563015; x=1715167815; darn=lists.infradead.org; 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=qEezwiCyGwOZD1+v35KdQzu2KwTw4n21wPX8WyrxUmo=; b=fKW/5i2rnSKwwqJD9jsp5eVeCTw4qULMoPDcioHsp7eDD0F4DdREov9DdFVPYPRrDq osQ3Z4R4H7nZ9/0M5J0oIkULTG8/jo4efXyWfjdkZiOfgKJj3q1f3ghPzJniHdb5wv5u IG+vjugRpJTVaCUOhUtZpVgcV5qYs7FJNnkgCI1S1u6J5FDN8gsPx0rCAa5ilWo+Yghu tApEdRe/gUVXAK4eQC1/9ffR+ZMHHQ9dyNm1zm3kJZ/55N8JotYOPb1oT6fhbzpTAywi ilzUWiWyksk3xfW8WT8OottltWDYhCrqvckfnuj3j02gTGZLfQYOeeqHBHHKxD/b0hh7 Uk0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714563015; x=1715167815; 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=qEezwiCyGwOZD1+v35KdQzu2KwTw4n21wPX8WyrxUmo=; b=jWddT09XLN42C6LRMTmftiP21v0XvUkrYDEQOR0ROFxiTM2jh6CvqDB16d+FWh5SO6 d0/EJp9cPSXR+d07QO8Gu1TFQ8TaM/kTNbg1FVMz7tgULrWkuZSJR+30xRKJRlOdaxO5 Bl/TGiPeCHkBqVYXN4QtssKknoJNh9GZ8QkJjTd+zSkMiNMuconqS0EX8bdoHyqHH2lH /M/Heg+ORJOdqIVd87pfo089/IJxLAQu7nTPWMEeX3resMWTPBWUcfIZdTePtScfxdvd 1UBatbGNgv+/V0v8yqKwYPSwH666y2PNmjka3U33mV6xP1jLD+rLRtzJKmZNLyHzZ5Jv wYzA== X-Forwarded-Encrypted: i=1; AJvYcCVRfsd8I/99F2oZB4xKJm1FM/p94/IKV99PFSYUrRWv1CbWOgJ8bhECyobqzlcFSLLPq4TCc05qDYEK3deUDgiYFRNn+5YnU7yE4F1J+g== X-Gm-Message-State: AOJu0YyqPo6adZ56kIhKHtRoMQkbos0EKk4c4cYonNAzERVB8iWG2ATP Dt1/5578f6j4NFWbDFhnN5laWnub8+KzwyGXK1UK/AMikwuQvswp X-Google-Smtp-Source: AGHT+IEFPYODr4TyreDdFCG6z01houFeGcrnNZN3iQCpjD0ek1ej4HVV0Wcok3E4Ojsg5zSqMK/UaA== X-Received: by 2002:a17:902:a383:b0:1e2:96d3:1bc1 with SMTP id x3-20020a170902a38300b001e296d31bc1mr2081748pla.1.1714563014788; Wed, 01 May 2024 04:30:14 -0700 (PDT) Received: from wheely.local0.net ([1.146.40.196]) by smtp.gmail.com with ESMTPSA id y22-20020a17090264d600b001ec64b128dasm2267150pli.129.2024.05.01.04.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 04:30:14 -0700 (PDT) From: Nicholas Piggin To: Andrew Jones Cc: Nicholas Piggin , Paolo Bonzini , Thomas Huth , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , =?utf-8?q?Nico_B=C3=B6hr?= , David Hildenbrand , Shaoqin Huang , Nikos Nikoleris , David Woodhouse , Ricardo Koller , rminmin , Gavin Shan , Nina Schoetterl-Glausch , Sean Christopherson , kvm@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH v3 1/5] Add initial shellcheck checking Date: Wed, 1 May 2024 21:29:30 +1000 Message-ID: <20240501112938.931452-2-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240501112938.931452-1-npiggin@gmail.com> References: <20240501112938.931452-1-npiggin@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_043021_857760_EFB29FA6 X-CRM114-Status: GOOD ( 18.77 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This adds a basic shellcheck style file, some directives to help find scripts, and a make shellcheck target. When changes settle down this could be made part of the standard build / CI flow. Suggested-by: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Nicholas Piggin --- .shellcheckrc | 30 ++++++++++++++++++++++++++++++ Makefile | 4 ++++ README.md | 3 +++ scripts/common.bash [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:62d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [npiggin(at)gmail.com] X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This adds a basic shellcheck style file, some directives to help find scripts, and a make shellcheck target. When changes settle down this could be made part of the standard build / CI flow. Suggested-by: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Nicholas Piggin --- .shellcheckrc | 30 ++++++++++++++++++++++++++++++ Makefile | 4 ++++ README.md | 3 +++ scripts/common.bash | 5 ++++- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .shellcheckrc diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 000000000..491af18bd --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,30 @@ +# shellcheck configuration file +external-sources=true + +# Optional extras -- https://www.shellcheck.net/wiki/Optional +# Possibilities, e.g., - +# quote‐safe‐variables +# require-double-brackets +# require-variable-braces +# add-default-case + +# Disable SC2004 style? I.e., +# In run_tests.sh line 67: +# if (( $unittest_run_queues <= 0 )); then +# ^------------------^ SC2004 (style): $/${} is unnecessary on arithmetic variables. +disable=SC2004 + +# Disable SC2086 for now, double quote to prevent globbing and word +# splitting. There are lots of places that use it for word splitting +# (e.g., invoking commands with arguments) that break. Should have a +# more consistent approach for this (perhaps use arrays for such cases) +# but for now disable. +# SC2086 (info): Double quote to prevent globbing and word splitting. +disable=SC2086 + +# Disable SC2235. Most developers are used to seeing expressions +# like a || (b && c), not a || { b && c ; }. The subshell overhead in +# kvm-unit-tests is negligible as it's not shell-heavy in the first +# place (time is dominated by qemu startup/shutdown and test execution) +# SC2235 (style): Use { ..; } instead of (..) to avoid subshell overhead. +disable=SC2235 diff --git a/Makefile b/Makefile index 4f35fffc6..6240d8dfa 100644 --- a/Makefile +++ b/Makefile @@ -141,6 +141,10 @@ cscope: -name '*.[chsS]' -exec realpath --relative-base=$(CURDIR) {} \; | sort -u > ./cscope.files cscope -bk +.PHONY: shellcheck +shellcheck: + shellcheck -a run_tests.sh */run */efi/run scripts/mkstandalone.sh + .PHONY: tags tags: ctags -R diff --git a/README.md b/README.md index 6e82dc225..2d6f7db56 100644 --- a/README.md +++ b/README.md @@ -193,3 +193,6 @@ with `git config diff.orderFile scripts/git.difforder` enables it. We strive to follow the Linux kernels coding style so it's recommended to run the kernel's ./scripts/checkpatch.pl on new patches. + +Also run `make shellcheck` before submitting a patch which touches bash +scripts. diff --git a/scripts/common.bash b/scripts/common.bash index b9413d683..5e9ad53e2 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -78,8 +78,11 @@ function arch_cmd() } # The current file has to be the only file sourcing the arch helper -# file +# file. Shellcheck can't follow this so help it out. There doesn't appear to be a +# way to specify multiple alternatives, so we will have to rethink this if things +# get more complicated. ARCH_FUNC=scripts/${ARCH}/func.bash if [ -f "${ARCH_FUNC}" ]; then +# shellcheck source=scripts/s390x/func.bash source "${ARCH_FUNC}" fi