tests: Clean up shell scripts
PATCH 1/1 tests: Clean up shell scripts
Convert all scripts to use /bin/sh shebang and fix all shellcheck reported problems.
Signed-off-by Joonas Lahtinen <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
--- tests/check_drm_clients | 15 +++++++++---- tests/ddx_intel_after_fbdev | 42 ++++++++++++++++++------------------- tests/debugfs_emon_crash | 16 +++++++++----- tests/debugfs_wedged | 18 ++++++++++------ tests/drm_getopt.sh | 20 ++++++++++-------- tests/drm_lib.sh | 51 +++++++++++++++++++++++---------------------- tests/drv_debugfs_reader | 17 ++++++++++----- tests/igt_command_line.sh | 26 +++++++++++------------ tests/sysfs_l3_parity | 30 ++++++++++++++++---------- tests/test_rte_check | 6 ------ tests/tools_test | 17 +++++++++------ 11 files changed, 147 insertions(+), 111 deletions(-) delete mode 100755 tests/test_rte_check
tests/check_drm_clients +11 -4
@@ -1,6 +1,13 @@ -#!/bin/bash +#!/bin/sh -SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )" -. $SOURCE_DIR/drm_lib.sh +if [ -n "$BASH_SOURCE" ]; then + THIS_SCRIPT=$BASH_SOURCE +else + THIS_SCRIPT=$0 +fi + +SOURCE_DIR=$(dirname "$THIS_SCRIPT") +. "$SOURCE_DIR/drm_lib.sh" + +exit "$IGT_EXIT_SUCCESS" -exit $IGT_EXIT_SUCCESS
tests/ddx_intel_after_fbdev +21 -21
86 lines not on this page · raw message
tests/debugfs_emon_crash +11 -5
@@ -1,16 +1,22 @@ -#!/bin/bash +#!/bin/sh # # This check if we can crash the kernel with segmentation-fault # by reading /sys/kernel/debug/dri/0/i915_emon_status too quickly # -SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )" -. $SOURCE_DIR/drm_lib.sh +if [ -n "$BASH_SOURCE" ]; then + THIS_SCRIPT=$BASH_SOURCE +else + THIS_SCRIPT=$0 +fi + +SOURCE_DIR=$(dirname "$THIS_SCRIPT") +. "$SOURCE_DIR/drm_lib.sh" for z in $(seq 1 1000); do - cat $i915_dfs_path/i915_emon_status > /dev/null 2&>1 + cat "$i915_dfs_path/i915_emon_status" > /dev/null 2>&1 done # If we got here, we haven't crashed +exit "$IGT_EXIT_SUCCESS" -exit $IGT_EXIT_SUCCESS
tests/debugfs_wedged +12 -6
@@ -1,10 +1,16 @@ -#!/bin/bash +#!/bin/sh -SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )" -. $SOURCE_DIR/drm_lib.sh +if [ -n "$BASH_SOURCE" ]; then + THIS_SCRIPT=$BASH_SOURCE +else + THIS_SCRIPT=$0 +fi + +SOURCE_DIR=$(dirname "$THIS_SCRIPT") +. "$SOURCE_DIR/drm_lib.sh" # Testcase: wedge the hw to check the error_state reading -# +# # Unfortunately wedged is permanent, so this test is not run by default -echo 1 > ${i915_dfs_path}/i915_wedged -cat $i915_dfs_path/i915_error_state > /dev/null 2>&1 +echo 1 > "${i915_dfs_path}/i915_wedged" +cat "$i915_dfs_path/i915_error_state" > /dev/null 2>&1
tests/drm_getopt.sh +11 -9
@@ -1,3 +1,4 @@ +#!/bin/sh # This is required for check/distcheck target as it has to --list-subtests # for each test. Source it if you add a new test in form of a (shell) script.
@@ -9,30 +10,31 @@ IGT_EXIT_SUCCESS=0 IGT_EXIT_INVALID=79 IGT_EXIT_FAILURE=99 -# hacked-up long option parsing -for arg in $@ ; do - case $arg in +PROG=$(basename "$THIS_SCRIPT") + +for arg do + case "$arg" in --list-subtests) - exit $IGT_EXIT_INVALID + exit "$IGT_EXIT_INVALID" ;; --run-subtest) - exit $IGT_EXIT_INVALID + exit "$IGT_EXIT_INVALID" ;; --debug) IGT_LOG_LEVEL=debug ;; --help-description) - echo $IGT_TEST_DESCRIPTION - exit $IGT_EXIT_SUCCESS + echo "$IGT_TEST_DESCRIPTION" + exit "$IGT_EXIT_SUCCESS" ;; --help) - echo "Usage: `basename $0` [OPTIONS]" + echo "Usage: $PROG [OPTIONS]" echo " --list-subtests" echo " --run-subtest <pattern>" echo " --debug" echo " --help-description" echo " --help" - exit $IGT_EXIT_SUCCESS + exit "$IGT_EXIT_SUCCESS" ;; esac done
tests/drm_lib.sh +26 -25
119 lines not on this page · raw message
tests/drv_debugfs_reader +12 -5
@@ -1,9 +1,16 @@ -#!/bin/bash +#!/bin/sh -SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )" -. $SOURCE_DIR/drm_lib.sh +if [ -n "$BASH_SOURCE" ]; then + THIS_SCRIPT=$BASH_SOURCE +else + THIS_SCRIPT=$0 +fi + +SOURCE_DIR=$(dirname "$THIS_SCRIPT") +. "$SOURCE_DIR/drm_lib.sh" # read everything we can -cat $i915_dfs_path/* > /dev/null 2>&1 +cat "$i915_dfs_path"/* > /dev/null 2>&1 + +exit "$IGT_EXIT_SUCCESS" -exit $IGT_EXIT_SUCCESS
tests/igt_command_line.sh +13 -13
@@ -26,11 +26,11 @@ # if [ -z "$top_builddir" ]; then - top_builddir="$(dirname $0)" + top_builddir=$(dirname "$0") fi # allow to run this script from top directory -TESTLIST=`cat $top_builddir/test-list.txt` +TESTLIST=$(cat "$top_builddir/test-list.txt") if [ $? -ne 0 ]; then # distcheck requires this hack TESTLIST=$(cat test-list.txt)
@@ -51,7 +51,7 @@ for test in $TESTLIST; do fi # top_builddir is empty for distcheck - test=$top_builddir/$test + test="$top_builddir/$test" # distcheck requires this hack if [ ! -x "$test" ]; then
@@ -62,29 +62,29 @@ for test in $TESTLIST; do # check invalid option handling echo " Checking invalid option handling..." - ./$test --invalid-option 2> /dev/null && fail $test + "./$test" --invalid-option 2> /dev/null && fail "$test" # check valid options succeed echo " Checking valid option handling..." - ./$test --help > /dev/null || fail $test + "./$test" --help > /dev/null || fail "$test" # check --list-subtests works correctly echo " Checking subtest enumeration..." - LIST=`./$test --list-subtests` + LIST=$("./$test" --list-subtests) RET=$? - if [ $RET -ne 0 -a $RET -ne 79 ]; then - fail $test + if [ "$RET" -ne 0 -a $RET -ne 79 ]; then + fail "$test" fi - if [ $RET -eq 79 -a -n "$LIST" ]; then - fail $test + if [ "$RET" -eq 79 -a -n "$LIST" ]; then + fail "$test" fi - if [ $RET -eq 0 -a -z "$LIST" ]; then - fail $test + if [ "$RET" -eq 0 -a -z "$LIST" ]; then + fail "$test" fi # check invalid subtest handling echo " Checking invalid subtest handling..." - ./$test --run-subtest invalid-subtest > /dev/null 2>&1 && fail $test + "./$test" --run-subtest invalid-subtest > /dev/null 2>&1 && fail "$test" done
tests/sysfs_l3_parity +19 -11
@@ -1,22 +1,30 @@ -#!/bin/bash +#!/bin/sh -SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )" -. $SOURCE_DIR/drm_lib.sh +if [ -n "$BASH_SOURCE" ]; then + THIS_SCRIPT=$BASH_SOURCE +else + THIS_SCRIPT=$0 +fi + +SOURCE_DIR=$(dirname "$THIS_SCRIPT") +. "$SOURCE_DIR/drm_lib.sh" -$SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e || exit $? +"$SOURCE_DIR/../tools/intel_l3_parity" -r 0 -b 0 -s 0 -e || exit $? #Check that we can remap a row -$SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -d -disabled=`$SOURCE_DIR/../tools/intel_l3_parity -l | grep -c 'Row 0, Bank 0, Subbank 0 is disabled'` -if [ "$disabled" != "1" ] ; then +"$SOURCE_DIR/../tools/intel_l3_parity" -r 0 -b 0 -s 0 -d +disabled=$("$SOURCE_DIR/../tools/intel_l3_parity" -l | grep -c 'Row 0, Bank 0, Subbank 0 is disabled') +if [ "$disabled" != 1 ] ; then echo "Fail" - exit $IGT_EXIT_FAILURE + exit "$IGT_EXIT_FAILURE" fi -$SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e +"$SOURCE_DIR/../tools/intel_l3_parity" -r 0 -b 0 -s 0 -e + #Check that we can clear remaps -if [ `$SOURCE_DIR/../tools/intel_l3_parity -l | wc -l` != 1 ] ; then +can_clear=$("$SOURCE_DIR/../tools/intel_l3_parity" -l | wc -l) +if [ "$can_clear" != 1 ] ; then echo "Fail 2" - exit $IGT_EXIT_FAILURE + exit "$IGT_EXIT_FAILURE" fi
tests/test_rte_check deleted +0 -6
@@ -1,6 +0,0 @@ -#!/bin/bash - -SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )" -. $SOURCE_DIR/drm_lib.sh - -exit $IGT_EXIT_SUCCESS
tests/tools_test +11 -6
@@ -1,16 +1,21 @@ -#!/bin/bash +#!/bin/sh # Test some of the most critical tools we have accidentally broken before. # TODO: Possibly make tests parse output -SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )" -. $SOURCE_DIR/drm_lib.sh +if [ -n "$BASH_SOURCE" ]; then + THIS_SCRIPT=$BASH_SOURCE +else + THIS_SCRIPT=$0 +fi + +SOURCE_DIR=$(dirname "$THIS_SCRIPT") +. "$SOURCE_DIR/drm_lib.sh" # ARB_MODE has existed for many gens -PATH=$SOURCE_DIR/../tools:$PATH +PATH="$SOURCE_DIR/../tools:$PATH" do_or_die "intel_reg read 0x4030" do_or_die "intel_reg dump" # TODO: Add more tests -exit $IGT_EXIT_SUCCESS - +exit "$IGT_EXIT_SUCCESS"
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 1 line · Joonas Lahtinen
delete mode 100755 tests/test_rte_check
Remove test_rte_check also from tests/Makefile.sources. With that,
Reviewed-by Petri Latvala <[email protected]>
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx