From: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
To: acme@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com,
irogers@google.com, namhyung@kernel.org
Cc: linux-perf-users@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
maddy@linux.ibm.com, atrajeev@linux.vnet.ibm.com,
kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com
Subject: [PATCH 1/2] tools/perf: Add new CONFIG_SHELLCHECK for detecting shellcheck binary
Date: Thu, 14 Sep 2023 22:48:26 +0530 [thread overview]
Message-ID: <20230914171827.98507-1-atrajeev@linux.vnet.ibm.com> (raw)
shellcheck tool can detect coding/formatting issues on
shell scripts. In perf directory "tests/shell", there are lot
of shell test scripts and this tool can detect coding/formatting
issues on these scripts.
Example to use shellcheck for severity level for
errors and warnings, below command is used:
# for F in $(find tests/shell/ -perm -o=x -name '*.sh'); do shellcheck -S warning $F; done
# echo $?
0
This testing needs to be automated into the build so that it
can avoid regressions and also run the check for newly added
during build test itself. Add a new feature check to detect
presence of shellcheck. Add CONFIG_SHELLCHECK feature check in
the build to avoid not having shellcheck breaking the build.
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
tools/build/Makefile.feature | 6 ++++--
tools/build/feature/Makefile | 8 +++++++-
tools/perf/Makefile.config | 10 ++++++++++
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 934e2777a2db..23f56b95babf 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -72,7 +72,8 @@ FEATURE_TESTS_BASIC := \
libzstd \
disassembler-four-args \
disassembler-init-styled \
- file-handle
+ file-handle \
+ shellcheck
# FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
# of all feature tests
@@ -138,7 +139,8 @@ FEATURE_DISPLAY ?= \
get_cpuid \
bpf \
libaio \
- libzstd
+ libzstd \
+ shellcheck
#
# Declare group members of a feature to display the logical OR of the detection
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 3184f387990a..44ba6d0c98d0 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -76,7 +76,8 @@ FILES= \
test-libzstd.bin \
test-clang-bpf-co-re.bin \
test-file-handle.bin \
- test-libpfm4.bin
+ test-libpfm4.bin \
+ test-shellcheck.bin
FILES := $(addprefix $(OUTPUT),$(FILES))
@@ -92,6 +93,8 @@ __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(
__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
+ BUILD_BINARY = sh -c $1 > $(@:.bin=.make.output) 2>&1
+
###############################
$(OUTPUT)test-all.bin:
@@ -207,6 +210,9 @@ $(OUTPUT)test-libslang-include-subdir.bin:
$(OUTPUT)test-libtraceevent.bin:
$(BUILD) -ltraceevent
+$(OUTPUT)test-shellcheck.bin:
+ $(BUILD_BINARY) "shellcheck --version"
+
$(OUTPUT)test-libtracefs.bin:
$(BUILD) $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null) -ltracefs
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index d66b52407e19..e71fe95ad865 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -779,6 +779,16 @@ ifndef NO_SLANG
endif
endif
+ifneq ($(NO_SHELLCHECK),1)
+ $(call feature_check,shellcheck)
+ ifneq ($(feature-shellcheck), 1)
+ msg := $(warning No shellcheck found. please install ShellCheck);
+ else
+ $(call detected,CONFIG_SHELLCHECK)
+ NO_SHELLCHECK := 0
+ endif
+endif
+
ifdef GTK2
FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
$(call feature_check,gtk2)
--
2.31.1
next reply other threads:[~2023-09-14 17:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 17:18 Athira Rajeev [this message]
2023-09-14 17:18 ` [PATCH 2/2] tools/perf: Add perf binary dependent rule for shellcheck log in Makefile.perf Athira Rajeev
2023-09-26 23:55 ` Namhyung Kim
2023-09-27 4:25 ` Athira Rajeev
2023-09-29 4:18 ` Athira Rajeev
2023-09-26 23:51 ` [PATCH 1/2] tools/perf: Add new CONFIG_SHELLCHECK for detecting shellcheck binary Namhyung Kim
2023-09-27 4:23 ` Athira Rajeev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230914171827.98507-1-atrajeev@linux.vnet.ibm.com \
--to=atrajeev@linux.vnet.ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=disgoel@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kjain@linux.ibm.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).