public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jan Sokolowski <jan.sokolowski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Jan Sokolowski" <jan.sokolowski@intel.com>,
	"Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
	"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
	"Katarzyna Piecielska" <katarzyna.piecielska@intel.com>,
	"Juha-Pekka Heikkila" <juhapekka.heikkila@gmail.com>,
	"Ashutosh Dixit" <ashutosh.dixit@intel.com>
Subject: [PATCH i-g-t 1/1] scripts/bash-autocomplete: Create autocompletion for tests
Date: Thu, 26 Feb 2026 14:39:16 +0100	[thread overview]
Message-ID: <20260226133916.33621-2-jan.sokolowski@intel.com> (raw)
In-Reply-To: <20260226133916.33621-1-jan.sokolowski@intel.com>

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, for example Ubuntu root does not
source bash_completion because it is commented out.

Signed-off-by: Jan Sokolowski <jan.sokolowski@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>
---
 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 1563a85b1..e5fbdcc0c 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 000000000..d3db63af0
--- /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 ~/.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


  reply	other threads:[~2026-02-26 13:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26 13:39 [PATCH i-g-t 0/1] Bash autocompletion feature for igt Jan Sokolowski
2026-02-26 13:39 ` Jan Sokolowski [this message]
2026-03-02  6:14   ` [PATCH i-g-t 1/1] scripts/bash-autocomplete: Create autocompletion for tests Zbigniew Kempczyński
2026-02-26 23:52 ` ✓ i915.CI.BAT: success for Bash autocompletion feature for igt Patchwork
2026-02-27  0:13 ` ✓ Xe.CI.BAT: " Patchwork
2026-02-27  6:14 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-02-27  7:23 ` ✗ i915.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260226133916.33621-2-jan.sokolowski@intel.com \
    --to=jan.sokolowski@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=juhapekka.heikkila@gmail.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=katarzyna.piecielska@intel.com \
    --cc=zbigniew.kempczynski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox