mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 19:12:04 +00:00
tests: Fix warnings reported by shellcheck
This commit includes following fixes for a few shell scripts: 1. Follow the best practice of quoting variables everywhere unless they are used in places where word-splitting and globbing can never happen. 2. Replace `command` with $(command) because the latter is easier to use and read. 3. Don't use "$@" in places expecting a string because it is an array of strings instead of a single string.
This commit is contained in:
parent
b2e75b5da0
commit
319500e4f3
@ -2,14 +2,13 @@
|
||||
|
||||
outputfile=$1
|
||||
shift
|
||||
test_source_files="$@"
|
||||
|
||||
echo '/* ** This file is autogenerated. Do not edit. ** */' > $outputfile
|
||||
echo '' >> $outputfile
|
||||
echo 'const char *test_unit_names[] = {' >> $outputfile
|
||||
echo '/* ** This file is autogenerated. Do not edit. ** */' > "$outputfile"
|
||||
echo '' >> "$outputfile"
|
||||
echo 'const char *test_unit_names[] = {' >> "$outputfile"
|
||||
|
||||
for test_source_file in $test_source_files; do
|
||||
echo " \"$(echo $test_source_file | sed 's/.*\(test-[a-z0-9\-]\+\)\.c/\1/')\"," >> $outputfile
|
||||
for test_source_file in "$@"; do
|
||||
echo " \"$(echo "$test_source_file" | sed 's/.*\(test-[a-z0-9\-]\+\)\.c/\1/')\"," >> "$outputfile"
|
||||
done
|
||||
|
||||
echo '};' >> $outputfile
|
||||
echo '};' >> "$outputfile"
|
||||
|
@ -5,6 +5,6 @@ outputfile="$2"
|
||||
|
||||
echo > "$outputfile"
|
||||
|
||||
sed -n -e 's/^ \{1,\}ADD_TEST *( *\([a-zA-Z0-9_]\{1,\}\).*/\1/p' "$1" | while read test; do
|
||||
echo $test >> $outputfile
|
||||
sed -n -e 's/^ \{1,\}ADD_TEST *( *\([a-zA-Z0-9_]\{1,\}\).*/\1/p' "$inputfile" | while read -r test; do
|
||||
echo "$test" >> "$outputfile"
|
||||
done
|
||||
|
@ -17,7 +17,7 @@ shift
|
||||
UNIT_TESTS_FILE=$1
|
||||
shift
|
||||
|
||||
. $ENVIRONMENT_CONFIG
|
||||
. "$ENVIRONMENT_CONFIG"
|
||||
|
||||
set +m
|
||||
|
||||
@ -65,35 +65,35 @@ get_status()
|
||||
|
||||
run_test()
|
||||
{
|
||||
$($TEST_BINARY $1 &>.log)
|
||||
"$TEST_BINARY" "$1" &>.log
|
||||
TMP=$?
|
||||
var_name=$2_result
|
||||
eval $var_name=$TMP
|
||||
eval "$var_name=$TMP"
|
||||
if grep -q "$MISSING_FEATURE" .log; then
|
||||
if test $TMP -ne 0; then
|
||||
eval $var_name=500
|
||||
if test "$TMP" -ne 0; then
|
||||
eval "$var_name=500"
|
||||
else
|
||||
eval $var_name=400
|
||||
eval "$var_name=400"
|
||||
fi
|
||||
elif grep -q "$KNOWN_FAILURE" .log; then
|
||||
if test $TMP -ne 0; then
|
||||
eval $var_name=300
|
||||
eval "$var_name=300"
|
||||
else
|
||||
eval $var_name=400
|
||||
eval "$var_name=400"
|
||||
fi
|
||||
else
|
||||
if test $TMP -ne 0; then EXIT=$TMP; fi
|
||||
if test "$TMP" -ne 0; then EXIT=$TMP; fi
|
||||
fi
|
||||
}
|
||||
|
||||
TITLE_FORMAT="%35s"
|
||||
printf $TITLE_FORMAT "Test"
|
||||
printf "$TITLE_FORMAT" "Test"
|
||||
|
||||
if test $HAVE_GL -eq 1; then
|
||||
if test "$HAVE_GL" -eq 1; then
|
||||
GL_FORMAT=" %6s %8s %7s %6s %6s"
|
||||
printf "$GL_FORMAT" "GL+GLSL" "GL-NPT" "GL3"
|
||||
fi
|
||||
if test $HAVE_GLES2 -eq 1; then
|
||||
if test "$HAVE_GLES2" -eq 1; then
|
||||
GLES2_FORMAT=" %6s %7s"
|
||||
printf "$GLES2_FORMAT" "ES2" "ES2-NPT"
|
||||
fi
|
||||
@ -101,59 +101,59 @@ fi
|
||||
echo ""
|
||||
echo ""
|
||||
|
||||
if [ ! -f $UNIT_TESTS_FILE ]; then
|
||||
if [ ! -f "$UNIT_TESTS_FILE" ]; then
|
||||
echo Missing unit-tests file
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for test in `cat $UNIT_TESTS_FILE`
|
||||
for test in $(cat "$UNIT_TESTS_FILE")
|
||||
do
|
||||
export COGL_DEBUG=
|
||||
|
||||
if test $HAVE_GL -eq 1; then
|
||||
if test "$HAVE_GL" -eq 1; then
|
||||
export COGL_DRIVER=gl
|
||||
# NB: we can't explicitly disable fixed + glsl in this case since
|
||||
# the arbfp code only supports fragment processing so we need either
|
||||
# the fixed or glsl vertends
|
||||
export COGL_DEBUG=
|
||||
run_test $test gl_arbfp
|
||||
run_test "$test" gl_arbfp
|
||||
|
||||
export COGL_DRIVER=gl
|
||||
export COGL_DEBUG=disable-fixed,disable-arbfp
|
||||
run_test $test gl_glsl
|
||||
run_test "$test" gl_glsl
|
||||
|
||||
export COGL_DRIVER=gl
|
||||
export COGL_DEBUG=disable-npot-textures
|
||||
run_test $test gl_npot
|
||||
run_test "$test" gl_npot
|
||||
|
||||
export COGL_DRIVER=gl3
|
||||
export COGL_DEBUG=
|
||||
run_test $test gl3
|
||||
run_test "$test" gl3
|
||||
fi
|
||||
|
||||
if test $HAVE_GLES2 -eq 1; then
|
||||
if test "$HAVE_GLES2" -eq 1; then
|
||||
export COGL_DRIVER=gles2
|
||||
export COGL_DEBUG=
|
||||
run_test $test gles2
|
||||
run_test "$test" gles2
|
||||
|
||||
export COGL_DRIVER=gles2
|
||||
export COGL_DEBUG=disable-npot-textures
|
||||
run_test $test gles2_npot
|
||||
run_test "$test" gles2_npot
|
||||
fi
|
||||
|
||||
printf $TITLE_FORMAT "$test:"
|
||||
if test $HAVE_GL -eq 1; then
|
||||
if test "$HAVE_GL" -eq 1; then
|
||||
printf "$GL_FORMAT" \
|
||||
"`get_status $gl_glsl_result`" \
|
||||
"`get_status $gl_npot_result`" \
|
||||
"`get_status $gl3_result`"
|
||||
"$(get_status "$gl_glsl_result")" \
|
||||
"$(get_status "$gl_npot_result")" \
|
||||
"$(get_status "$gl3_result")"
|
||||
fi
|
||||
if test $HAVE_GLES2 -eq 1; then
|
||||
if test "$HAVE_GLES2" -eq 1; then
|
||||
printf "$GLES2_FORMAT" \
|
||||
"`get_status $gles2_result`" \
|
||||
"`get_status $gles2_npot_result`"
|
||||
"$(get_status "$gles2_result")" \
|
||||
"$(get_status "$gles2_npot_result")"
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
|
||||
exit $EXIT
|
||||
exit "$EXIT"
|
||||
|
@ -9,20 +9,20 @@ shift
|
||||
UNIT_TEST=$1
|
||||
shift
|
||||
|
||||
test -z ${UNIT_TEST} && {
|
||||
test -z "${UNIT_TEST}" && {
|
||||
echo "Usage: $0 UNIT_TEST"
|
||||
exit 1
|
||||
}
|
||||
|
||||
BINARY_NAME=`basename $TEST_BINARY`
|
||||
UNIT_TEST=`echo $UNIT_TEST|sed 's/-/_/g'`
|
||||
BINARY_NAME=$(basename "$TEST_BINARY")
|
||||
UNIT_TEST=$(echo "$UNIT_TEST"|sed 's/-/_/g')
|
||||
|
||||
echo "Running: ./$BINARY_NAME ${UNIT_TEST} $@"
|
||||
echo "Running: ./$BINARY_NAME ${UNIT_TEST} $*"
|
||||
echo ""
|
||||
COGL_TEST_VERBOSE=1 $TEST_BINARY ${UNIT_TEST} "$@"
|
||||
COGL_TEST_VERBOSE=1 "$TEST_BINARY" "${UNIT_TEST}" "$@"
|
||||
exit_val=$?
|
||||
|
||||
if test $exit_val -eq 0; then
|
||||
if test "$exit_val" -eq 0; then
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
@ -36,4 +36,4 @@ echo "$ env G_SLICE=always-malloc \\"
|
||||
echo " libtool --mode=execute \\"
|
||||
echo " valgrind ./$BINARY_NAME ${UNIT_TEST}"
|
||||
|
||||
exit $exit_val
|
||||
exit "$exit_val"
|
||||
|
Loading…
Reference in New Issue
Block a user