perf test: Change all remaining #!/bin/sh to #!/bin/bash
authorJames Clark <james.clark@linaro.org>
Mon, 23 Jun 2025 09:00:12 +0000 (10:00 +0100)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 26 Jun 2025 17:31:05 +0000 (10:31 -0700)
There are 43 instances of posix shell tests and 35 instances of bash. To
give us a single consistent language for testing in, replace
all #!/bin/sh to #!/bin/bash. Common sources that are included in both
different shells will now work as expected. And we no longer have to fix
up bashisms that appear to work when someone's system has sh symlinked
to bash, but don't work on other systems that have both shells
installed.

Although we could have chosen sh, it's not backwards compatible so it
wouldn't be possible to bulk convert without re-writing the existing
bash tests.

Choosing bash also gives us some nicer features including 'local'
variable definitions and regexes in if statements that are already
widely used in the tests.

It's not expected that there are any users with only sh available due to
the large number of bash tests that exist.

Discussed in relation to running shellcheck here:
https://lore.kernel.org/linux-perf-users/e3751a74be34bbf3781c4644f518702a7270220b.1749785642.git.collin.funk1@gmail.com/

Signed-off-by: James Clark <james.clark@linaro.org>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/20250623-james-perf-bash-tests-v1-1-f572f54d4559@linaro.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
43 files changed:
tools/perf/tests/perf-targz-src-pkg
tools/perf/tests/shell/amd-ibs-swfilt.sh
tools/perf/tests/shell/buildid.sh
tools/perf/tests/shell/coresight/asm_pure_loop.sh
tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh
tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh
tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh
tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh
tools/perf/tests/shell/diff.sh
tools/perf/tests/shell/ftrace.sh
tools/perf/tests/shell/lib/perf_has_symbol.sh
tools/perf/tests/shell/lib/probe_vfs_getname.sh
tools/perf/tests/shell/lib/setup_python.sh
tools/perf/tests/shell/lib/waiting.sh
tools/perf/tests/shell/list.sh
tools/perf/tests/shell/lock_contention.sh
tools/perf/tests/shell/perf-report-hierarchy.sh
tools/perf/tests/shell/probe_vfs_getname.sh
tools/perf/tests/shell/record+probe_libc_inet_pton.sh
tools/perf/tests/shell/record+script_probe_vfs_getname.sh
tools/perf/tests/shell/record+zstd_comp_decomp.sh
tools/perf/tests/shell/record_bpf_filter.sh
tools/perf/tests/shell/record_offcpu.sh
tools/perf/tests/shell/record_sideband.sh
tools/perf/tests/shell/script.sh
tools/perf/tests/shell/stat+csv_summary.sh
tools/perf/tests/shell/stat+shadow_stat.sh
tools/perf/tests/shell/stat_all_pfm.sh
tools/perf/tests/shell/stat_bpf_counters.sh
tools/perf/tests/shell/stat_bpf_counters_cgrp.sh
tools/perf/tests/shell/test_arm_callgraph_fp.sh
tools/perf/tests/shell/test_arm_coresight.sh
tools/perf/tests/shell/test_arm_coresight_disasm.sh
tools/perf/tests/shell/test_arm_spe.sh
tools/perf/tests/shell/test_arm_spe_fork.sh
tools/perf/tests/shell/test_bpf_metadata.sh
tools/perf/tests/shell/test_intel_pt.sh
tools/perf/tests/shell/trace+probe_vfs_getname.sh
tools/perf/tests/shell/trace_btf_enum.sh
tools/perf/tests/shell/trace_exit_race.sh
tools/perf/tests/shell/trace_record_replay.sh
tools/perf/tests/shell/trace_summary.sh
tools/perf/tests/tests-scripts.c

index b3075c168cb21bf13273fba0b85b85735e08d7e8..52a90e6bd8af9230f681befa6f6e51649789ac6a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 # Test one of the main kernel Makefile targets to generate a perf sources tarball
 # suitable for build outside the full kernel sources.
index 83937aa687ccd8595055764b686348e9f107409d..7045ec72ba4cff1881892a90443fd19d5b956e13 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # AMD IBS software filtering
 
 echo "check availability of IBS swfilt"
index 3383ca3399d4c59c6cc4a8497b6d2ab291e7b85c..d2eb213da01d8d22efdd04232ac7399317775d00 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # build id cache operations
 # SPDX-License-Identifier: GPL-2.0
 
index c63bc8c73e262b98cdd920d6af4674fc77035e74..0301904b96379e12be423499eb035047f03819ed 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash -e
 # CoreSight / ASM Pure Loop (exclusive)
 
 # SPDX-License-Identifier: GPL-2.0
index 8e29630957c8d5bc735d9b7f1772f2fa2940a2e6..1f765d69acc35954b64e62bc2fa655ca44b30de8 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash -e
 # CoreSight / Memcpy 16k 10 Threads (exclusive)
 
 # SPDX-License-Identifier: GPL-2.0
index 0c4c82a1c8e15afdce7695a41847079feb64b825..7f43a93a2ac2658594626ef9c4049a9ecd9439bd 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash -e
 # CoreSight / Thread Loop 10 Threads - Check TID (exclusive)
 
 # SPDX-License-Identifier: GPL-2.0
index d3aea9fc6ced9ca4e9a2ab731af1c2f1705fa210..a94d2079ed06e6efa21100a7b0115cc1eaf20949 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash -e
 # CoreSight / Thread Loop 2 Threads - Check TID (exclusive)
 
 # SPDX-License-Identifier: GPL-2.0
index 7429d3a2ae43683be5f77d02d813c308fa541fa5..cb3e97a0a89f3e500767312ff5f0ddd651563c47 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash -e
 # CoreSight / Unroll Loop Thread 10 (exclusive)
 
 # SPDX-License-Identifier: GPL-2.0
index e05a5dc4947955f4f5422f44cbd98d773284ab6b..fe05fdebcab5ee248026ab9e211a2067be3013b9 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf diff tests
 # SPDX-License-Identifier: GPL-2.0
 
index c243731d2fbf67aa750dd33f90a48a2559a1e164..7f8aafcbb761ce7719deca3933e305056512bbe0 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf ftrace tests
 # SPDX-License-Identifier: GPL-2.0
 
index 561c93b75d77a57a28531a60d91d833cd689f24a..0b35cce0b13d5a76ddef158d551bde923dafc243 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
 perf_has_symbol()
index 58debce9ab42a9f09dd900f835e0d52f48047617..88cd0e26d5f670f8503a7b7198367c0eddb1fc08 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
 
 perf probe -l 2>&1 | grep -q probe:vfs_getname
index c2fce1793538db8c5a5ef2d321c8b696de58f294..a58e5536f2eddadc5072684ecc41c72af95438cf 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
 if [ "x$PYTHON" = "x" ]
index bdd5a7c71591073530ede655d12a3b01b5449561..3a152892e0771ecd8852271075c7581670201ed4 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
 tenths=date\ +%s%1N
index 76a9846cff223b2e3d63d3959f42b7f1b1e2e82d..0c04b3159cef01dacb33b0b2bb70dc766109e3cc 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf list tests
 # SPDX-License-Identifier: GPL-2.0
 
index 30d195d4c62f74d09c0b7d02928c28681bcedf10..dde5bc737eb26bf52be81719423610506300b91b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # kernel lock contention analysis test
 # SPDX-License-Identifier: GPL-2.0
 
index 02e3b6aee4ed89a5319bc46898430f5d2b86348d..e3c6f9a24f33efa4aed4833f5d74dc017da1e82e 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf report --hierarchy
 # SPDX-License-Identifier: GPL-2.0
 # Arnaldo Carvalho de Melo <acme@redhat.com> 
index 0f52654c914a0b6982914b1b1a7a3a1ecf260061..5fe5682c28cef4663909c77d3bf95ea29fe810d7 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Add vfs_getname probe to get syscall args filenames (exclusive)
 
 # SPDX-License-Identifier: GPL-2.0
index 9bdf47aabe9d738bcf1b26317c741bd15a608ec7..ab99bef556bf040d47a0ec5bc6f62cb255be1428 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # probe libc's inet_pton & backtrace it with ping (exclusive)
 
 # Installs a probe on libc's inet_pton function, that will use uprobes,
index 1ad252f0d36e0dcd5ee688179e9615854d1afbfe..002f7037f1820531970ca6de7a3c56dc09042853 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Use vfs_getname probe to get syscall args filenames (exclusive)
 
 # Uses the 'perf test shell' library to add probe:vfs_getname to the system
index 8929046e9057c627667343901f9bf5b09695fb2d..f6b82223834e4f2b05c94a95a37c99722c0db13e 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Zstd perf.data compression/decompression
 
 # SPDX-License-Identifier: GPL-2.0
index 4d6c3c1b7fb92579b6ff1fe1a61e8c3d092d80da..383574cb3bd3cfb2a4cd98beb6c30416a88f6489 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf record sample filtering (by BPF) tests
 # SPDX-License-Identifier: GPL-2.0
 
index 21a22efe08f5acfbd657063cc77c4200995f1799..860a2d6f4b75f1c89864dbf5239b01cc1f6aa09b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf record offcpu profiling tests (exclusive)
 # SPDX-License-Identifier: GPL-2.0
 
index ac70ac27d590eb9d8604490e93686df375ce5cc2..2182551873be32c211f6c644b2e7900e51f7be99 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf record sideband tests
 # SPDX-License-Identifier: GPL-2.0
 
index d3e2958d224203d819015242638dcf3248332087..7007f1cdf761b4b11ab19d28d1f8683fda53866b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf script tests
 # SPDX-License-Identifier: GPL-2.0
 
index 323123ff4d193dbfa86e2524ddb04c40ed632143..9a4353db3825ede9234633b7453121373ec72350 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf stat csv summary test
 # SPDX-License-Identifier: GPL-2.0
 
index 0c7d79a230eac2918c0a8a528c3a6824edea738d..8824f445d343083c9389d92138eff69d276eeaf5 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf stat metrics (shadow stat) test
 # SPDX-License-Identifier: GPL-2.0
 
index 4d004f777a6ee0223433c253036b49b95e101787..c08c186af2c42e847d503151e68861b8abe39317 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf all libpfm4 events test
 # SPDX-License-Identifier: GPL-2.0
 
index 95d2ad5d17c67d1cf7d267d4b1a397232fe61953..f43e28a136d3c9bc841e654c8630e72d83ac7cd0 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf stat --bpf-counters test (exclusive)
 # SPDX-License-Identifier: GPL-2.0
 
index 2ec69060c42ffdc598e3b676706a705fb801e5b5..ff2e06c408bc6be1f5420bc7d81e7c2eda21d4fd 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf stat --bpf-counters --for-each-cgroup test
 # SPDX-License-Identifier: GPL-2.0
 
index 9caa36130175964e70b4d524fe18cb7df5694c12..9172dd68a81d3617e5b14e8174795c07c1faccbf 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Check Arm64 callgraphs are complete in fp mode
 # SPDX-License-Identifier: GPL-2.0
 
index 573af9235b725c698ba3ad5e5ca433c38f8c1121..1c750b67d141a188a62699d18060923dc757b3b4 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Check Arm CoreSight trace data recording and synthesized samples (exclusive)
 
 # Uses the 'perf record' to record trace data with Arm CoreSight sinks;
index be2d26303f94b1277c964818d878e5742c70e89f..0dfb4fadf53177814f8f1bd7532a4c283c8ae9a8 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Check Arm CoreSight disassembly script completes without errors (exclusive)
 # SPDX-License-Identifier: GPL-2.0
 
index a69aab70dd8aef164db77714f96c01bd5897aa88..bb76ea88aa14b02a5824465b383bd11cbb244db6 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Check Arm SPE trace data recording and synthesized samples (exclusive)
 
 # Uses the 'perf record' to record trace data of Arm SPE events;
index 8efeef9fb9564a563c37fc717c716ec7f6f54808..5bcca51c03acdaedb2c1506ea5e4df6ccfc25e29 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Check Arm SPE doesn't hang when there are forks
 
 # SPDX-License-Identifier: GPL-2.0
index 11df592fb6613bcb723a117d8139fc8fd52f0860..bc9aef161664a023830e1ecf1f26252daf20893c 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 #
 # BPF metadata collection test.
index 32a9b8dcb2003c65571f0e71fae1c982840f7f04..8ee761f03c38b5d241211006dd6430e025f0b3b9 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Miscellaneous Intel PT testing (exclusive)
 # SPDX-License-Identifier: GPL-2.0
 
index 5d5019988d61d2f6ed4222c52127a037a91d2c6a..7a0b1145d0cd744b8562e82120c8d801c44a8485 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Check open filename arg using perf trace + vfs_getname (exclusive)
 
 # Uses the 'perf test shell' library to add probe:vfs_getname to the system
index c37017bfeb5e86805d882349f6afdeebd36f9a28..572001d75d781562d69e08ed492924629050e4b0 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf trace enum augmentation tests
 # SPDX-License-Identifier: GPL-2.0
 
index 1e247693e756d4398dd415dd3f1b61a30f580f7d..db300cde94fbc0314a0f16b51e1fee9d0ddbf04f 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf trace exit race
 # SPDX-License-Identifier: GPL-2.0
 
index 6b4ed863c1ef86793e75be9db26a52f3b178c3ce..88d30a03dcecb07e2765a0197d4e786f8eb9a4c5 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf trace record and replay
 # SPDX-License-Identifier: GPL-2.0
 
index f9bb7f9388be3fd7e06bd13fadab5350bed19cbd..22e2651d591916763b05337ef2eada053d1d5454 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # perf trace summary (exclusive)
 # SPDX-License-Identifier: GPL-2.0
 
index 3a2a8438f9af1bd12d0d232397d88129730c75cf..f18c4cd337c8f679894b173e95e1acca055848cf 100644 (file)
@@ -85,7 +85,7 @@ static char *shell_test__description(int dir_fd, const char *name)
        if (io.fd < 0)
                return NULL;
 
-       /* Skip first line - should be #!/bin/sh Shebang */
+       /* Skip first line - should be #!/bin/bash Shebang */
        if (io__get_char(&io) != '#')
                goto err_out;
        if (io__get_char(&io) != '!')