Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2 1/1] scripts/bash-autocomplete: Create autocompletion for tests
@ 2026-04-29  7:56 Jan Sokolowski
  2026-04-29 11:03 ` ✓ Xe.CI.BAT: success for series starting with [i-g-t,v2,1/1] " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jan Sokolowski @ 2026-04-29  7:56 UTC (permalink / raw)
  To: igt-dev
  Cc: zbigniew.kempczynski, peter.senna, piotr.rudnicki, mika.kuoppala,
	Jan Sokolowski, Kamil Konieczny, Katarzyna Piecielska,
	Juha-Pekka Heikkila, Ashutosh Dixit

Add installation and uninstallation scripts for bash autocompletion
for tests.

To install: run './meson.sh install-completions'.

To uninstall: run './meson.sh 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, for example Ubuntu root does not
source bash_completion because it is commented out.

Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com>
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: Katarzyna Piecielska <katarzyna.piecielska@intel.com>
Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
---

v2: applied nits from previous review and added reviewed-by.

---
 meson.sh                                      |  6 ++
 .../install_completions.sh                    | 88 +++++++++++++++++++
 2 files changed, 94 insertions(+)
 create mode 100755 scripts/bash_autocompletion/install_completions.sh

diff --git a/meson.sh b/meson.sh
index 1563a85b1f..e5fbdcc0cf 100755
--- a/meson.sh
+++ b/meson.sh
@@ -60,6 +60,12 @@ install: build/build.ninja
 uninstall: build/build.ninja
 	\$(Q)ninja -C build uninstall \$(quiet_build)
 
+install-completions: all
+	./scripts/bash_autocompletion/install_completions.sh --local-install
+
+uninstall-completions: all
+	./scripts/bash_autocompletion/install_completions.sh --local-uninstall
+
 docs:
 	\$(Q)ninja -C build igt-gpu-tools-doc \$(quiet_build)
 
diff --git a/scripts/bash_autocompletion/install_completions.sh b/scripts/bash_autocompletion/install_completions.sh
new file mode 100755
index 0000000000..88998ae66e
--- /dev/null
+++ b/scripts/bash_autocompletion/install_completions.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+# Copyright © 2025 Intel Corporation
+# Author: Jan Sokolowski <jan.sokolowski@intel.com>
+
+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
+
+	echo "Installing bash autocompletion scripts to ~/.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
+	echo "Unnstalling bash autocompletion scripts from ~/.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 -f ~/.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
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-29 19:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29  7:56 [PATCH i-g-t v2 1/1] scripts/bash-autocomplete: Create autocompletion for tests Jan Sokolowski
2026-04-29 11:03 ` ✓ Xe.CI.BAT: success for series starting with [i-g-t,v2,1/1] " Patchwork
2026-04-29 11:06 ` ✓ i915.CI.BAT: " Patchwork
2026-04-29 19:05 ` ✗ i915.CI.Full: failure " Patchwork
2026-04-29 19:45 ` ✗ Xe.CI.FULL: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox