Skip to contentSkip to conversation

RFC: Bash autocompletion feature for igt

PATCH In review Jan Sokolowski 3 participants 4 messages Jan 30 – Feb 11 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 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 (1):
RFC /scripts/bash-autocomplete: Create bash autocompletion scripts for
tests

 meson.sh                                      |  6 ++
 .../install_completions.sh                    | 85 +++++++++++++++++++
 2 files changed, 91 insertions(+)
 create mode 100755 scripts/bash_autocompletion/install_completions.sh
Signature · 1 line
2.43.0
#1 lore raw

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

Add installation and uninstallation scripts for bash autocompletion for tests.

To install: run 'make install-completions' after generating Makefile via meson.sh.

To uninstall: run 'make uninstall-completions'.

By default autocompletions are installed to ~/.local/share/bash-completion/completions and use build/tests/test_list.txt directory as list of what completions to install.

In order to install them as root to /usr/share/bash-completion/completions, run ./install_completions.sh --install from scripts/bash_autocompletion directory. It uses /usr/local/libexec/igt-gpu-tools/test_list.txt as list of what completions to install.

Please note that these completions might be unavailable due to .bashrc configuration, refer to distribution documentation.

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.sh                                      |  6 ++
 .../install_completions.sh                    | 85 +++++++++++++++++++
 2 files changed, 91 insertions(+)
 create mode 100755 scripts/bash_autocompletion/install_completions.sh
meson.sh +6 -0
index 1563a85b1..7f1f8b987 100755
@@ -60,6 +60,12 @@ install: build/build.ninja
 uninstall: build/build.ninja
 	\$(Q)ninja -C build uninstall \$(quiet_build)
 
+install-completions:
+	./scripts/bash_autocompletion/install_completions.sh --local-install
+
+uninstall-completions:
+	./scripts/bash_autocompletion/install_completions.sh --local-uninstall
+
 docs:
 	\$(Q)ninja -C build igt-gpu-tools-doc \$(quiet_build)
 
scripts/bash_autocompletion/install_completions.sh new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

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

Quoted 6 lines · Jan Sokolowski

Add installation and uninstallation scripts for bash autocompletion for tests.

To install: run 'make install-completions' after generating Makefile via meson.sh.

Quoted 6 lines

To uninstall: run 'make uninstall-completions'.

By default autocompletions are installed to ~/.local/share/bash-completion/completions and use build/tests/test_list.txt directory as list of what completions to install.

It would be good if during 'install-completions' step you would print where it is installing the completions.

Quoted 9 lines

In order to install them as root to /usr/share/bash-completion/completions, run ./install_completions.sh --install from scripts/bash_autocompletion directory. It uses /usr/local/libexec/igt-gpu-tools/test_list.txt as list of what completions to install.

Please note that these completions might be unavailable due to .bashrc configuration, refer to distribution documentation.

Too vague, add as an example for Ubuntu root may not source /etc/bash_completion because it is commented out.

Quoted 18 lines
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.sh                                      |  6 ++
 .../install_completions.sh                    | 85 +++++++++++++++++++
 2 files changed, 91 insertions(+)
 create mode 100755 scripts/bash_autocompletion/install_completions.sh
meson.sh +0 -0
index 1563a85b1..7f1f8b987 100755

meson.sh install: build/build.ninja · line 63

Quoted 4 lines
meson.sh +1 -0
@@ -60,6 +60,12 @@ install: build/build.ninja
 uninstall: build/build.ninja
 	\$(Q)ninja -C build uninstall \$(quiet_build)
 
+install-completions:

+install-completions: all

meson.sh install: build/build.ninja · line 66

Quoted 3 lines
meson.sh +3 -0
+	./scripts/bash_autocompletion/install_completions.sh --local-install
+
+uninstall-completions:

+uninstall-completions: all

Quoted 11 lines
meson.sh +2 -0
+	./scripts/bash_autocompletion/install_completions.sh --local-uninstall
+
 docs:
 	\$(Q)ninja -C build igt-gpu-tools-doc \$(quiet_build)
 
scripts/bash_autocompletion/install_completions.sh new file +0 -0
new file mode 100755
index 000000000..5aa739f2e

scripts/bash_autocompletion/install_completions.sh line 9

Quoted 9 lines
scripts/bash_autocompletion/install_completions.sh new file +9 -0
@@ -0,0 +1,85 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+# Copyright © 2025 Intel Corporation
+# Author: Jan Sokolowski <[email protected]>
+
+usage() {
+echo "install_completions.sh - creates bash autocompletion scripts for installed igt gpu tools tests."
+echo "Usage: "
+echo "--install : installs completions for installed /usr/local/libexec/igt_gpu_tools tests to ~/.local/share/bash-completion/completions" 

Whitespace at the end.

Anyway it is desirable change for me, just address my minor nits.

--
Zbigniew

Quoted 79 lines
scripts/bash_autocompletion/install_completions.sh new file +76 -0
+echo "--local-install : uses ../../build/tests as list of completions to install to ~/.local/share/bash-completion/completions"
+echo "--uninstall : uninstalls completions installed to /usrl/local/libexec/igt_gpu_tools from ~/.local/share/bash-completion/completions"
+echo "--local-uninstall : uses ../../build/tests as list of completions to uninstall from ~/.local/share/bash-completion-completions"
+}
+
+__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="\`\$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 "\$1")' -- "\$cur"))
+	fi
+
+} &&
+
+complete -F _$1 $1
+EOF
+
+}
+
+__install_completions() {
+	mkdir -p ~/.local/share/bash-completion/completions
+	cd ~/.local/share/bash-completion/completions
+	for ENTRY in `sed -n 2p $1/test-list-full.txt`;
+	do
+		TEST=`echo $ENTRY | rev | cut -f1 -d'/' | rev`
+		__generate_completion $TEST
+	done
+	cd - > /dev/null
+}
+
+__uninstall_completions() {
+	cd ~/.local/share/bash-completion/completions
+	for ENTRY in `sed -n 2p $1/test-list-full.txt`;
+	do
+		TEST=`echo $ENTRY | rev | cut -f1 -d'/' | rev`
+		rm ~/.local/share/bash-completion/completions/$TEST
+	done
+	cd - > /dev/null
+}
+
+case "$1" in
+	"--install")
+		__install_completions "/usr/local/libexec/igt-gpu-tools"
+		;;
+	"--local-install")
+		__install_completions "$PWD/build/tests"
+		;;
+	"--uninstall")
+		__uninstall_completions "/usr/local/libexec/igt-gpu-tools"
+		;;
+	"--local-uninstall")
+		__uninstall_completions "$PWD/build/tests"
+		;;
+	"--help")
+		usage
+		;;
+	*)
+		__install_completions "/usr/local/libexec/igt-gpu-tools"
+		;;
+esac
Signature · 1 line
2.43.0
#3 lore raw

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

In reply to Jan Sokolowski

Hi Jan,
On 2026-01-30 at 14:11:22 +0100, Jan Sokolowski wrote:

when you address Zbigniew nits please resend without RFC, also remove '/' from begin, imho you could also make it a little shorter, so it will be for example:

[PATCH i-g-t v2 1/1] scripts/bash-autocomplete: Create autocompletion for tests

Regards,
Kamil

Quoted 145 lines

Add installation and uninstallation scripts for bash autocompletion for tests.

To install: run 'make install-completions' after generating Makefile via meson.sh.

To uninstall: run 'make uninstall-completions'.

By default autocompletions are installed to ~/.local/share/bash-completion/completions and use build/tests/test_list.txt directory as list of what completions to install.

In order to install them as root to /usr/share/bash-completion/completions, run ./install_completions.sh --install from scripts/bash_autocompletion directory. It uses /usr/local/libexec/igt-gpu-tools/test_list.txt as list of what completions to install.

Please note that these completions might be unavailable due to .bashrc configuration, refer to distribution documentation.

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.sh                                      |  6 ++
 .../install_completions.sh                    | 85 +++++++++++++++++++
 2 files changed, 91 insertions(+)
 create mode 100755 scripts/bash_autocompletion/install_completions.sh
meson.sh +6 -0
index 1563a85b1..7f1f8b987 100755
@@ -60,6 +60,12 @@ install: build/build.ninja
 uninstall: build/build.ninja
 	\$(Q)ninja -C build uninstall \$(quiet_build)
 
+install-completions:
+	./scripts/bash_autocompletion/install_completions.sh --local-install
+
+uninstall-completions:
+	./scripts/bash_autocompletion/install_completions.sh --local-uninstall
+
 docs:
 	\$(Q)ninja -C build igt-gpu-tools-doc \$(quiet_build)
 
scripts/bash_autocompletion/install_completions.sh new file +85 -0
new file mode 100755
index 000000000..5aa739f2e
@@ -0,0 +1,85 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+# Copyright © 2025 Intel Corporation
+# Author: Jan Sokolowski <[email protected]>
+
+usage() {
+echo "install_completions.sh - creates bash autocompletion scripts for installed igt gpu tools tests."
+echo "Usage: "
+echo "--install : installs completions for installed /usr/local/libexec/igt_gpu_tools tests to ~/.local/share/bash-completion/completions" 
+echo "--local-install : uses ../../build/tests as list of completions to install to ~/.local/share/bash-completion/completions"
+echo "--uninstall : uninstalls completions installed to /usrl/local/libexec/igt_gpu_tools from ~/.local/share/bash-completion/completions"
+echo "--local-uninstall : uses ../../build/tests as list of completions to uninstall from ~/.local/share/bash-completion-completions"
+}
+
+__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="\`\$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 "\$1")' -- "\$cur"))
+	fi
+
+} &&
+
+complete -F _$1 $1
+EOF
+
+}
+
+__install_completions() {
+	mkdir -p ~/.local/share/bash-completion/completions
+	cd ~/.local/share/bash-completion/completions
+	for ENTRY in `sed -n 2p $1/test-list-full.txt`;
+	do
+		TEST=`echo $ENTRY | rev | cut -f1 -d'/' | rev`
+		__generate_completion $TEST
+	done
+	cd - > /dev/null
+}
+
+__uninstall_completions() {
+	cd ~/.local/share/bash-completion/completions
+	for ENTRY in `sed -n 2p $1/test-list-full.txt`;
+	do
+		TEST=`echo $ENTRY | rev | cut -f1 -d'/' | rev`
+		rm ~/.local/share/bash-completion/completions/$TEST
+	done
+	cd - > /dev/null
+}
+
+case "$1" in
+	"--install")
+		__install_completions "/usr/local/libexec/igt-gpu-tools"
+		;;
+	"--local-install")
+		__install_completions "$PWD/build/tests"
+		;;
+	"--uninstall")
+		__uninstall_completions "/usr/local/libexec/igt-gpu-tools"
+		;;
+	"--local-uninstall")
+		__uninstall_completions "$PWD/build/tests"
+		;;
+	"--help")
+		usage
+		;;
+	*)
+		__install_completions "/usr/local/libexec/igt-gpu-tools"
+		;;
+esac
Signature · 1 line
2.43.0