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

Kamil Konieczny kamil.konieczny at linux.intel.com
Wed Jul 23 07:45:39 UTC 2025


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

> Add installation and uninstallation scripts for bash autocompletion
> for tests.
> 
> Signed-off-by: Jan Sokolowski <jan.sokolowski at intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> Cc: Katarzyna Piecielska <katarzyna.piecielska at intel.com>
> Cc: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> Cc: Ashutosh Dixit <ashutosh.dixit at intel.com>
> ---
>  .../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

> 
> diff --git a/scripts/bash_autocompletion/install_completions.sh b/scripts/bash_autocompletion/install_completions.sh
> new file mode 100755
> index 000000000..40cc87403
> --- /dev/null
> +++ b/scripts/bash_autocompletion/install_completions.sh
> @@ -0,0 +1,47 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: MIT
> +# Copyright © 2025 Intel Corporation
> +# Author: Jan Sokolowski <jan.sokolowski at intel.com>
> +
> +__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
> diff --git a/scripts/bash_autocompletion/uninstall_completions.sh b/scripts/bash_autocompletion/uninstall_completions.sh
> new file mode 100755
> index 000000000..26345d6e2
> --- /dev/null
> +++ b/scripts/bash_autocompletion/uninstall_completions.sh
> @@ -0,0 +1,9 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: MIT
> +# Copyright © 2025 Intel Corporation
> +# Author: Jan Sokolowski <jan.sokolowski at intel.com>
> +
> +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
> -- 
> 2.34.1
> 


More information about the igt-dev mailing list