tools/perf: Add perf binary dependent rule for shellcheck log in Makefile.perf
PATCH v2 1/1 tools/perf: Add perf binary dependent rule for shellcheck log in Makefile.perf
Add rule in new Makefile "tests/Makefile.tests" for running shellcheck on shell test scripts. This automates below shellcheck into the build.
$ for F in $(find tests/shell/ -perm -o=x -name '*.sh'); do shellcheck -S warning $F; done
Condition for shellcheck is added in Makefile.perf to avoid build breakage in the absence of shellcheck binary. Update Makefile.perf to contain new rule for "SHELLCHECK_TEST" which is for making shellcheck test as a dependency on perf binary. Added "tests/Makefile.tests" to run shellcheck on shellscripts in tests/shell. The make rule "SHLLCHECK_RUN" ensures that, every time during make, shellcheck will be run only on modified files during subsequent invocations. By this, if any newly added shell scripts or fixes in existing scripts breaks coding/formatting style, it will get captured during the perf build.
Example build failure with present scripts in tests/shell:
INSTALL libsubcmd_headers
INSTALL libperf_headers
INSTALL libapi_headers
INSTALL libsymbol_headers
INSTALL libbpf_headers
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:675: SHELLCHECK_TEST] Error 2
make[1]: *** [Makefile.perf:238: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
After this, for testing, changed "tests/shell/record.sh" to break shellcheck format. In the next make run, it is also captured:
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:675: SHELLCHECK_TEST] Error 2
make[1]: *** [Makefile.perf:238: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
---
Changelog:
v1 -> v2:
Version1 had shellcheck in feature check which is not required since shellcheck is already a binary. Presence of binary can be checked using:
$(shell command -v shellcheck)
Addressed these changes as suggested by Namhyung in V2 Feature test logic is removed in V2. Also added example for build breakage when shellcheck fails in commit message
tools/perf/Makefile.perf | 14 +++++++++++++- tools/perf/tests/Makefile.tests | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tools/perf/tests/Makefile.tests
tools/perf/Makefile.perf +13 -1
@@ -667,7 +667,18 @@ $(PERF_IN): prepare FORCE $(PMU_EVENTS_IN): FORCE prepare $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events -$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) +# Runs shellcheck on perf test shell scripts + +SHELLCHECK := $(shell command -v shellcheck) +ifneq ($(SHELLCHECK),) +SHELLCHECK_TEST: FORCE prepare + $(Q)$(MAKE) -f $(srctree)/tools/perf/tests/Makefile.tests +else +SHELLCHECK_TEST: + @: +endif + +$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) SHELLCHECK_TEST $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \ $(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
@@ -1130,6 +1141,7 @@ bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean + $(Q)$(MAKE) -f $(srctree)/tools/perf/tests/Makefile.tests clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected
tools/perf/tests/Makefile.tests new file +24 -0
@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 +# Athira Rajeev <[email protected]>, 2023 + +PROGS = $(subst ./,,$(shell find tests/shell -perm -o=x -type f -name '*.sh')) +DEPS = $(addprefix output/,$(addsuffix .dep,$(basename $(PROGS)))) +DIRS = $(shell echo $(dir $(DEPS)) | xargs -n1 | sort -u | xargs) + +.PHONY: all +all: SHELLCHECK_RUN + @: + +SHELLCHECK_RUN: $(DEPS) $(DIRS) + +output/%.dep: %.sh | $(DIRS) + $(call rule_mkdir) + $(eval input_file := $(subst output/,./,$(patsubst %.dep, %.sh, $@))) + $(Q)$(call frecho-cmd,test)@shellcheck -S warning ${input_file} 1> [email protected] && ([[ ! -s [email protected] ]]) + $(Q)$(call frecho-cmd,test)@touch $@ + $(Q)$(call frecho-cmd,test)@rm -rf [email protected] +$(DIRS): + @mkdir -p $@ + +clean: + @rm -rf output
Signature · 1 line
2.31.1
Quoted 50 lines · Athira Rajeev
Add rule in new
Makefile"tests/Makefile.tests" for running shellcheck on shell test scripts. This automates below shellcheck into the build.$ for F in $(find tests/shell/ -perm -o=x -name '*.sh'); do shellcheck -S warning $F; doneCondition for shellcheck is added in Makefile.perf to avoid build breakage in the absence of shellcheck binary. Update Makefile.perf to contain new rule for "
SHELLCHECK_TEST" which is for making shellcheck test as a dependency on perf binary. Added "tests/Makefile.tests" to run shellcheck on shellscripts in tests/shell. The make rule "SHLLCHECK_RUN" ensures that, every time during make, shellcheck will be run only on modified files during subsequent invocations. By this, if any newly added shell scripts or fixes in existing scripts breaks coding/formatting style, it will get captured during the perf build.Example build failure with present scripts in tests/shell:
INSTALL
libsubcmd_headers
INSTALLlibperf_headers
INSTALLlibapi_headers
INSTALLlibsymbol_headers
INSTALLlibbpf_headers
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:675:SHELLCHECK_TEST] Error 2
make[1]: *** [Makefile.perf:238: sub-make] Error 2
make: *** [Makefile:70: all] Error 2After this, for testing, changed "
tests/shell/record.sh" to break shellcheck format. In the next make run, it is also captured:make[3]: *** [
/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:675:SHELLCHECK_TEST] Error 2
make[1]: *** [Makefile.perf:238: sub-make] Error 2
make: *** [Makefile:70: all] Error 2Signed-off-by Athira Rajeev <[email protected]>
Quoted 10 lines
---
Changelog:
v1 -> v2:
Version1 had shellcheck in feature check which is not required since shellcheck is already a binary. Presence of binary can be checked using:
$(shell command -v shellcheck)
Addressed these changes as suggested by Namhyung in V2 Feature test logic is removed in V2. Also added example for build breakage when shellcheck fails in commit message
Hi All,
Looking for feedback on this patch
Thanks
Athira
Quoted 71 lines
tools/perf/Makefile.perf| 14 +++++++++++++-tools/perf/tests/Makefile.tests| 24 ++++++++++++++++++++++++2 files changed, 37 insertions(+), 1 deletion(-)create mode 100644
tools/perf/tests/Makefile.teststools/perf/Makefile.perf +0
-0@@ -667,7 +667,18 @@ $(PERF_IN): prepare FORCE$(PMU_EVENTS_IN): FORCE prepare
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events-$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN)
tools/perf/Makefile.perf +12
-0+# Runs shellcheck on perf test shell scripts + +SHELLCHECK := $(shell command -v shellcheck) +ifneq ($(SHELLCHECK),) +SHELLCHECK_TEST: FORCE prepare + $(Q)$(MAKE) -f $(srctree)/tools/perf/tests/Makefile.tests +else +SHELLCHECK_TEST: + @: +endif + +$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) SHELLCHECK_TEST$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
$(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@tools/perf/Makefile.perf +0
-0@@ -1130,6 +1141,7 @@ bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean
+ $(Q)$(MAKE) -f $(srctree)/tools/perf/tests/Makefile.tests clean
$(callQUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS)
$(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)$(RM) $(OUTPUT).config-detectedtools/perf/tests/Makefile.tests new file +24
-0@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 +# Athira Rajeev <[email protected]>, 2023 + +PROGS = $(subst ./,,$(shell find tests/shell -perm -o=x -type f -name '*.sh')) +DEPS = $(addprefix output/,$(addsuffix .dep,$(basename $(PROGS)))) +DIRS = $(shell echo $(dir $(DEPS)) | xargs -n1 | sort -u | xargs) + +.PHONY: all +all: SHELLCHECK_RUN + @: + +SHELLCHECK_RUN: $(DEPS) $(DIRS) + +output/%.dep: %.sh | $(DIRS) + $(call rule_mkdir) + $(eval input_file := $(subst output/,./,$(patsubst %.dep, %.sh, $@))) + $(Q)$(call frecho-cmd,test)@shellcheck -S warning ${input_file} 1> [email protected] && ([[ ! -s [email protected] ]]) + $(Q)$(call frecho-cmd,test)@touch $@ + $(Q)$(call frecho-cmd,test)@rm -rf [email protected] +$(DIRS): + @mkdir -p $@ + +clean: + @rm -rf outputSignature · 1 line
2.31.1
Namhyung Kim
maintainerHello,
Sorry for the late reply.
Quoted 37 lines · Athira Rajeev
Quoted 37 lines · Athira Rajeev
Add rule in new
Makefile"tests/Makefile.tests" for running shellcheck on shell test scripts. This automates below shellcheck into the build.$ for F in $(find tests/shell/ -perm -o=x -name '*.sh'); do shellcheck -S warning $F; doneCondition for shellcheck is added in Makefile.perf to avoid build breakage in the absence of shellcheck binary. Update Makefile.perf to contain new rule for "
SHELLCHECK_TEST" which is for making shellcheck test as a dependency on perf binary. Added "tests/Makefile.tests" to run shellcheck on shellscripts in tests/shell. The make rule "SHLLCHECK_RUN" ensures that, every time during make, shellcheck will be run only on modified files during subsequent invocations. By this, if any newly added shell scripts or fixes in existing scripts breaks coding/formatting style, it will get captured during the perf build.Example build failure with present scripts in tests/shell:
INSTALL
libsubcmd_headers
INSTALLlibperf_headers
INSTALLlibapi_headers
INSTALLlibsymbol_headers
INSTALLlibbpf_headers
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:675:SHELLCHECK_TEST] Error 2
make[1]: *** [Makefile.perf:238: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
Quoted 3 lines
Quoted 3 lines
After this, for testing, changed "
tests/shell/record.sh" to break shellcheck format. In the next make run, it is also captured:
Where can I see the actual failure messages?
Quoted 9 lines
Quoted 9 lines
make[3]: *** [
/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:675:SHELLCHECK_TEST] Error 2
make[1]: *** [Makefile.perf:238: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
So is this reported at build time before I run the test command? I'm ok with that but maybe I need to build it even though I know some test is broken. Can we have an option to do that like with make NO_SHELLCHECK=1 ?
Quoted 72 lines
Quoted 12 lines
Signed-off-by Athira Rajeev <[email protected]>---
Changelog:
v1 -> v2:
Version1 had shellcheck in feature check which is not required since shellcheck is already a binary. Presence of binary can be checked using:
$(shell command -v shellcheck)
Addressed these changes as suggested by Namhyung in V2 Feature test logic is removed in V2. Also added example for build breakage when shellcheck fails in commit messageHi All,
Looking for feedback on this patch
Thanks
AthiraQuoted 53 lines
tools/perf/Makefile.perf| 14 +++++++++++++-tools/perf/tests/Makefile.tests| 24 ++++++++++++++++++++++++2 files changed, 37 insertions(+), 1 deletion(-)create mode 100644
tools/perf/tests/Makefile.teststools/perf/Makefile.perf +0
-0@@ -667,7 +667,18 @@ $(PERF_IN): prepare FORCE$(PMU_EVENTS_IN): FORCE prepare
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events-$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN)
tools/perf/Makefile.perf +12
-0+# Runs shellcheck on perf test shell scripts + +SHELLCHECK := $(shell command -v shellcheck) +ifneq ($(SHELLCHECK),) +SHELLCHECK_TEST: FORCE prepare + $(Q)$(MAKE) -f $(srctree)/tools/perf/tests/Makefile.tests +else +SHELLCHECK_TEST: + @: +endif + +$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) SHELLCHECK_TEST$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
$(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@tools/perf/Makefile.perf +0
-0@@ -1130,6 +1141,7 @@ bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean
+ $(Q)$(MAKE) -f $(srctree)/tools/perf/tests/Makefile.tests clean
$(callQUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS)
$(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)$(RM) $(OUTPUT).config-detectedtools/perf/tests/Makefile.tests new file +9
-0@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 +# Athira Rajeev <[email protected]>, 2023 + +PROGS = $(subst ./,,$(shell find tests/shell -perm -o=x -type f -name '*.sh')) +DEPS = $(addprefix output/,$(addsuffix .dep,$(basename $(PROGS)))) +DIRS = $(shell echo $(dir $(DEPS)) | xargs -n1 | sort -u | xargs) + +.PHONY: all +all: SHELLCHECK_RUN
Quoted 8 lines
tools/perf/tests/Makefile.tests line 17
Quoted 8 lines
tools/perf/tests/Makefile.tests new file +8
-0+ @: + +SHELLCHECK_RUN: $(DEPS) $(DIRS) + +output/%.dep: %.sh | $(DIRS) + $(call rule_mkdir) + $(eval input_file := $(subst output/,./,$(patsubst %.dep, %.sh, $@))) + $(Q)$(call frecho-cmd,test)@shellcheck -S warning ${input_file} 1> [email protected] && ([[ ! -s [email protected] ]])
What is the last part? I guess it checks if shellcheck found no errors. Can we just check the exit code of the shellcheck? Is there a case it didn't work?
Thanks,
Namhyung
Quoted 11 lines
Quoted 10 lines
tools/perf/tests/Makefile.tests new file +7
-1+ $(Q)$(call frecho-cmd,test)@touch $@ + $(Q)$(call frecho-cmd,test)@rm -rf [email protected] +$(DIRS): + @mkdir -p $@ + +clean: + @rm -rf output --2.31.1
Quoted 47 lines · Namhyung Kim
Hello,
Sorry for the late reply.
Quoted 37 lines · Athira Rajeev
Quoted 37 lines · Athira Rajeev
Add rule in new
Makefile"tests/Makefile.tests" for running shellcheck on shell test scripts. This automates below shellcheck into the build.$ for F in $(find tests/shell/ -perm -o=x -name '*.sh'); do shellcheck -S warning $F; doneCondition for shellcheck is added in Makefile.perf to avoid build breakage in the absence of shellcheck binary. Update Makefile.perf to contain new rule for "
SHELLCHECK_TEST" which is for making shellcheck test as a dependency on perf binary. Added "tests/Makefile.tests" to run shellcheck on shellscripts in tests/shell. The make rule "SHLLCHECK_RUN" ensures that, every time during make, shellcheck will be run only on modified files during subsequent invocations. By this, if any newly added shell scripts or fixes in existing scripts breaks coding/formatting style, it will get captured during the perf build.Example build failure with present scripts in tests/shell:
INSTALL
libsubcmd_headers
INSTALLlibperf_headers
INSTALLlibapi_headers
INSTALLlibsymbol_headers
INSTALLlibbpf_headers
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:675:SHELLCHECK_TEST] Error 2
make[1]: *** [Makefile.perf:238: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
After this, for testing, changed "
tests/shell/record.sh" to break shellcheck format. In the next make run, it is also captured:Where can I see the actual failure messages?
Hi Namhyung,
Thanks for the review comments.
Example, with current tree, we have these format issues:
GENSKEL /root/athira/linux/tools/perf/util/bpf_skel/kwork_trace.skel.h
CC bench/uprobe.o
CC util/header.o
LD bench/perf-in.o
make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/stat_all_metricgroups.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 CC util/bpf_counter.o
CC util/bpf_counter_cgroup.o
CC util/bpf_ftrace.o
CC util/bpf_off_cpu.o
CC util/bpf-filter.o
make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:15: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:15: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:679: SHELLCHECK_TEST] Error 2
make[2]: *** Waiting for unfinished jobs....
LD util/perf-in.o
LD perf-in.o
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
The actual fail can be seen here:
# cat output/tests/shell/stat_all_metricgroups.dep.log
In ./tests/shell/stat_all_metricgroups.sh line 7:
function ParanoidAndNotRoot()
^-- SC2112: 'function' keyword is non-standard. Delete it.
For more information:
https://www.shellcheck.net/wiki/SC2112 -- 'function' keyword is non-standar...
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 8 lines
Quoted 8 lines
make[3]: *** [
/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/record.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/namhyung/perf-tools-next/tools/perf/tests/Makefile.tests:17: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:675:SHELLCHECK_TEST] Error 2
make[1]: *** [Makefile.perf:238: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
Quoted 4 lines
So is this reported at build time before I run the test command? I'm ok with that but maybe I need to build it even though I know some test is broken. Can we have an option to do that like with
make NO_SHELLCHECK=1?
Yes, agree Namhyung. Valid point.
I will add that in V3
Quoted 77 lines
Quoted 77 lines
Quoted 13 lines
Signed-off-by Athira Rajeev <[email protected]>---
Changelog:
v1 -> v2:
Version1 had shellcheck in feature check which is not required since shellcheck is already a binary. Presence of binary can be checked using:
$(shell command -v shellcheck)
Addressed these changes as suggested by Namhyung in V2 Feature test logic is removed in V2. Also added example for build breakage when shellcheck fails in commit messageHi All,
Looking for feedback on this patch
Thanks
AthiraQuoted 57 lines
tools/perf/Makefile.perf| 14 +++++++++++++-tools/perf/tests/Makefile.tests| 24 ++++++++++++++++++++++++2 files changed, 37 insertions(+), 1 deletion(-)create mode 100644
tools/perf/tests/Makefile.teststools/perf/Makefile.perf +0
-0@@ -667,7 +667,18 @@ $(PERF_IN): prepare FORCE$(PMU_EVENTS_IN): FORCE prepare
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events-$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN)
tools/perf/Makefile.perf +12
-0+# Runs shellcheck on perf test shell scripts + +SHELLCHECK := $(shell command -v shellcheck) +ifneq ($(SHELLCHECK),) +SHELLCHECK_TEST: FORCE prepare + $(Q)$(MAKE) -f $(srctree)/tools/perf/tests/Makefile.tests +else +SHELLCHECK_TEST: + @: +endif + +$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) SHELLCHECK_TEST$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
$(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@tools/perf/Makefile.perf +0
-0@@ -1130,6 +1141,7 @@ bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean
+ $(Q)$(MAKE) -f $(srctree)/tools/perf/tests/Makefile.tests clean
$(callQUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS)
$(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)$(RM) $(OUTPUT).config-detectedtools/perf/tests/Makefile.tests new file +13
-0@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 +# Athira Rajeev <[email protected]>, 2023 + +PROGS = $(subst ./,,$(shell find tests/shell -perm -o=x -type f -name '*.sh')) +DEPS = $(addprefix output/,$(addsuffix .dep,$(basename $(PROGS)))) +DIRS = $(shell echo $(dir $(DEPS)) | xargs -n1 | sort -u | xargs) + +.PHONY: all +all: SHELLCHECK_RUN + @: + +SHELLCHECK_RUN: $(DEPS) $(DIRS) +
Quoted 8 lines
Quoted 4 lines
tools/perf/tests/Makefile.tests line 17
Quoted 4 lines
tools/perf/tests/Makefile.tests new file +4
-0+output/%.dep: %.sh | $(DIRS) + $(call rule_mkdir) + $(eval input_file := $(subst output/,./,$(patsubst %.dep, %.sh, $@))) + $(Q)$(call frecho-cmd,test)@shellcheck -S warning ${input_file} 1> [email protected] && ([[ ! -s [email protected] ]])What is the last part? I guess it checks if shellcheck found no errors. Can we just check the exit code of the shellcheck? Is there a case it didn't work?
It checks to see if the redirected file has any warnings ( if it is not empty ). I had tried exit code, but it reported false fails with using exit code
Diff I used:
tools/perf/tests/Makefile.tests +0 -0
@@ -14,7 +14,7 @@ SHELLCHECK_RUN: $(DEPS) $(DIRS)
output/%.dep: %.sh | $(DIRS)
$(call rule_mkdir)
$(eval input_file := $(subst output/,./,$(patsubst %.dep, %.sh, $@)))
- $(Q)$(call frecho-cmd,test)@shellcheck -S warning ${input_file} 1> [email protected] && ([[ ! -s [email protected] ]])
+ $(Q)$(call frecho-cmd,test)@shellcheck -S warning ${input_file} 1> [email protected] && ([[ ! $? ]]) $(Q)$(call frecho-cmd,test)@touch $@
$(Q)$(call frecho-cmd,test)@rm -rf [email protected]
$(DIRS):
INSTALL libsubcmd_headers
INSTALL libsymbol_headers
INSTALL libperf_headers
INSTALL libapi_headers
INSTALL libbpf_headers
make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/stat_all_metricgroups.dep] Error 1 make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/trace+probe_vfs_getname.dep] Error 1 make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/record_sideband.dep] Error 1 make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_java_symbol.dep] Error 1 make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_brstack.dep] Error 1 make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_task_analyzer.dep] Error 1 make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/test_arm_coresight.dep] Error 1 make[3]: *** [/root/athira/linux/tools/perf/tests/Makefile.tests:17: output/tests/shell/lock_contention.dep] Error 1 make[2]: *** [Makefile.perf:679: SHELLCHECK_TEST] Error 2
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
I think it happens since we run the checks parallely.
Hence checking the corresponding log for the particular script will give us accuracy with the results.
Thanks
Athira
Quoted 14 lines
Thanks,
NamhyungQuoted 9 lines
Quoted 9 lines
tools/perf/tests/Makefile.tests new file +7
-1+ $(Q)$(call frecho-cmd,test)@touch $@ + $(Q)$(call frecho-cmd,test)@rm -rf [email protected] +$(DIRS): + @mkdir -p $@ + +clean: + @rm -rf output --2.31.1