linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Kajol Jain <kjain@linux.ibm.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-perf-users@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	Disha Goel <disgoel@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 1/2] tools/perf: Add new CONFIG_SHELLCHECK for detecting shellcheck binary
Date: Wed, 27 Sep 2023 09:53:17 +0530	[thread overview]
Message-ID: <51AB9EEE-6A09-460E-8812-5698FC1300D4@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAM9d7chpQ-t72+wsv0qrLsLK9yJ5x77qapqN3+9tKHqT8246Ew@mail.gmail.com>



> On 27-Sep-2023, at 5:21 AM, Namhyung Kim <namhyung@kernel.org> wrote:
> 
> Hello,
> 
> On Thu, Sep 14, 2023 at 10:18 AM Athira Rajeev
> <atrajeev@linux.vnet.ibm.com> wrote:
>> 
>> 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"
> 
> I don't think it'd generate the .bin file.
> 
> Anyway, it's a binary file already.  Can we check it with
> `command -v` and get rid of the feature test?
> 
> Thanks,
> Namhyung

Hi Namhyung,

Thanks for the review. Sure, I will check on this

Athira
> 
> 
>> +
>> $(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



      reply	other threads:[~2023-09-27  4:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 17:18 [PATCH 1/2] tools/perf: Add new CONFIG_SHELLCHECK for detecting shellcheck binary Athira Rajeev
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 [this message]

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=51AB9EEE-6A09-460E-8812-5698FC1300D4@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).