Skip to contentSkip to conversation

RFC: Bash autocompletion feature for igt

PATCH Superseded Jan Sokolowski 3 participants 6 messages Jul 14, 2025 – Jul 23, 2025 Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover RFC: Bash autocompletion feature for igt

This is a RFC for a feature that I've found to be useful not only for me, but according to the rest of my team, to be of use to other igt developers and users, that is, bash autocompletion feature.

This RFC currently only has an incomplete support for igt tests, and supports following suggestions: --*, --run-subtest *, --device *.

Before I'll continue with the work, I'd like to ask what are your opinions on this feature? Which tools other than tests could benefit from having autocompletion added?

Cc Zbigniew Kempczyński <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Katarzyna Piecielska <[email protected]>
Cc Juha-Pekka Heikkila <[email protected]>
Cc Ashutosh Dixit <[email protected]>

Jan Sokolowski (2):
RFC /scripts/bash-autocomplete: Create bash autocompletion scripts for
tests
meson: Add bash autocompletion install step

 meson_options.txt                             |  5 ++
 .../install_completions.sh                    | 47 +++++++++++++++++++
 .../uninstall_completions.sh                  | 10 ++++
 scripts/meson.build                           |  4 ++
 4 files changed, 66 insertions(+)
 create mode 100755 scripts/bash_autocompletion/install_completions.sh
 create mode 100755 scripts/bash_autocompletion/uninstall_completions.sh
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 RFC /scripts/bash-autocomplete: Create bash autocompletion scripts for tests

Add installation and uninstallation scripts for bash autocompletion for tests.

Cc Zbigniew Kempczyński <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Katarzyna Piecielska <[email protected]>
Cc Juha-Pekka Heikkila <[email protected]>
Cc Ashutosh Dixit <[email protected]>
---
 .../install_completions.sh                    | 47 +++++++++++++++++++
 .../uninstall_completions.sh                  |  9 ++++
 2 files changed, 56 insertions(+)
 create mode 100755 scripts/bash_autocompletion/install_completions.sh
 create mode 100755 scripts/bash_autocompletion/uninstall_completions.sh
scripts/bash_autocompletion/install_completions.sh new file +47 -0
new file mode 100755
index 000000000..40cc87403
@@ -0,0 +1,47 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+# Copyright © 2025 Intel Corporation
+# Author: Jan Sokolowski <[email protected]>
+
+__generate_completion() {
+
+cat <<EOF > $1
+_$1()
+{
+	local cur prev words cword
+	_init_completion || return
+
+	case \$prev in
+		--run-subtest | --dynamic-subtest)
+			local IFS=$'\n\b'
+			LIST_OF_TESTS="echo -e \`/usr/local/libexec/igt-gpu-tools/$1 --list-subtest\`"
+			COMPREPLY=(\$(compgen -W "\$LIST_OF_TESTS" -- "\$cur"))
+			return
+			;;
+		--device)
+			COMPREPLY=(\$(compgen -o nospace -W "sys: pci: sriov: drm:" -- "\$cur"))
+			;;
+	esac
+
+	if [[ \$cur == -* ]]; then
+		COMPREPLY=(\$(compgen -W '\$(_parse_help "/usr/local/libexec/igt-gpu-tools/$1")' -- "\$cur"))
+	fi
+
+} &&
+complete -F _$1 $1
+EOF
+
+cp $1 /usr/share/bash-completion/completions/
+
+}
+
+mkdir /tmp/igt-gpu-tools-bash-completion-installer
+cd /tmp/igt-gpu-tools-bash-completion-installer
+
+for TEST in `find /usr/local/libexec/igt-gpu-tools -type f | grep -v intel-ci-tests | rev | cut -d'/' -f1 | rev`;
+do
+__generate_completion $TEST
+done
+
+cd -
+rm -rf /tmp/igt-gpu-tools-bash-completion-installer
scripts/bash_autocompletion/uninstall_completions.sh new file +9 -0
new file mode 100755
index 000000000..26345d6e2
@@ -0,0 +1,9 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+# Copyright © 2025 Intel Corporation
+# Author: Jan Sokolowski <[email protected]>
+
+for TEST in `find /usr/local/libexec/igt-gpu-tools -type f | grep -v intel-ci-tests | rev | cut -d'/' -f1 | rev`;
+do
+rm /usr/share/bash-completion/completions/$TEST
+done
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH i-g-t v1 1/2] RFC /scripts/bash-autocomplete: Create bash autocompletion scripts for tests

Quoted 44 lines · Jan Sokolowski

Add installation and uninstallation scripts for bash autocompletion for tests.

Cc Zbigniew Kempczyński <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Katarzyna Piecielska <[email protected]>
Cc Juha-Pekka Heikkila <[email protected]>
Cc Ashutosh Dixit <[email protected]>
---
 .../install_completions.sh                    | 47 +++++++++++++++++++
 .../uninstall_completions.sh                  |  9 ++++
 2 files changed, 56 insertions(+)
 create mode 100755 scripts/bash_autocompletion/install_completions.sh
 create mode 100755 scripts/bash_autocompletion/uninstall_completions.sh
scripts/bash_autocompletion/install_completions.sh new file +22 -0
new file mode 100755
index 000000000..40cc87403
@@ -0,0 +1,47 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+# Copyright © 2025 Intel Corporation
+# Author: Jan Sokolowski <[email protected]>
+
+__generate_completion() {
+
+cat <<EOF > $1
+_$1()
+{
+	local cur prev words cword
+	_init_completion || return
+
+	case \$prev in
+		--run-subtest | --dynamic-subtest)
+			local IFS=$'\n\b'
+			LIST_OF_TESTS="echo -e \`/usr/local/libexec/igt-gpu-tools/$1 --list-subtest\`"
+			COMPREPLY=(\$(compgen -W "\$LIST_OF_TESTS" -- "\$cur"))
+			return
+			;;
+		--device)
+			COMPREPLY=(\$(compgen -o nospace -W "sys: pci: sriov: drm:" -- "\$cur"))

scripts/bash_autocompletion/install_completions.sh line 32

Quoted 10 lines
scripts/bash_autocompletion/install_completions.sh new file +10 -0
+			;;
+	esac
+
+	if [[ \$cur == -* ]]; then
+		COMPREPLY=(\$(compgen -W '\$(_parse_help "/usr/local/libexec/igt-gpu-tools/$1")' -- "\$cur"))
+	fi
+
+} &&
+complete -F _$1 $1
+EOF

I wondered a bit about this and I think the best would be to provide two autocompletions. First for binaries installed, but you have to honour meson 'prefix', instead of hardcoding /usr/local/*. Second, more useful for me which would produce "local" autocompletions (I mean for ./testname). It might be installed to ~/.bash_completion.d/igt or ~/.bash_completion.igt (or wherever in my home simply sourced from ~/.bashrc. Local ./testname autocompletion is more useful when you develop the test (I execute them in build dir without installing).

At the moment I would guard both under 'disabled' flag.

scripts/bash_autocompletion/install_completions.sh line 38

Quoted 6 lines
scripts/bash_autocompletion/install_completions.sh new file +6 -0
+
+cp $1 /usr/share/bash-completion/completions/
+
+}
+
+mkdir /tmp/igt-gpu-tools-bash-completion-installer

mktemp?

scripts/bash_autocompletion/install_completions.sh line 41

Quoted 3 lines
scripts/bash_autocompletion/install_completions.sh new file +3 -0
+cd /tmp/igt-gpu-tools-bash-completion-installer
+
+for TEST in `find /usr/local/libexec/igt-gpu-tools -type f | grep -v intel-ci-tests | rev | cut -d'/' -f1 | rev`;

I think better would be to use igt_runner -L to produce list of tests. Unfortunately it depends on -Drunner=enabled flag. I think instead find you proposed it would be to use:

	$ find build -type f -executable

--
Zbigniew

Quoted 24 lines
scripts/bash_autocompletion/install_completions.sh new file +6 -0
+do
+__generate_completion $TEST
+done
+
+cd -
+rm -rf /tmp/igt-gpu-tools-bash-completion-installer
scripts/bash_autocompletion/uninstall_completions.sh new file +9 -0
new file mode 100755
index 000000000..26345d6e2
@@ -0,0 +1,9 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+# Copyright © 2025 Intel Corporation
+# Author: Jan Sokolowski <[email protected]>
+
+for TEST in `find /usr/local/libexec/igt-gpu-tools -type f | grep -v intel-ci-tests | rev | cut -d'/' -f1 | rev`;
+do
+rm /usr/share/bash-completion/completions/$TEST
+done
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH i-g-t v1 1/2] RFC /scripts/bash-autocomplete: Create bash autocompletion scripts for tests

In reply to Jan Sokolowski

Hi Jan,
On 2025-07-14 at 12:01:29 +0000, Jan Sokolowski wrote:

imho subject could be improved (when it will exit from RFC):

[PATCH i-g-t v1 1/2] scripts: Add bash autocompletion

Quoted 9 lines

Add installation and uninstallation scripts for bash autocompletion for tests.

Cc Zbigniew Kempczyński <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Katarzyna Piecielska <[email protected]>
Cc Juha-Pekka Heikkila <[email protected]>
Cc Ashutosh Dixit <[email protected]>
Quoted 6 lines
---
 .../install_completions.sh                    | 47 +++++++++++++++++++
 .../uninstall_completions.sh                  |  9 ++++
 2 files changed, 56 insertions(+)
 create mode 100755 scripts/bash_autocompletion/install_completions.sh
 create mode 100755 scripts/bash_autocompletion/uninstall_completions.sh

Is it possible to have it in only one script with two options --intall
--uninstall|--remove

Regards,
Kamil

Quoted 72 lines
scripts/bash_autocompletion/install_completions.sh new file +47 -0
new file mode 100755
index 000000000..40cc87403
@@ -0,0 +1,47 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+# Copyright © 2025 Intel Corporation
+# Author: Jan Sokolowski <[email protected]>
+
+__generate_completion() {
+
+cat <<EOF > $1
+_$1()
+{
+	local cur prev words cword
+	_init_completion || return
+
+	case \$prev in
+		--run-subtest | --dynamic-subtest)
+			local IFS=$'\n\b'
+			LIST_OF_TESTS="echo -e \`/usr/local/libexec/igt-gpu-tools/$1 --list-subtest\`"
+			COMPREPLY=(\$(compgen -W "\$LIST_OF_TESTS" -- "\$cur"))
+			return
+			;;
+		--device)
+			COMPREPLY=(\$(compgen -o nospace -W "sys: pci: sriov: drm:" -- "\$cur"))
+			;;
+	esac
+
+	if [[ \$cur == -* ]]; then
+		COMPREPLY=(\$(compgen -W '\$(_parse_help "/usr/local/libexec/igt-gpu-tools/$1")' -- "\$cur"))
+	fi
+
+} &&
+complete -F _$1 $1
+EOF
+
+cp $1 /usr/share/bash-completion/completions/
+
+}
+
+mkdir /tmp/igt-gpu-tools-bash-completion-installer
+cd /tmp/igt-gpu-tools-bash-completion-installer
+
+for TEST in `find /usr/local/libexec/igt-gpu-tools -type f | grep -v intel-ci-tests | rev | cut -d'/' -f1 | rev`;
+do
+__generate_completion $TEST
+done
+
+cd -
+rm -rf /tmp/igt-gpu-tools-bash-completion-installer
scripts/bash_autocompletion/uninstall_completions.sh new file +9 -0
new file mode 100755
index 000000000..26345d6e2
@@ -0,0 +1,9 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+# Copyright © 2025 Intel Corporation
+# Author: Jan Sokolowski <[email protected]>
+
+for TEST in `find /usr/local/libexec/igt-gpu-tools -type f | grep -v intel-ci-tests | rev | cut -d'/' -f1 | rev`;
+do
+rm /usr/share/bash-completion/completions/$TEST
+done
Signature · 1 line
2.34.1
#4 lore raw

PATCH 2/2 RFC: meson: Add bash autocompletion install step

In reply to Jan Sokolowski

Add a call to bash autocompletion installer
script.

Cc Zbigniew Kempczyński <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Katarzyna Piecielska <[email protected]>
Cc Juha-Pekka Heikkila <[email protected]>
Cc Ashutosh Dixit <[email protected]>
---
 meson_options.txt   | 5 +++++
 scripts/meson.build | 4 ++++
 2 files changed, 9 insertions(+)
meson_options.txt +5 -0
index e23402b36..01bd1dc6d 100644
@@ -82,3 +82,8 @@ option('version_hash',
 option('srcdir',
        type : 'string',
        description : 'Override the source code path embedded inside target binaries (optional)')
+
+option('bash_autocomopletion',
+       type : 'feature',
+       value : 'enabled',
+       description : 'Install bash autocompletion scripts')
scripts/meson.build +4 -0
index 6e64065c5..3df0b6a96 100644
@@ -15,3 +15,7 @@ endif
 igt_doc_script = find_program('igt_doc.py', required : build_testplan)
 gen_rst_index = find_program('gen_rst_index', required : build_sphinx)
 generate_iga64_codes = find_program('generate_iga64_codes')
+
+if get_option('bash_autocomopletion').enabled()
+       meson.add_install_script('bash_autocompletion/install_completions.sh')
+endif
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH i-g-t v1 2/2] RFC: meson: Add bash autocompletion install step

Quoted 19 lines · Jan Sokolowski

Add a call to bash autocompletion installer
script.

Cc Zbigniew Kempczyński <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Katarzyna Piecielska <[email protected]>
Cc Juha-Pekka Heikkila <[email protected]>
Cc Ashutosh Dixit <[email protected]>
---
 meson_options.txt   | 5 +++++
 scripts/meson.build | 4 ++++
 2 files changed, 9 insertions(+)
meson_options.txt +0 -0
index e23402b36..01bd1dc6d 100644

meson_options.txt option('version_hash', · line 86

Quoted 5 lines
meson_options.txt +2 -0
@@ -82,3 +82,8 @@ option('version_hash',
 option('srcdir',
        type : 'string',
        description : 'Override the source code path embedded inside target binaries (optional)')
+
+option('bash_autocomopletion',

typo

meson_options.txt option('version_hash', · line 88

Quoted 2 lines
meson_options.txt +2 -0
+       type : 'feature',
+       value : 'enabled',

I think it should be 'disabled' at the moment.

--
Zbigniew

Quoted 16 lines
meson_options.txt +1 -0
+       description : 'Install bash autocompletion scripts')
scripts/meson.build +4 -0
index 6e64065c5..3df0b6a96 100644
@@ -15,3 +15,7 @@ endif
 igt_doc_script = find_program('igt_doc.py', required : build_testplan)
 gen_rst_index = find_program('gen_rst_index', required : build_sphinx)
 generate_iga64_codes = find_program('generate_iga64_codes')
+
+if get_option('bash_autocomopletion').enabled()
+       meson.add_install_script('bash_autocompletion/install_completions.sh')
+endif
Signature · 1 line
2.34.1