perf trace beauty: Add shellcheck to scripts
authorIan Rogers <irogers@google.com>
Tue, 9 Apr 2024 02:32:16 +0000 (19:32 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 12 Apr 2024 20:54:02 +0000 (17:54 -0300)
Add shell check to scripts generating perf trace lookup tables. Fix
quoting issue in arch_errno_names.sh.

Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Link: https://lore.kernel.org/r/20240409023216.2342032-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/trace/beauty/Build
tools/perf/trace/beauty/arch_errno_names.sh

index d8ce1b69898321348aec5d6aec996074046b9968..cb3c1399ff40914dc40c5f7020bfac78ef7f145b 100644 (file)
@@ -20,3 +20,17 @@ perf-y += statx.o
 perf-y += sync_file_range.o
 perf-y += timespec.o
 perf-y += tracepoints/
+
+ifdef SHELLCHECK
+  SHELL_TESTS := $(wildcard trace/beauty/*.sh)
+  TEST_LOGS := $(SHELL_TESTS:trace/beauty/%=%.shellcheck_log)
+else
+  SHELL_TESTS :=
+  TEST_LOGS :=
+endif
+
+$(OUTPUT)%.shellcheck_log: %
+       $(call rule_mkdir)
+       $(Q)$(call echo-cmd,test)shellcheck -s bash -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)
+
+perf-y += $(TEST_LOGS)
index 7df4bf5b55a3cc2a8c5a31462129e8ac829a4e59..30d3889b295771508917267db2daf5b2f8b317d8 100755 (executable)
@@ -60,10 +60,12 @@ create_arch_errno_table_func()
        printf 'arch_syscalls__strerrno_t *arch_syscalls__strerrno_function(const char *arch)\n'
        printf '{\n'
        for arch in $archlist; do
-               printf '\tif (!strcmp(arch, "%s"))\n' $(arch_string "$arch")
-               printf '\t\treturn errno_to_name__%s;\n' $(arch_string "$arch")
+               arch_str=$(arch_string "$arch")
+               printf '\tif (!strcmp(arch, "%s"))\n' "$arch_str"
+               printf '\t\treturn errno_to_name__%s;\n' "$arch_str"
        done
-       printf '\treturn errno_to_name__%s;\n' $(arch_string "$default")
+       arch_str=$(arch_string "$default")
+       printf '\treturn errno_to_name__%s;\n' "$arch_str"
        printf '}\n'
 }