tools/perf: Fix shellcheck coding/formatting issues of perf tool shell scripts
Subsystems (2)
cover tools/perf: Fix shellcheck coding/formatting issues of perf tool shell scripts
Patchset covers a set of fixes for coding/formatting issues observed while running shellcheck tool on the perf shell scripts.
This cleanup is a pre-requisite to include a build option for shellcheck discussed here: https://www.spinics.net/lists/linux-perf-users/msg25553.html
First set of patches were posted here:
https://lore.kernel.org/linux-perf-users/[email protected]/T/#t
This patchset covers remaining set of shell scripts which needs fix. Patch 1 is resubmission of patch 6 from the initial series. Patch 15, 16 and 22 touches code from tools/perf/trace/beauty. Other patches are fixes for scripts from tools/perf/tests.
Akanksha J N (1):
tools/perf/tests: Fix shellcheck warnings for
trace+probe_vfs_getname.sh
Athira Rajeev (11):
tools/perf/tests: fix test_arm_spe_fork.sh signal case issues tools/perf/tests: Fix unused variable references in
stat+csv_summary.sh testcase
tools/perf/tests: fix shellcheck warning for
test_perf_data_converter_json.sh testcase
tools/perf/tests: Fix shellcheck issue for stat_bpf_counters.sh
testcase
tools/perf/tests: Fix shellcheck issues in
tests/shell/stat+shadow_stat.sh tetscase
tools/perf/tests: Fix shellcheck warnings for
thread_loop_check_tid_10.sh
tools/perf/tests: Fix shellcheck warnings for unroll_loop_thread_10.sh tools/perf/tests: Fix shellcheck warnings for lib/probe_vfs_getname.sh tools/perf/tests: Fix the shellcheck wanrings in lib/waiting.sh tools/perf/trace: Fix x86_arch_prctl.sh to address shellcheck warnings tools/perf/arch/x86: Fix syscalltbl.sh to address shellcheck warnings
Kajol Jain (10):
tools/perf/tests: Fix shellcheck warning for probe_vfs_getname.sh
testcase
tools/perf/tests: Fix shellcheck warning for record_offcpu.sh testcase tools/perf/tests: Fix shellcheck issue for lock_contention.sh testcase tools/perf/tests: Fix shellcheck issue for stat_bpf_counters_cgrp.sh
testcase
tools/perf/tests: Fix shellcheck warning for asm_pure_loop.sh shell
script
tools/perf/tests: Fix shellcheck warning for memcpy_thread_16k_10.sh
shell script
tools/perf/tests: Fix shellcheck warning for coresight.sh shell script tools/perf/tests: Fix shellcheck warning for probe.sh shell script tools/perf/trace: Fix shellcheck issue for arch_errno_names.sh script tools/perf: Fix shellcheck issue for check-headers.sh script
.../arch/x86/entry/syscalls/syscalltbl.sh | 2 +- tools/perf/check-headers.sh | 6 ++-- .../tests/shell/coresight/asm_pure_loop.sh | 2 +- .../shell/coresight/memcpy_thread_16k_10.sh | 2 +- .../coresight/thread_loop_check_tid_10.sh | 2 +- .../shell/coresight/unroll_loop_thread_10.sh | 2 +- tools/perf/tests/shell/lib/coresight.sh | 3 +- tools/perf/tests/shell/lib/probe.sh | 1 + .../perf/tests/shell/lib/probe_vfs_getname.sh | 5 ++-- tools/perf/tests/shell/lib/waiting.sh | 1 + tools/perf/tests/shell/lock_contention.sh | 12 ++++---- tools/perf/tests/shell/probe_vfs_getname.sh | 4 +-- tools/perf/tests/shell/record_offcpu.sh | 6 ++-- tools/perf/tests/shell/stat+csv_summary.sh | 4 +-- tools/perf/tests/shell/stat+shadow_stat.sh | 4 +-- tools/perf/tests/shell/stat_bpf_counters.sh | 4 +-- .../tests/shell/stat_bpf_counters_cgrp.sh | 28 ++++++++----------- tools/perf/tests/shell/test_arm_spe_fork.sh | 2 +- .../shell/test_perf_data_converter_json.sh | 2 +- .../tests/shell/trace+probe_vfs_getname.sh | 6 ++-- tools/perf/trace/beauty/arch_errno_names.sh | 15 ++++------ tools/perf/trace/beauty/x86_arch_prctl.sh | 6 ++-- 22 files changed, 58 insertions(+), 61 deletions(-)
Signature · 1 line
2.39.1
PATCH 1/22 tools/perf/tests: Fix shellcheck warnings for trace+probe_vfs_getname.sh
From: Akanksha J N <[email protected]>
Running shellcheck -S on probe_vfs_getname.sh, throws below warnings:
Before fix:
$ shellcheck -S warning trace+probe_vfs_getname.sh
In trace+probe_vfs_getname.sh line 13: . $(dirname $0)/lib/probe.sh ^-----------^ SC2046 (warning): Quote this to prevent word splitting. In trace+probe_vfs_getname.sh line 18: . $(dirname $0)/lib/probe_vfs_getname.sh ^-----------^ SC2046 (warning): Quote this to prevent word splitting. In trace+probe_vfs_getname.sh line 21: evts=$(echo $(perf list syscalls:sys_enter_open* 2>/dev/null | grep -E 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/') ^-- SC2046 (warning): Quote this to prevent word splitting.
Fix the shellcheck warnings by adding quotes to prevent word splitting.
--- tools/perf/tests/shell/trace+probe_vfs_getname.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/tests/shell/trace+probe_vfs_getname.sh +3 -3
@@ -10,15 +10,15 @@ # SPDX-License-Identifier: GPL-2.0 # Arnaldo Carvalho de Melo <[email protected]>, 2017 -. $(dirname $0)/lib/probe.sh +. "$(dirname $0)"/lib/probe.sh skip_if_no_perf_probe || exit 2 skip_if_no_perf_trace || exit 2 -. $(dirname $0)/lib/probe_vfs_getname.sh +. "$(dirname $0)"/lib/probe_vfs_getname.sh trace_open_vfs_getname() { - evts=$(echo $(perf list syscalls:sys_enter_open* 2>/dev/null | grep -E 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/') + evts="$(echo "$(perf list syscalls:sys_enter_open* 2>/dev/null | grep -E 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/')" | sed ':a;N;s:\n:,:g')" perf trace -e $evts touch $file 2>&1 | \ grep -E " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$" }
Signature · 1 line
2.39.1
PATCH 2/22 tools/perf/tests: Fix shellcheck warning for probe_vfs_getname.sh testcase
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on probe_vfs_getname.sh throws below warning:
In tests/shell/probe_vfs_getname.sh line 7:
. $(dirname $0)/lib/probe.sh
^-----------^ SC2046 (warning): Quote this to prevent word splitting.
In tests/shell/probe_vfs_getname.sh line 11:
. $(dirname $0)/lib/probe_vfs_getname.sh
^-----------^ SC2046 (warning): Quote this to prevent word splitting.
Fixed the warning by adding quotes to avoid word splitting.
ShellCheck result with patch:
# shellcheck -S warning probe_vfs_getname.sh
#--- tools/perf/tests/shell/probe_vfs_getname.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/tests/shell/probe_vfs_getname.sh +2 -2
@@ -4,11 +4,11 @@ # SPDX-License-Identifier: GPL-2.0 # Arnaldo Carvalho de Melo <[email protected]>, 2017 -. $(dirname $0)/lib/probe.sh +. "$(dirname $0)"/lib/probe.sh skip_if_no_perf_probe || exit 2 -. $(dirname $0)/lib/probe_vfs_getname.sh +. "$(dirname $0)"/lib/probe_vfs_getname.sh add_probe_vfs_getname || skip_if_no_debuginfo err=$?
Signature · 1 line
2.39.1
PATCH 3/22 tools/perf/tests: Fix shellcheck warning for record_offcpu.sh testcase
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on record_offcpu.sh throws below warning:
In tests/shell/record_offcpu.sh line 13:
trap - exit term int
^--^ SC3049 (warning): In POSIX sh, using lower/mixed case for signal names is undefined.
^--^ SC3049 (warning): In POSIX sh, using lower/mixed case for signal names is undefined.
^-^ SC3049 (warning): In POSIX sh, using lower/mixed case for signal names is undefined.
In tests/shell/record_offcpu.sh line 20:
trap trap_cleanup exit term int
^--^ SC3049 (warning): In POSIX sh, using lower/mixed case for signal names is undefined.
^--^ SC3049 (warning): In POSIX sh, using lower/mixed case for signal names is undefined.
^-^ SC3049 (warning): In POSIX sh, using lower/mixed case for signal names is undefined.
In tests/shell/record_offcpu.sh line 25:
if [ id -u != 0 ]
^-----^ SC2046 (warning): Quote this to prevent word splitting.
Fixed the warnings by:
- Capitalize signals(INT, TERM, EXIT) to avoid mixed/lower case naming of signals.
- Adding quotes to avoid word splitting.
Result from shellcheck after patch changes:
$ shellcheck -S warning record_offcpu.sh
$--- tools/perf/tests/shell/record_offcpu.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/tests/shell/record_offcpu.sh +3 -3
@@ -10,19 +10,19 @@ perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) cleanup() { rm -f ${perfdata} rm -f ${perfdata}.old - trap - exit term int + trap - EXIT TERM INT } trap_cleanup() { cleanup exit 1 } -trap trap_cleanup exit term int +trap trap_cleanup EXIT TERM INT test_offcpu_priv() { echo "Checking off-cpu privilege" - if [ `id -u` != 0 ] + if [ "$(id -u)" != 0 ] then echo "off-cpu test [Skipped permission]" err=2
Signature · 1 line
2.39.1
PATCH 4/22 tools/perf/tests: Fix shellcheck issue for lock_contention.sh testcase
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on lock_contention.sh generates below warning:
In tests/shell/lock_contention.sh line 24:
if [ `id -u` != 0 ]; then
^-----^ SC2046 (warning): Quote this to prevent word splitting.In tests/shell/lock_contention.sh line 160:
local type=$(head -1 "${result}" | awk '{ print $8 }' | sed -e 's/:.*//')
^--------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
^--^ SC2155 (warning): Declare and assign separately to avoid masking return values.
^-- SC2046 (warning): Quote this to prevent word splitting.Fixed above warnings by:
- Adding quotes to avoid word splitting.
- Fixing shellcheck warnings for local usage, by prefixing function name to the variable.
--- tools/perf/tests/shell/lock_contention.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/tests/shell/lock_contention.sh +6 -6
@@ -21,7 +21,7 @@ trap_cleanup() { trap trap_cleanup EXIT TERM INT check() { - if [ `id -u` != 0 ]; then + if [ "$(id -u)" != 0 ]; then echo "[Skip] No root permission" err=2 exit
@@ -157,10 +157,10 @@ test_lock_filter() perf lock contention -i ${perfdata} -L tasklist_lock -q 2> ${result} # find out the type of tasklist_lock - local type=$(head -1 "${result}" | awk '{ print $8 }' | sed -e 's/:.*//') + test_lock_filter_type=$(head -1 "${result}" | awk '{ print $8 }' | sed -e 's/:.*//') - if [ "$(grep -c -v "${type}" "${result}")" != "0" ]; then - echo "[Fail] Recorded result should not have non-${type} locks:" "$(cat "${result}")" + if [ "$(grep -c -v "${test_lock_filter_type}" "${result}")" != "0" ]; then + echo "[Fail] Recorded result should not have non-${test_lock_filter_type} locks:" "$(cat "${result}")" err=1 exit fi
@@ -170,8 +170,8 @@ test_lock_filter() fi perf lock con -a -b -L tasklist_lock -q -- perf bench sched messaging > /dev/null 2> ${result} - if [ "$(grep -c -v "${type}" "${result}")" != "0" ]; then - echo "[Fail] BPF result should not have non-${type} locks:" "$(cat "${result}")" + if [ "$(grep -c -v "${test_lock_filter_type}" "${result}")" != "0" ]; then + echo "[Fail] BPF result should not have non-${test_lock_filter_type} locks:" "$(cat "${result}")" err=1 exit fi
Signature · 1 line
2.39.1
PATCH 5/22 tools/perf/tests: Fix shellcheck issue for stat_bpf_counters_cgrp.sh testcase
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on lock_contention.sh generates below warning:
In stat_bpf_counters_cgrp.sh line 28:
if [ -d /sys/fs/cgroup/system.slice -a -d /sys/fs/cgroup/user.slice ]; then
^-- SC2166 (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.In stat_bpf_counters_cgrp.sh line 34:
local self_cgrp=$(grep perf_event /proc/self/cgroup | cut -d: -f3)
^-------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
^-- SC2046 (warning): Quote this to prevent word splitting.In stat_bpf_counters_cgrp.sh line 51:
local output
^----------^ SC3043 (warning): In POSIX sh, 'local' is undefined.In stat_bpf_counters_cgrp.sh line 65:
local output
^----------^ SC3043 (warning): In POSIX sh, 'local' is undefined.Fixed above warnings by:
- Changing the expression [p -a q] to [p] && [q].
- Fixing shellcheck warnings for local usage, by prefixing function name to the variable.
--- .../tests/shell/stat_bpf_counters_cgrp.sh | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-)
tools/perf/tests/shell/stat_bpf_counters_cgrp.sh +12 -16
@@ -25,22 +25,22 @@ check_bpf_counter() find_cgroups() { # try usual systemd slices first - if [ -d /sys/fs/cgroup/system.slice -a -d /sys/fs/cgroup/user.slice ]; then + if [ -d /sys/fs/cgroup/system.slice ] && [ -d /sys/fs/cgroup/user.slice ]; then test_cgroups="system.slice,user.slice" return fi # try root and self cgroups - local self_cgrp=$(grep perf_event /proc/self/cgroup | cut -d: -f3) - if [ -z ${self_cgrp} ]; then + find_cgroups_self_cgrp=$(grep perf_event /proc/self/cgroup | cut -d: -f3) + if [ -z ${find_cgroups_self_cgrp} ]; then # cgroup v2 doesn't specify perf_event - self_cgrp=$(grep ^0: /proc/self/cgroup | cut -d: -f3) + find_cgroups_self_cgrp=$(grep ^0: /proc/self/cgroup | cut -d: -f3) fi - if [ -z ${self_cgrp} ]; then + if [ -z ${find_cgroups_self_cgrp} ]; then test_cgroups="/" else - test_cgroups="/,${self_cgrp}" + test_cgroups="/,${find_cgroups_self_cgrp}" fi }
@@ -48,13 +48,11 @@ find_cgroups() # Just check if it runs without failure and has non-zero results. check_system_wide_counted() { - local output - - output=$(perf stat -a --bpf-counters --for-each-cgroup ${test_cgroups} -e cpu-clock -x, sleep 1 2>&1) - if echo ${output} | grep -q -F "<not "; then + check_system_wide_counted_output=$(perf stat -a --bpf-counters --for-each-cgroup ${test_cgroups} -e cpu-clock -x, sleep 1 2>&1) + if echo ${check_system_wide_counted_output} | grep -q -F "<not "; then echo "Some system-wide events are not counted" if [ "${verbose}" = "1" ]; then - echo ${output} + echo ${check_system_wide_counted_output} fi exit 1 fi
@@ -62,13 +60,11 @@ check_system_wide_counted() check_cpu_list_counted() { - local output - - output=$(perf stat -C 1 --bpf-counters --for-each-cgroup ${test_cgroups} -e cpu-clock -x, taskset -c 1 sleep 1 2>&1) - if echo ${output} | grep -q -F "<not "; then + check_cpu_list_counted_output=$(perf stat -C 1 --bpf-counters --for-each-cgroup ${test_cgroups} -e cpu-clock -x, taskset -c 1 sleep 1 2>&1) + if echo ${check_cpu_list_counted_output} | grep -q -F "<not "; then echo "Some CPU events are not counted" if [ "${verbose}" = "1" ]; then - echo ${output} + echo ${check_cpu_list_counted_output} fi exit 1 fi
Signature · 1 line
2.39.1
PATCH 6/22 tools/perf/tests: fix test_arm_spe_fork.sh signal case issues
In reply to Athira RajeevRunning shellcheck -S on test_arm_spe_fork.sh throws below warnings:
In tests/shell/test_arm_spe_fork.sh line 25:
trap cleanup_files exit term int
^--^ SC3049 (warning): In POSIX sh, using lower/mixed case for signal names is undefined.
^--^ SC3049 (warning): In POSIX sh, using lower/mixed case for signal names is undefined.
^-^ SC3049 (warning): In POSIX sh, using lower/mixed case for signal names is undefined.
Fixed this issue by using uppercase for "EXIT", "TERM" and "INIT" signals to avoid using lower/mixed case for signal names as input.
--- tools/perf/tests/shell/test_arm_spe_fork.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/test_arm_spe_fork.sh +1 -1
@@ -22,7 +22,7 @@ cleanup_files() rm -f ${PERF_DATA} } -trap cleanup_files exit term int +trap cleanup_files EXIT TERM INT echo "Recording workload..." perf record -o ${PERF_DATA} -e arm_spe/period=65536/ -vvv -- $TEST_PROGRAM > ${PERF_RECORD_LOG} 2>&1 &
Signature · 1 line
2.39.1
PATCH 7/22 tools/perf/tests: Fix unused variable references in stat+csv_summary.sh testcase
In reply to Athira RajeevRunning shellcheck on stat+csv_summary.sh throws below warnings:
In tests/shell/stat+csv_summary.sh line 26:
while read num event run pct
^-^ SC2034 (warning): num appears unused. Verify use (or export if used externally).
^---^ SC2034 (warning): event appears unused. Verify use (or export if used externally).
^-^ SC2034 (warning): run appears unused. Verify use (or export if used externally).
^-^ SC2034 (warning): pct appears unused. Verify use (or export if used externally).
These variables are intentioanlly unused since they are needed to parse through the output. Use "_" as a prefix for these throw away variables.
--- tools/perf/tests/shell/stat+csv_summary.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/tests/shell/stat+csv_summary.sh +2 -2
@@ -10,7 +10,7 @@ set -e # perf stat -e cycles -x' ' -I1000 --interval-count 1 --summary 2>&1 | \ grep -e summary | \ -while read summary num event run pct +while read summary _num _event _run _pct do if [ $summary != "summary" ]; then exit 1
@@ -23,7 +23,7 @@ done # perf stat -e cycles -x' ' -I1000 --interval-count 1 --summary --no-csv-summary 2>&1 | \ grep -e summary | \ -while read num event run pct +while read _num _event _run _pct do exit 1 done
Signature · 1 line
2.39.1
PATCH 8/22 tools/perf/tests: fix shellcheck warning for test_perf_data_converter_json.sh testcase
In reply to Athira RajeevRunning shellcheck on test_perf_data_converter_json.sh throws below warning:
In tests/shell/test_perf_data_converter_json.sh line 42:
if [ $(cat "${result}" | wc -l) -gt "0" ] ; then
^------------------------^ SC2046 (warning): Quote this to prevent word splitting.
Fixed the warning by adding quotes to avoid word splitting.
ShellCheck result with patch:
# shellcheck -S warning test_perf_data_converter_json.sh
#--- tools/perf/tests/shell/test_perf_data_converter_json.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/test_perf_data_converter_json.sh +1 -1
@@ -39,7 +39,7 @@ test_json_converter_command() echo "Testing Perf Data Convertion Command to JSON" perf record -o "$perfdata" -F 99 -g -- perf test -w noploop > /dev/null 2>&1 perf data convert --to-json "$result" --force -i "$perfdata" >/dev/null 2>&1 - if [ $(cat "${result}" | wc -l) -gt "0" ] ; then + if [ "$(cat ${result} | wc -l)" -gt "0" ] ; then echo "Perf Data Converter Command to JSON [SUCCESS]" else echo "Perf Data Converter Command to JSON [FAILED]"
Signature · 1 line
2.39.1
PATCH 9/22 tools/perf/tests: Fix shellcheck issue for stat_bpf_counters.sh testcase
In reply to Athira RajeevRunning shellcheck on stat_bpf_counter.sh generates below warning:
In tests/shell/stat_bpf_counters.sh line 34:
if [ "$base_cycles" == "<not" ]; then
^-- SC3014 (warning): In POSIX sh, == in place of = is undefined.
In tests/shell/stat_bpf_counters.sh line 39:
if [ "$bpf_cycles" == "<not" ]; then
^-- SC3014 (warning): In POSIX sh, == in place of = is undefined.
Fix this by using "=" instead of "==" to work for
all shells.
--- tools/perf/tests/shell/stat_bpf_counters.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/tests/shell/stat_bpf_counters.sh +2 -2
@@ -31,12 +31,12 @@ if ! perf stat --bpf-counters true > /dev/null 2>&1; then fi base_cycles=$(perf stat --no-big-num -e cycles -- perf bench sched messaging -g 1 -l 100 -t 2>&1 | awk '/cycles/ {print $1}') -if [ "$base_cycles" == "<not" ]; then +if [ "$base_cycles" = "<not" ]; then echo "Skipping: cycles event not counted" exit 2 fi bpf_cycles=$(perf stat --no-big-num --bpf-counters -e cycles -- perf bench sched messaging -g 1 -l 100 -t 2>&1 | awk '/cycles/ {print $1}') -if [ "$bpf_cycles" == "<not" ]; then +if [ "$bpf_cycles" = "<not" ]; then echo "Failed: cycles not counted with --bpf-counters" exit 1 fi
Signature · 1 line
2.39.1
PATCH 10/22 tools/perf/tests: Fix shellcheck issues in tests/shell/stat+shadow_stat.sh tetscase
In reply to Athira RajeevRunning shellcheck on stat+shadow_stat.sh generates below warning:
In tests/shell/stat+shadow_stat.sh line 48:
while read cpu num evt hash ipc rest
^--^ SC2034 (warning): hash appears unused. Verify use (or export if used externally).
This variable is intentioanlly unused since it is
needed to parse through the output. Use "_" as a
prefix for this throw away variable.
--- tools/perf/tests/shell/stat+shadow_stat.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/tests/shell/stat+shadow_stat.sh +2 -2
@@ -14,7 +14,7 @@ test_global_aggr() { perf stat -a --no-big-num -e cycles,instructions sleep 1 2>&1 | \ grep -e cycles -e instructions | \ - while read num evt hash ipc rest + while read num evt _hash ipc rest do # skip not counted events if [ "$num" = "<not" ]; then
@@ -45,7 +45,7 @@ test_no_aggr() { perf stat -a -A --no-big-num -e cycles,instructions sleep 1 2>&1 | \ grep ^CPU | \ - while read cpu num evt hash ipc rest + while read cpu num evt _hash ipc rest do # skip not counted events if [ "$num" = "<not" ]; then
Signature · 1 line
2.39.1
PATCH 11/22 tools/perf/tests: Fix shellcheck warning for asm_pure_loop.sh shell script
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on asm_pure_loop.sh throws below warning:
In coresight/asm_pure_loop.sh line 8:
. $(dirname $0)/../lib/coresight.sh
^-----------^ SC2046 (warning): Quote this to prevent word splitting.
Fixed the warning by adding quotes to avoid word splitting.
ShellCheck result with patch:
# shellcheck -S warning coresight/asm_pure_loop.sh
#--- tools/perf/tests/shell/coresight/asm_pure_loop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/coresight/asm_pure_loop.sh +1 -1
@@ -5,7 +5,7 @@ # Carsten Haitzler <[email protected]>, 2021 TEST="asm_pure_loop" -. $(dirname $0)/../lib/coresight.sh +. "$(dirname $0)"/../lib/coresight.sh ARGS="" DATV="out" DATA="$DATD/perf-$TEST-$DATV.data"
Signature · 1 line
2.39.1
PATCH 12/22 tools/perf/tests: Fix shellcheck warning for memcpy_thread_16k_10.sh shell script
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on memcpy_thread_16k_10.sh throws below warning:
In memcpy_thread_16k_10.sh line 8:
. $(dirname $0)/../lib/coresight.sh
^-----------^ SC2046 (warning): Quote this to prevent word splitting.
Fixed the warning by adding quotes to avoid word splitting.
ShellCheck result with patch:
# shellcheck -S warning coresight/memcpy_thread_16k_10.sh
#--- tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh +1 -1
@@ -5,7 +5,7 @@ # Carsten Haitzler <[email protected]>, 2021 TEST="memcpy_thread" -. $(dirname $0)/../lib/coresight.sh +. "$(dirname $0)"/../lib/coresight.sh ARGS="16 10 1" DATV="16k_10" DATA="$DATD/perf-$TEST-$DATV.data"
Signature · 1 line
2.39.1
PATCH 13/22 tools/perf/tests: Fix shellcheck warning for coresight.sh shell script
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on coresight.sh throws below warning:
In lib/coresight.sh line 1:
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
In lib/coresight.sh line 13:
PERFRECOPT="$PERFRECMEM -e cs_etm//u"
^--------^ SC2034 (warning): PERFRECOPT appears unused. Verify use (or export if used externally).
Fixed the warnings by:
- Adding shell directive
- Using export for PERFRECOPT variable
--- tools/perf/tests/shell/lib/coresight.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/tests/shell/lib/coresight.sh +2 -1
@@ -1,3 +1,4 @@ +#!/bin/bash # SPDX-License-Identifier: GPL-2.0 # Carsten Haitzler <[email protected]>, 2021
@@ -10,7 +11,7 @@ # perf record options for the perf tests to use PERFRECMEM="-m ,16M" -PERFRECOPT="$PERFRECMEM -e cs_etm//u" +export PERFRECOPT="$PERFRECMEM -e cs_etm//u" TOOLS=$(dirname $0) DIR="$TOOLS/$TEST"
Signature · 1 line
2.39.1
PATCH 14/22 tools/perf/tests: Fix shellcheck warning for probe.sh shell script
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on probe.sh throws below warning:
In lib/probe.sh line 1:
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
Fixed the warnings by adding shell directive.
--- tools/perf/tests/shell/lib/probe.sh | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/shell/lib/probe.sh +1 -0
@@ -1,3 +1,4 @@ +#!/bin/bash # SPDX-License-Identifier: GPL-2.0 # Arnaldo Carvalho de Melo <[email protected]>, 2017
Signature · 1 line
2.39.1
PATCH 15/22 tools/perf/trace: Fix shellcheck issue for arch_errno_names.sh script
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on arch_errno_names.sh generates below warning:
In arch_errno_names.sh line 20:
local arch="$1"
^--------^ SC3043 (warning): In POSIX sh, 'local' is undefined.......
In arch_errno_names.sh line 61:
local arch
^--------^ SC3043 (warning): In POSIX sh, 'local' is undefined.In arch_errno_names.sh line 67:
printf '\t\treturn errno_to_name__%s(err);\n' $(arch_string "$arch")
^--------------------^ SC2046 (warning): Quote this to prevent word splitting.In arch_errno_names.sh line 69:
printf '\treturn errno_to_name__%s(err);\n' $(arch_string "$default")
^-----------------------^ SC2046 (warning): Quote this to prevent word splitting.Fixed the warnings by:
- Fixing shellcheck warnings for local usage, by removing local from the variable names
- Adding quotes to avoid word splitting
--- tools/perf/trace/beauty/arch_errno_names.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
tools/perf/trace/beauty/arch_errno_names.sh +6 -9
@@ -17,8 +17,7 @@ arch_string() asm_errno_file() { - local arch="$1" - local header + arch="$1" header="$toolsdir/arch/$arch/include/uapi/asm/errno.h" if test -r "$header"; then
@@ -30,8 +29,7 @@ asm_errno_file() create_errno_lookup_func() { - local arch=$(arch_string "$1") - local nr name + arch=$(arch_string "$1") printf "static const char *errno_to_name__%s(int err)\n{\n\tswitch (err) {\n" $arch
@@ -44,8 +42,8 @@ create_errno_lookup_func() process_arch() { - local arch="$1" - local asm_errno=$(asm_errno_file "$arch") + arch="$1" + asm_errno=$(asm_errno_file "$arch") $gcc $CFLAGS $include_path -E -dM -x c $asm_errno \ |grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
@@ -56,9 +54,8 @@ process_arch() create_arch_errno_table_func() { - local archlist="$1" - local default="$2" - local arch + archlist="$1" + default="$2" printf 'const char *arch_syscalls__strerrno(const char *arch, int err)\n' printf '{\n'
Signature · 1 line
2.39.1
PATCH 16/22 tools/perf: Fix shellcheck issue for check-headers.sh script
In reply to Athira RajeevFrom: Kajol Jain <[email protected]>
Running shellcheck on check-headers.sh generates below warning:
In check-headers.sh line 126:
check_2 "tools/$file" "$file" $*
^-- SC2048 (warning): Use "$@" (with quotes) to prevent whitespace problems.
In check-headers.sh line 134:
check_2 "tools/perf/trace/beauty/$file" "$file" $*
^-- SC2048 (warning): Use "$@" (with quotes) to prevent whitespace problems.
In check-headers.sh line 186:
cd tools/perf
^-----------^ SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
Fixed the warnings by:
- Using "$@" instead of $*
- Adding exit condition with cd command
--- tools/perf/check-headers.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/check-headers.sh +3 -3
@@ -123,7 +123,7 @@ check () { shift - check_2 "tools/$file" "$file" $* + check_2 "tools/$file" "$file" "$@" } beauty_check () {
@@ -131,7 +131,7 @@ beauty_check () { shift - check_2 "tools/perf/trace/beauty/$file" "$file" $* + check_2 "tools/perf/trace/beauty/$file" "$file" "$@" } # Check if we have the kernel headers (tools/perf/../../include), else
@@ -183,7 +183,7 @@ done check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c -cd tools/perf +cd tools/perf || exit if [ ${#FAILURES[@]} -gt 0 ] then
Signature · 1 line
2.39.1
PATCH 18/22 tools/perf/tests: Fix shellcheck warnings for unroll_loop_thread_10.sh
In reply to Athira RajeevFix the shellcheck warnings for unroll_loop_thread_10.sh Add quotes to prevent word splitting which are caused by unquoted command expansions.
--- tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh +1 -1
@@ -5,7 +5,7 @@ # Carsten Haitzler <[email protected]>, 2021 TEST="unroll_loop_thread" -. $(dirname $0)/../lib/coresight.sh +. "$(dirname $0)"/../lib/coresight.sh ARGS="10" DATV="10" DATA="$DATD/perf-$TEST-$DATV.data"
Signature · 1 line
2.39.1
PATCH 19/22 tools/perf/tests: Fix shellcheck warnings for lib/probe_vfs_getname.sh
In reply to Athira RajeevRunning shellcheck on probe_vfs_getname fails with below warning:
In ./tools/perf/tests/shell/lib/probe_vfs_getname.sh line 1:
# Arnaldo Carvalho de Melo <[email protected]>, 2017
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
In ./tools/perf/tests/shell/lib/probe_vfs_getname.sh line 14:
local verbose=$1
^-----------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
Fix this:
- by adding shebang in the beginning of the file and
- rename variable verbose to "add_probe_verbose" after removing local
--- tools/perf/tests/shell/lib/probe_vfs_getname.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/tests/shell/lib/probe_vfs_getname.sh +3 -2
@@ -1,3 +1,4 @@ +#!/bin/sh # Arnaldo Carvalho de Melo <[email protected]>, 2017 perf probe -l 2>&1 | grep -q probe:vfs_getname
@@ -10,11 +11,11 @@ cleanup_probe_vfs_getname() { } add_probe_vfs_getname() { - local verbose=$1 + add_probe_verbose=$1 if [ $had_vfs_getname -eq 1 ] ; then line=$(perf probe -L getname_flags 2>&1 | grep -E 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/') perf probe -q "vfs_getname=getname_flags:${line} pathname=result->name:string" || \ - perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:ustring" + perf probe $add_probe_verbose "vfs_getname=getname_flags:${line} pathname=filename:ustring" fi }
Signature · 1 line
2.39.1
PATCH 22/22 tools/perf/arch/x86: Fix syscalltbl.sh to address shellcheck warnings
In reply to Athira RajeevRunning shellcheck on syscalltbl.sh generates below warning:
In ./tools/perf/arch/x86/entry/syscalls/syscalltbl.sh line 27:
while read nr abi name entry compat; do
^-^ SC2034 (warning): abi appears unused. Verify use (or export if used externally).
^----^ SC2034 (warning): compat appears unused. Verify use (or export if used externally).
These variables are intentioanlly unused since they are needed to parse through the output. Use "_" as a prefix for these throw away variables.
--- tools/perf/arch/x86/entry/syscalls/syscalltbl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/x86/entry/syscalls/syscalltbl.sh +1 -1
@@ -24,7 +24,7 @@ sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX) grep '^[0-9]' "$in" | sort -n > $sorted_table max_nr=0 -while read nr abi name entry compat; do +while read nr _abi name entry _compat; do if [ $nr -ge 512 ] ; then # discard compat sycalls break fi
Signature · 1 line
2.39.1
PATCH 21/22 tools/perf/trace: Fix x86_arch_prctl.sh to address shellcheck warnings
In reply to Athira RajeevRunning shellcheck on x86_arch_prctl.sh generates below warning:
In ./tools/perf/trace/beauty/x86_arch_prctl.sh line 10:
local idx=$1
^-------^ SC3043 (warning): In POSIX sh, 'local' is undefined. In ./tools/perf/trace/beauty/x86_arch_prctl.sh line 11:
local prefix=$2
^----------^ SC3043 (warning): In POSIX sh, 'local' is undefined. In ./tools/perf/trace/beauty/x86_arch_prctl.sh line 12:
local first_entry=$3
^---------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.Fix this by removing local since these are variables used only in specific function
--- tools/perf/trace/beauty/x86_arch_prctl.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/trace/beauty/x86_arch_prctl.sh +3 -3
@@ -7,9 +7,9 @@ prctl_arch_header=${x86_header_dir}/prctl.h print_range () { - local idx=$1 - local prefix=$2 - local first_entry=$3 + idx=$1 + prefix=$2 + first_entry=$3 printf "#define x86_arch_prctl_codes_%d_offset %s\n" $idx $first_entry printf "static const char *x86_arch_prctl_codes_%d[] = {\n" $idx
Signature · 1 line
2.39.1
PATCH 17/22 tools/perf/tests: Fix shellcheck warnings for thread_loop_check_tid_10.sh
In reply to Athira RajeevFix the shellcheck warnings for thread_loop_check_tid_10.sh
In ./tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh line 8:
. $(dirname $0)/../lib/coresight.sh
^-----------^ SC2046 (warning): Quote this to prevent word splitting.
Add quotes to prevent word splitting which are caused by unquoted command expansions.
--- tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh +1 -1
@@ -5,7 +5,7 @@ # Carsten Haitzler <[email protected]>, 2021 TEST="thread_loop" -. $(dirname $0)/../lib/coresight.sh +. "$(dirname $0)"/../lib/coresight.sh ARGS="10 1" DATV="check-tid-10th" DATA="$DATD/perf-$TEST-$DATV.data"
Signature · 1 line
2.39.1
PATCH 20/22 tools/perf/tests: Fix the shellcheck wanrings in lib/waiting.sh
In reply to Athira RajeevRunning shellcheck in "lib/waiting.sh" generates below warning:
In ./tools/perf/tests/shell/lib/waiting.sh line 1:
# SPDX-License-Identifier: GPL-2.0
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
Fix this by adding shebang in the beginning of the script.
--- tools/perf/tests/shell/lib/waiting.sh | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/shell/lib/waiting.sh +1 -0
@@ -1,3 +1,4 @@ +#!/bin/sh # SPDX-License-Identifier: GPL-2.0 tenths=date\ +%s%1N
Signature · 1 line
2.39.1
Namhyung Kim
maintainerHello,
Quoted 9 lines · Athira Rajeev
Patchset covers a set of fixes for coding/formatting issues observed while running shellcheck tool on the perf shell scripts.
This cleanup is a pre-requisite to include a build option for shellcheck discussed here: https://www.spinics.net/lists/linux-perf-users/msg25553.html
First set of patches were posted here:
https://lore.kernel.org/linux-perf-users/[email protected]/T/#t
Quoted 4 lines
This patchset covers remaining set of shell scripts which needs fix. Patch 1 is resubmission of patch 6 from the initial series. Patch 15, 16 and 22 touches code from
tools/perf/trace/beauty. Other patches are fixes for scripts fromtools/perf/tests.
Thanks for this work. But it seems there are some issues even after applying this series.
$ for F in $(find tests/shell/ -perm -o=x -name '*.sh'); do
Quoted 1 line
shellcheck $F; done | grep -c -e '(info)' -e '(warning)'
29
$ for F in $(find tests/shell/ -perm -o=x -name '*.sh'); do
Quoted 1 line
shellcheck $F; done | grep ^In
In tests/shell/pipe_test.sh line 10:
In tests/shell/pipe_test.sh line 15:
In tests/shell/pipe_test.sh line 20:
In tests/shell/pipe_test.sh line 21:
In tests/shell/pipe_test.sh line 26:
In tests/shell/pipe_test.sh line 27:
In tests/shell/pipe_test.sh line 33:
In tests/shell/record+zstd_comp_decomp.sh line 16:
In tests/shell/record+zstd_comp_decomp.sh line 22:
In tests/shell/record+zstd_comp_decomp.sh line 27:
In tests/shell/record+zstd_comp_decomp.sh line 28:
In tests/shell/record+zstd_comp_decomp.sh line 29:
In tests/shell/record+zstd_comp_decomp.sh line 30:
In tests/shell/record+zstd_comp_decomp.sh line 36:
In tests/shell/coresight/thread_loop_check_tid_2.sh line 8:
In tests/shell/coresight/thread_loop_check_tid_2.sh line 11:
In tests/shell/coresight/thread_loop_check_tid_2.sh line 14:
Also unfortunately there's some update in the shell tests. Please rebase onto the perf-tools-next.
Thanks,
Namhyung
Quoted 66 lines
Akanksha J N (1):
tools/perf/tests: Fix shellcheck warnings for
trace+probe_vfs_getname.shAthira Rajeev (11):
tools/perf/tests: fixtest_arm_spe_fork.shsignal case issuestools/perf/tests: Fix unused variable references in
stat+csv_summary.shtestcase
tools/perf/tests: fix shellcheck warning for
test_perf_data_converter_json.shtestcase
tools/perf/tests: Fix shellcheck issue forstat_bpf_counters.sh
testcase
tools/perf/tests: Fix shellcheck issues in
tests/shell/stat+shadow_stat.shtetscase
tools/perf/tests: Fix shellcheck warnings forthread_loop_check_tid_10.sh
tools/perf/tests: Fix shellcheck warnings forunroll_loop_thread_10.shtools/perf/tests: Fix shellcheck warnings forlib/probe_vfs_getname.shtools/perf/tests: Fix the shellcheck wanrings inlib/waiting.shtools/perf/trace: Fixx86_arch_prctl.shto address shellcheck warningstools/perf/arch/x86: Fixsyscalltbl.shto address shellcheck warningsKajol Jain (10):
tools/perf/tests: Fix shellcheck warning forprobe_vfs_getname.sh
testcase
tools/perf/tests: Fix shellcheck warning forrecord_offcpu.shtestcasetools/perf/tests: Fix shellcheck issue forlock_contention.shtestcasetools/perf/tests: Fix shellcheck issue forstat_bpf_counters_cgrp.sh
testcase
tools/perf/tests: Fix shellcheck warning forasm_pure_loop.shshell
script
tools/perf/tests: Fix shellcheck warning formemcpy_thread_16k_10.sh
shell script
tools/perf/tests: Fix shellcheck warning forcoresight.shshell scripttools/perf/tests: Fix shellcheck warning forprobe.shshell scripttools/perf/trace: Fix shellcheck issue forarch_errno_names.shscripttools/perf: Fix shellcheck issue forcheck-headers.shscript.../arch/x86/entry/syscalls/syscalltbl.sh | 2 +- tools/perf/check-headers.sh | 6 ++-- .../tests/shell/coresight/asm_pure_loop.sh | 2 +- .../shell/coresight/memcpy_thread_16k_10.sh | 2 +- .../coresight/thread_loop_check_tid_10.sh | 2 +- .../shell/coresight/unroll_loop_thread_10.sh | 2 +- tools/perf/tests/shell/lib/coresight.sh | 3 +- tools/perf/tests/shell/lib/probe.sh | 1 + .../perf/tests/shell/lib/probe_vfs_getname.sh | 5 ++-- tools/perf/tests/shell/lib/waiting.sh | 1 + tools/perf/tests/shell/lock_contention.sh | 12 ++++---- tools/perf/tests/shell/probe_vfs_getname.sh | 4 +-- tools/perf/tests/shell/record_offcpu.sh | 6 ++-- tools/perf/tests/shell/stat+csv_summary.sh | 4 +-- tools/perf/tests/shell/stat+shadow_stat.sh | 4 +-- tools/perf/tests/shell/stat_bpf_counters.sh | 4 +-- .../tests/shell/stat_bpf_counters_cgrp.sh | 28 ++++++++----------- tools/perf/tests/shell/test_arm_spe_fork.sh | 2 +- .../shell/test_perf_data_converter_json.sh | 2 +- .../tests/shell/trace+probe_vfs_getname.sh | 6 ++-- tools/perf/trace/beauty/arch_errno_names.sh | 15 ++++------ tools/perf/trace/beauty/x86_arch_prctl.sh | 6 ++-- 22 files changed, 58 insertions(+), 61 deletions(-)--
2.39.1
Quoted 49 lines · Namhyung Kim
Hello,
Quoted 9 lines · Athira Rajeev
Patchset covers a set of fixes for coding/formatting issues observed while running shellcheck tool on the perf shell scripts.
This cleanup is a pre-requisite to include a build option for shellcheck discussed here: https://www.spinics.net/lists/linux-perf-users/msg25553.html
First set of patches were posted here:
https://lore.kernel.org/linux-perf-users/[email protected]/T/#tQuoted 4 lines
This patchset covers remaining set of shell scripts which needs fix. Patch 1 is resubmission of patch 6 from the initial series. Patch 15, 16 and 22 touches code from
tools/perf/trace/beauty. Other patches are fixes for scripts fromtools/perf/tests.Thanks for this work. But it seems there are some issues even after applying this series.
$ for F in $(find tests/shell/ -perm -o=x -name '*.sh'); doQuoted 1 line
shellcheck $F; done | grep -c -e '(info)' -e '(warning)'
29
$ for F in $(find tests/shell/ -perm -o=x -name '*.sh'); doQuoted 1 line
shellcheck $F; done | grep ^In
In
tests/shell/pipe_test.shline 10:
Intests/shell/pipe_test.shline 15:
Intests/shell/pipe_test.shline 20:
Intests/shell/pipe_test.shline 21:
Intests/shell/pipe_test.shline 26:
Intests/shell/pipe_test.shline 27:
Intests/shell/pipe_test.shline 33:
Intests/shell/record+zstd_comp_decomp.shline 16:
Intests/shell/record+zstd_comp_decomp.shline 22:
Intests/shell/record+zstd_comp_decomp.shline 27:
Intests/shell/record+zstd_comp_decomp.shline 28:
Intests/shell/record+zstd_comp_decomp.shline 29:
Intests/shell/record+zstd_comp_decomp.shline 30:
Intests/shell/record+zstd_comp_decomp.shline 36:
Intests/shell/coresight/thread_loop_check_tid_2.shline 8:
Intests/shell/coresight/thread_loop_check_tid_2.shline 11:
Intests/shell/coresight/thread_loop_check_tid_2.shline 14:
Quoted 2 lines
Also unfortunately there's some update in the shell tests. Please rebase onto the perf-tools-next.
Hi Namhyung
Thanks for checking. Will send an updated version on top of perf-tools-next
Thanks
Athira
Quoted 70 lines
Thanks,
NamhyungQuoted 65 lines
Akanksha J N (1):
tools/perf/tests: Fix shellcheck warnings for
trace+probe_vfs_getname.shAthira Rajeev (11):
tools/perf/tests: fixtest_arm_spe_fork.shsignal case issuestools/perf/tests: Fix unused variable references in
stat+csv_summary.shtestcase
tools/perf/tests: fix shellcheck warning for
test_perf_data_converter_json.shtestcase
tools/perf/tests: Fix shellcheck issue forstat_bpf_counters.sh
testcase
tools/perf/tests: Fix shellcheck issues in
tests/shell/stat+shadow_stat.shtetscase
tools/perf/tests: Fix shellcheck warnings for
thread_loop_check_tid_10.sh
tools/perf/tests: Fix shellcheck warnings forunroll_loop_thread_10.shtools/perf/tests: Fix shellcheck warnings forlib/probe_vfs_getname.shtools/perf/tests: Fix the shellcheck wanrings inlib/waiting.shtools/perf/trace: Fixx86_arch_prctl.shto address shellcheck warningstools/perf/arch/x86: Fixsyscalltbl.shto address shellcheck warningsKajol Jain (10):
tools/perf/tests: Fix shellcheck warning forprobe_vfs_getname.sh
testcase
tools/perf/tests: Fix shellcheck warning forrecord_offcpu.shtestcasetools/perf/tests: Fix shellcheck issue forlock_contention.shtestcasetools/perf/tests: Fix shellcheck issue forstat_bpf_counters_cgrp.sh
testcase
tools/perf/tests: Fix shellcheck warning forasm_pure_loop.shshell
script
tools/perf/tests: Fix shellcheck warning formemcpy_thread_16k_10.sh
shell script
tools/perf/tests: Fix shellcheck warning forcoresight.shshell scripttools/perf/tests: Fix shellcheck warning forprobe.shshell scripttools/perf/trace: Fix shellcheck issue forarch_errno_names.shscripttools/perf: Fix shellcheck issue forcheck-headers.shscript.../arch/x86/entry/syscalls/syscalltbl.sh | 2 +- tools/perf/check-headers.sh | 6 ++-- .../tests/shell/coresight/asm_pure_loop.sh | 2 +- .../shell/coresight/memcpy_thread_16k_10.sh | 2 +- .../coresight/thread_loop_check_tid_10.sh | 2 +- .../shell/coresight/unroll_loop_thread_10.sh | 2 +- tools/perf/tests/shell/lib/coresight.sh | 3 +- tools/perf/tests/shell/lib/probe.sh | 1 + .../perf/tests/shell/lib/probe_vfs_getname.sh | 5 ++-- tools/perf/tests/shell/lib/waiting.sh | 1 + tools/perf/tests/shell/lock_contention.sh | 12 ++++---- tools/perf/tests/shell/probe_vfs_getname.sh | 4 +-- tools/perf/tests/shell/record_offcpu.sh | 6 ++-- tools/perf/tests/shell/stat+csv_summary.sh | 4 +-- tools/perf/tests/shell/stat+shadow_stat.sh | 4 +-- tools/perf/tests/shell/stat_bpf_counters.sh | 4 +-- .../tests/shell/stat_bpf_counters_cgrp.sh | 28 ++++++++----------- tools/perf/tests/shell/test_arm_spe_fork.sh | 2 +- .../shell/test_perf_data_converter_json.sh | 2 +- .../tests/shell/trace+probe_vfs_getname.sh | 6 ++-- tools/perf/trace/beauty/arch_errno_names.sh | 15 ++++------ tools/perf/trace/beauty/x86_arch_prctl.sh | 6 ++-- 22 files changed, 58 insertions(+), 61 deletions(-)--
2.39.1
Re: [PATCH 13/22] tools/perf/tests: Fix shellcheck warning for coresight.sh shell script
In reply to Athira RajeevQuoted 26 lines · Athira Rajeev
From: Kajol Jain <[email protected]>
Running shellcheck on
coresight.shthrows below warning:In
lib/coresight.shline 1:
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.In
lib/coresight.shline 13:
PERFRECOPT="$PERFRECMEM -e cs_etm//u"
^--------^ SC2034 (warning): PERFRECOPT appears unused. Verify use (or export if used externally).Fixed the warnings by:
- Adding shell directive
- Using export for PERFRECOPT variableSigned-off-by Athira Rajeev <[email protected]>Signed-off-by Kajol Jain <[email protected]>--- tools/perf/tests/shell/lib/coresight.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/perf/tests/shell/lib/coresight.sh +0
-0
tools/perf/tests/shell/lib/coresight.sh line 1
Quoted 1 line
tools/perf/tests/shell/lib/coresight.sh +1
-0@@ -1,3 +1,4 @@ +#!/bin/bash
There is a comment a couple of lines below this that says the shebang was excluded for a reason. It's probably worth leaving it excluded or updating the comment.
tools/perf/tests/shell/lib/coresight.sh line 14
Quoted 9 lines
tools/perf/tests/shell/lib/coresight.sh +1
-1# SPDX-License-Identifier: GPL-2.0 # Carsten Haitzler <[email protected]>, 2021@@ -10,7 +11,7 @@ # perf record options for the perf tests to use PERFRECMEM="-m ,16M" -PERFRECOPT="$PERFRECMEM -e cs_etm//u" +export PERFRECOPT="$PERFRECMEM -e cs_etm//u"
This might silence the warning, but there are other variables like DATD that are used in the sub-test scripts in the same way. They just don't trigger the warning because they're also used in the top level one.
I think this change makes the code more misleading than solving any problems. The coresight.sh script is sourced in the same process as the sub tests so exporting variables isn't needed which is why it already works without this change.
Quoted 3 lines
tools/perf/tests/shell/lib/coresight.sh +0
-0TOOLS=$(dirname $0) DIR="$TOOLS/$TEST"