[igt-dev] [PATCH i-g-t] scripts/bash-autocomplete.sh: Add bash autocomplete script for IGT tests
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Wed Mar 20 19:40:42 UTC 2019
This script know about IGT test parameters and can fetch IGT
subtests as parameter for --run-subtest. This script assume
tests were built with meson.sh and there is build/tests/test-list.txt
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
scripts/bash-autocomplete.sh | 81 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
create mode 100755 scripts/bash-autocomplete.sh
diff --git a/scripts/bash-autocomplete.sh b/scripts/bash-autocomplete.sh
new file mode 100755
index 0000000..befccfc
--- /dev/null
+++ b/scripts/bash-autocomplete.sh
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+#
+# Copyright © 2019 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+_igt_test_complete()
+{
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ local cmd=${COMP_WORDS[COMP_CWORD-1]}
+ local exe=${COMP_WORDS[0]}
+
+ if [ -f $cmd ]; then
+ COMPREPLY=($(compgen -W "--list-subtests --run-subtest --debug --interactive-debug --help-description --help" -- $cur))
+ else
+ if [ "$cmd" = "--run-subtest" ]; then
+ local subtestlist=""
+ if [ -x $exe ]; then
+ while read subtest; do
+ subtestlist="$subtestlist $subtest"
+ done < <($exe --list-subtests)
+ fi
+ COMPREPLY=($(compgen -W "$subtestlist" -- $cur))
+ return
+ fi
+ COMPREPLY=($(compgen -W "" -- $cur))
+ fi
+}
+
+if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
+ echo "you need to source this script"
+ echo "ie. \"source ./scripts/bash-autocomplete.sh\""
+ exit
+fi
+
+
+ROOT=$(dirname $0)
+ROOT=$(readlink -f $ROOT/..)
+
+if [ ! -f "$ROOT/build/tests/test-list.txt" ]; then
+ ROOT=$(dirname $0)
+ ROOT=$(readlink -f $ROOT)
+fi
+
+testlist=""
+while read test; do
+ if [[ "$test" != "TESTLIST" && "$test" != "END TESTLIST" ]]; then
+ IFS=' /' read -r -a array <<< $test
+ for element in "${array[@]}"
+ do
+ if [ "$element" != "amdgpu" ]; then
+ testlist="$testlist $element"
+ fi
+ done
+ fi
+done < <(cat $ROOT/build/tests/test-list.txt)
+
+if [ "$testlist" != "" ]; then
+ complete -F _igt_test_complete $testlist
+else
+ echo "$ROOT/build/tests/test-list.txt not correct! You need to build IGT first with meson.sh"
+ echo "or you need to source this file from scripts folder"
+fi
+
--
2.7.4
More information about the igt-dev
mailing list