[PATCH v2] perf test perftool_testsuite: Add missing shellcheck source directive

Subsystems: performance events subsystem, the rest

STALE282d

2 messages, 2 authors, 2026-01-07 · open the first message on its own page

[PATCH v2] perf test perftool_testsuite: Add missing shellcheck source directive

From: Nicolas Schier <hidden>
Date: 2026-01-06 13:00:02

Add shellcheck source directive to prevent old versions of shellcheck to
issue warning SC1090 for perf shell scripts, e.g.:

    In tests/shell/base_probe/test_line_semantics.sh line 20:
    . "$DIR_PATH/../common/init.sh"
      ^---------------------------^ SC1090: Can't follow non-constant source. Use a directive to specify location.

shellcheck versions since 0.7.2 handle such dynamic source includes in a
more friendly manner [1]; older versions show the warning and thus
break the perf build unless NO_SHELLCHECK is set to '1'.

Fixes: 241f21be7d0f ("perf test perftool_testsuite: Use absolute paths")
Link: https://github.com/koalaman/shellcheck/issues/1998 # [1]
Signed-off-by: Nicolas Schier <redacted>
---
Changes in v2:
  * Extend commit message and mention affected shellcheck versions
    (< 0.7.2)
  * Link to v1: https://lore.kernel.org/r/20251229-perf-add-shellcheck-sc1090-annotation-v1-1-083821aeefa6@avm.de
---
Another way w/o new shellcheck directives would be to update the minimum
shellcheck version in tools/perf/Makefile.perf to 0.7.2.  I'll send
that as an alternative patch.

Newer versions of shellcheck are available since e.g.
Debian bookworm 12 (released: 2023/06), Ubuntu jammy 22.04 (released:
2022/04), Fedora 37 (released: 2022/11)
---
 tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh | 1 +
 tools/perf/tests/shell/base_probe/test_adding_kernel.sh      | 1 +
 tools/perf/tests/shell/base_probe/test_basic.sh              | 1 +
 tools/perf/tests/shell/base_probe/test_invalid_options.sh    | 1 +
 tools/perf/tests/shell/base_probe/test_line_semantics.sh     | 1 +
 tools/perf/tests/shell/base_report/setup.sh                  | 1 +
 tools/perf/tests/shell/base_report/test_basic.sh             | 1 +
 7 files changed, 7 insertions(+)
diff --git a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh b/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh
index f74aab5c5d7f85b04f68090515acdfa49b6bccf3..06fca7d2cbb407eaea57df79bef11e26b49f9841 100755
--- a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh
+++ b/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh
@@ -17,6 +17,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 # skip if not supported
diff --git a/tools/perf/tests/shell/base_probe/test_adding_kernel.sh b/tools/perf/tests/shell/base_probe/test_adding_kernel.sh
index 555a825d55f24543e3b6d105660c2cb505080e04..b6f9c4a697921b232a4795afcba10882e6101ce9 100755
--- a/tools/perf/tests/shell/base_probe/test_adding_kernel.sh
+++ b/tools/perf/tests/shell/base_probe/test_adding_kernel.sh
@@ -17,6 +17,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 # shellcheck source=lib/probe_vfs_getname.sh
diff --git a/tools/perf/tests/shell/base_probe/test_basic.sh b/tools/perf/tests/shell/base_probe/test_basic.sh
index 162838ddc974d04d806b22366866f8201802f969..f2db48cb9b8feffc6de1f3ea50a1dc99cb44f377 100755
--- a/tools/perf/tests/shell/base_probe/test_basic.sh
+++ b/tools/perf/tests/shell/base_probe/test_basic.sh
@@ -16,6 +16,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 if ! check_kprobes_available; then
diff --git a/tools/perf/tests/shell/base_probe/test_invalid_options.sh b/tools/perf/tests/shell/base_probe/test_invalid_options.sh
index 44a3ae014bfa2ffa831b86796b2e5187311d7303..3ae9afe6288b04d90777ebf5cdc64342f270eb75 100755
--- a/tools/perf/tests/shell/base_probe/test_invalid_options.sh
+++ b/tools/perf/tests/shell/base_probe/test_invalid_options.sh
@@ -16,6 +16,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 if ! check_kprobes_available; then
diff --git a/tools/perf/tests/shell/base_probe/test_line_semantics.sh b/tools/perf/tests/shell/base_probe/test_line_semantics.sh
index 576442d87a44400a65edce95b23070ce56f32993..4a1189c6cb0cbc269672c47efa617d20b0b4e795 100755
--- a/tools/perf/tests/shell/base_probe/test_line_semantics.sh
+++ b/tools/perf/tests/shell/base_probe/test_line_semantics.sh
@@ -17,6 +17,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 if ! check_kprobes_available; then
diff --git a/tools/perf/tests/shell/base_report/setup.sh b/tools/perf/tests/shell/base_report/setup.sh
index bb49b0fabb11499d4fb20d3c8c325d7f081cf18b..bc1dd8c128a6a57fd0a8ba94e51f0b11453a31de 100755
--- a/tools/perf/tests/shell/base_report/setup.sh
+++ b/tools/perf/tests/shell/base_report/setup.sh
@@ -15,6 +15,7 @@
 DIR_PATH="$(dirname $0)"
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 TEST_RESULT=0
diff --git a/tools/perf/tests/shell/base_report/test_basic.sh b/tools/perf/tests/shell/base_report/test_basic.sh
index 0dfe7e5fd1ca609535fa70b03c8301373ec3fe6f..4cbc7c67f7bb9ccd79f950b731c604a426c5bfd0 100755
--- a/tools/perf/tests/shell/base_report/test_basic.sh
+++ b/tools/perf/tests/shell/base_report/test_basic.sh
@@ -16,6 +16,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 
---
base-commit: 9ace4753a5202b02191d54e9fdf7f9e3d02b85eb
change-id: 20251229-perf-add-shellcheck-sc1090-annotation-fec8beb43c1e

Best regards,
-- 
Nicolas Schier

Re: [PATCH v2] perf test perftool_testsuite: Add missing shellcheck source directive

From: Namhyung Kim <namhyung@kernel.org>
Date: 2026-01-07 07:36:12

Hello,

On Tue, Jan 06, 2026 at 01:59:25PM +0100, Nicolas Schier wrote:
Add shellcheck source directive to prevent old versions of shellcheck to
issue warning SC1090 for perf shell scripts, e.g.:

    In tests/shell/base_probe/test_line_semantics.sh line 20:
    . "$DIR_PATH/../common/init.sh"
      ^---------------------------^ SC1090: Can't follow non-constant source. Use a directive to specify location.

shellcheck versions since 0.7.2 handle such dynamic source includes in a
more friendly manner [1]; older versions show the warning and thus
break the perf build unless NO_SHELLCHECK is set to '1'.

Fixes: 241f21be7d0f ("perf test perftool_testsuite: Use absolute paths")
Link: https://github.com/koalaman/shellcheck/issues/1998 # [1]
Signed-off-by: Nicolas Schier <redacted>
---
Changes in v2:
  * Extend commit message and mention affected shellcheck versions
    (< 0.7.2)
  * Link to v1: https://lore.kernel.org/r/20251229-perf-add-shellcheck-sc1090-annotation-v1-1-083821aeefa6@avm.de
---
Another way w/o new shellcheck directives would be to update the minimum
shellcheck version in tools/perf/Makefile.perf to 0.7.2.  I'll send
that as an alternative patch.
Thanks for doing this, I think that's much simpler than this.
quoted hunk
Newer versions of shellcheck are available since e.g.
Debian bookworm 12 (released: 2023/06), Ubuntu jammy 22.04 (released:
2022/04), Fedora 37 (released: 2022/11)
---
 tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh | 1 +
 tools/perf/tests/shell/base_probe/test_adding_kernel.sh      | 1 +
 tools/perf/tests/shell/base_probe/test_basic.sh              | 1 +
 tools/perf/tests/shell/base_probe/test_invalid_options.sh    | 1 +
 tools/perf/tests/shell/base_probe/test_line_semantics.sh     | 1 +
 tools/perf/tests/shell/base_report/setup.sh                  | 1 +
 tools/perf/tests/shell/base_report/test_basic.sh             | 1 +
 7 files changed, 7 insertions(+)
diff --git a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh b/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh
index f74aab5c5d7f85b04f68090515acdfa49b6bccf3..06fca7d2cbb407eaea57df79bef11e26b49f9841 100755
--- a/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh
+++ b/tools/perf/tests/shell/base_probe/test_adding_blacklisted.sh
@@ -17,6 +17,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
I'm not sure how shellcheck handles the source directory, but I think we
used to assume it's the directory where the current script is on.

Something like:

  # shellcheck source=../common/init.sh

But as I said, it'd be better to increase the minimal shellcheck version
if it can handle that automatically.

Thanks,
Namhyung
quoted hunk
 
 # skip if not supported
diff --git a/tools/perf/tests/shell/base_probe/test_adding_kernel.sh b/tools/perf/tests/shell/base_probe/test_adding_kernel.sh
index 555a825d55f24543e3b6d105660c2cb505080e04..b6f9c4a697921b232a4795afcba10882e6101ce9 100755
--- a/tools/perf/tests/shell/base_probe/test_adding_kernel.sh
+++ b/tools/perf/tests/shell/base_probe/test_adding_kernel.sh
@@ -17,6 +17,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 # shellcheck source=lib/probe_vfs_getname.sh
diff --git a/tools/perf/tests/shell/base_probe/test_basic.sh b/tools/perf/tests/shell/base_probe/test_basic.sh
index 162838ddc974d04d806b22366866f8201802f969..f2db48cb9b8feffc6de1f3ea50a1dc99cb44f377 100755
--- a/tools/perf/tests/shell/base_probe/test_basic.sh
+++ b/tools/perf/tests/shell/base_probe/test_basic.sh
@@ -16,6 +16,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 if ! check_kprobes_available; then
diff --git a/tools/perf/tests/shell/base_probe/test_invalid_options.sh b/tools/perf/tests/shell/base_probe/test_invalid_options.sh
index 44a3ae014bfa2ffa831b86796b2e5187311d7303..3ae9afe6288b04d90777ebf5cdc64342f270eb75 100755
--- a/tools/perf/tests/shell/base_probe/test_invalid_options.sh
+++ b/tools/perf/tests/shell/base_probe/test_invalid_options.sh
@@ -16,6 +16,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 if ! check_kprobes_available; then
diff --git a/tools/perf/tests/shell/base_probe/test_line_semantics.sh b/tools/perf/tests/shell/base_probe/test_line_semantics.sh
index 576442d87a44400a65edce95b23070ce56f32993..4a1189c6cb0cbc269672c47efa617d20b0b4e795 100755
--- a/tools/perf/tests/shell/base_probe/test_line_semantics.sh
+++ b/tools/perf/tests/shell/base_probe/test_line_semantics.sh
@@ -17,6 +17,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 if ! check_kprobes_available; then
diff --git a/tools/perf/tests/shell/base_report/setup.sh b/tools/perf/tests/shell/base_report/setup.sh
index bb49b0fabb11499d4fb20d3c8c325d7f081cf18b..bc1dd8c128a6a57fd0a8ba94e51f0b11453a31de 100755
--- a/tools/perf/tests/shell/base_report/setup.sh
+++ b/tools/perf/tests/shell/base_report/setup.sh
@@ -15,6 +15,7 @@
 DIR_PATH="$(dirname $0)"
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 TEST_RESULT=0
diff --git a/tools/perf/tests/shell/base_report/test_basic.sh b/tools/perf/tests/shell/base_report/test_basic.sh
index 0dfe7e5fd1ca609535fa70b03c8301373ec3fe6f..4cbc7c67f7bb9ccd79f950b731c604a426c5bfd0 100755
--- a/tools/perf/tests/shell/base_report/test_basic.sh
+++ b/tools/perf/tests/shell/base_report/test_basic.sh
@@ -16,6 +16,7 @@ DIR_PATH="$(dirname $0)"
 TEST_RESULT=0
 
 # include working environment
+# shellcheck source=tests/shell/common/init.sh
 . "$DIR_PATH/../common/init.sh"
 
 
---
base-commit: 9ace4753a5202b02191d54e9fdf7f9e3d02b85eb
change-id: 20251229-perf-add-shellcheck-sc1090-annotation-fec8beb43c1e

Best regards,
-- 
Nicolas Schier
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help