2018-11-30 23:04:26 -05:00
|
|
|
#!/usr/bin/env bash
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-06-20 13:24:58 -04:00
|
|
|
if test -z "$G_DEBUG"; then
|
|
|
|
G_DEBUG=fatal-warnings
|
|
|
|
else
|
|
|
|
G_DEBUG="$G_DEBUG,fatal-warnings"
|
|
|
|
fi
|
|
|
|
|
|
|
|
export G_DEBUG
|
|
|
|
|
2013-05-30 08:22:22 -04:00
|
|
|
ENVIRONMENT_CONFIG=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
TEST_BINARY=$1
|
|
|
|
shift
|
|
|
|
|
2019-04-04 19:59:50 -04:00
|
|
|
UNIT_TESTS=$1
|
2018-05-22 09:52:37 -04:00
|
|
|
shift
|
|
|
|
|
2018-12-01 00:48:38 -05:00
|
|
|
. "$ENVIRONMENT_CONFIG"
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2012-02-23 07:30:51 -05:00
|
|
|
set +m
|
|
|
|
|
2018-12-17 10:12:29 -05:00
|
|
|
LOG=$(mktemp)
|
|
|
|
|
2012-02-23 07:30:51 -05:00
|
|
|
trap "" ERR
|
|
|
|
trap "" SIGABRT
|
|
|
|
trap "" SIGFPE
|
|
|
|
trap "" SIGSEGV
|
|
|
|
|
|
|
|
EXIT=0
|
2012-11-09 11:47:01 -05:00
|
|
|
MISSING_FEATURE="WARNING: Missing required feature";
|
|
|
|
KNOWN_FAILURE="WARNING: Test is known to fail";
|
2012-02-23 07:30:51 -05:00
|
|
|
|
2019-04-04 23:36:06 -04:00
|
|
|
if [ -z "$RUN_TESTS_QUIET" ]; then
|
|
|
|
echo "Key:"
|
|
|
|
echo "ok = Test passed"
|
|
|
|
echo "n/a = Driver is missing a feature required for the test"
|
|
|
|
echo "FAIL = Unexpected failure"
|
|
|
|
echo "FIXME = Test failed, but it was an expected failure"
|
|
|
|
echo "PASS! = Unexpected pass"
|
|
|
|
echo ""
|
|
|
|
fi
|
2012-02-23 07:30:51 -05:00
|
|
|
|
|
|
|
get_status()
|
|
|
|
{
|
|
|
|
case $1 in
|
|
|
|
# Special value we use to indicate that the test failed
|
|
|
|
# but it was an expected failure so don't fail the
|
|
|
|
# overall test run as a result...
|
|
|
|
300)
|
2013-09-02 09:26:03 -04:00
|
|
|
echo -n "FIXME";;
|
2012-02-23 07:30:51 -05:00
|
|
|
# Special value we use to indicate that the test passed
|
|
|
|
# but we weren't expecting it to pass‽
|
|
|
|
400)
|
|
|
|
echo -n 'PASS!';;
|
|
|
|
|
2012-11-09 11:47:01 -05:00
|
|
|
# Special value to indicate the test is missing a required feature
|
|
|
|
500)
|
|
|
|
echo -n "n/a";;
|
|
|
|
|
2012-02-23 07:30:51 -05:00
|
|
|
0)
|
|
|
|
echo -n "ok";;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo -n "FAIL";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
run_test()
|
|
|
|
{
|
2018-12-17 10:12:29 -05:00
|
|
|
$("$TEST_BINARY" "$1" &> "$LOG")
|
2012-02-23 07:30:51 -05:00
|
|
|
TMP=$?
|
|
|
|
var_name=$2_result
|
2018-12-01 00:48:38 -05:00
|
|
|
eval "$var_name=$TMP"
|
2018-12-17 10:12:29 -05:00
|
|
|
if grep -q "$MISSING_FEATURE" "$LOG"; then
|
2018-12-01 00:48:38 -05:00
|
|
|
if test "$TMP" -ne 0; then
|
|
|
|
eval "$var_name=500"
|
2012-11-09 11:47:01 -05:00
|
|
|
else
|
2018-12-01 00:48:38 -05:00
|
|
|
eval "$var_name=400"
|
2012-11-09 11:47:01 -05:00
|
|
|
fi
|
2018-12-17 10:12:29 -05:00
|
|
|
elif grep -q "$KNOWN_FAILURE" "$LOG"; then
|
2012-02-23 07:30:51 -05:00
|
|
|
if test $TMP -ne 0; then
|
2018-12-01 00:48:38 -05:00
|
|
|
eval "$var_name=300"
|
2012-02-23 07:30:51 -05:00
|
|
|
else
|
2018-12-01 00:48:38 -05:00
|
|
|
eval "$var_name=400"
|
2012-02-23 07:30:51 -05:00
|
|
|
fi
|
|
|
|
else
|
2018-12-01 00:48:38 -05:00
|
|
|
if test "$TMP" -ne 0; then EXIT=$TMP; fi
|
2012-02-23 07:30:51 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-04-04 23:36:06 -04:00
|
|
|
if [ -z "$UNIT_TESTS" ]; then
|
|
|
|
echo Missing unit-tests file or names
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-02-23 07:30:51 -05:00
|
|
|
TITLE_FORMAT="%35s"
|
2018-12-01 00:48:38 -05:00
|
|
|
printf "$TITLE_FORMAT" "Test"
|
2012-02-23 07:30:51 -05:00
|
|
|
|
2018-12-01 00:48:38 -05:00
|
|
|
if test "$HAVE_GL" -eq 1; then
|
2019-03-28 14:57:36 -04:00
|
|
|
GL_FORMAT=" %6s %8s %7s %6s"
|
|
|
|
printf "$GL_FORMAT" "GL+GLSL" "GL3"
|
2012-02-23 07:30:51 -05:00
|
|
|
fi
|
2018-12-01 00:48:38 -05:00
|
|
|
if test "$HAVE_GLES2" -eq 1; then
|
2019-03-28 14:57:36 -04:00
|
|
|
GLES2_FORMAT=" %6s"
|
|
|
|
printf "$GLES2_FORMAT" "ES2"
|
2012-02-23 07:30:51 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
2019-04-04 19:59:50 -04:00
|
|
|
if [ -f "$UNIT_TESTS" ]; then
|
|
|
|
UNIT_TESTS="$(cat $UNIT_TESTS)"
|
|
|
|
fi
|
|
|
|
|
2019-04-04 23:36:06 -04:00
|
|
|
if [ -z "$RUN_TESTS_QUIET" ] || [ "$(echo "$UNIT_TESTS" | wc -w )" -gt 1 ]; then
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
2019-04-04 19:59:50 -04:00
|
|
|
for test in $UNIT_TESTS
|
2011-05-05 18:34:38 -04:00
|
|
|
do
|
2019-04-04 23:36:06 -04:00
|
|
|
printf $TITLE_FORMAT "$test:"
|
2012-02-23 07:30:51 -05:00
|
|
|
export COGL_DEBUG=
|
|
|
|
|
2018-12-01 00:48:38 -05:00
|
|
|
if test "$HAVE_GL" -eq 1; then
|
2012-02-23 07:30:51 -05:00
|
|
|
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=
|
2018-12-01 00:48:38 -05:00
|
|
|
run_test "$test" gl_arbfp
|
2012-02-23 07:30:51 -05:00
|
|
|
|
|
|
|
export COGL_DRIVER=gl
|
|
|
|
export COGL_DEBUG=disable-fixed,disable-arbfp
|
2018-12-01 00:48:38 -05:00
|
|
|
run_test "$test" gl_glsl
|
2012-02-23 07:30:51 -05:00
|
|
|
|
2012-09-26 15:32:36 -04:00
|
|
|
export COGL_DRIVER=gl3
|
|
|
|
export COGL_DEBUG=
|
2018-12-01 00:48:38 -05:00
|
|
|
run_test "$test" gl3
|
2012-02-23 07:30:51 -05:00
|
|
|
fi
|
|
|
|
|
2018-12-01 00:48:38 -05:00
|
|
|
if test "$HAVE_GLES2" -eq 1; then
|
2012-02-23 07:30:51 -05:00
|
|
|
export COGL_DRIVER=gles2
|
|
|
|
export COGL_DEBUG=
|
2018-12-01 00:48:38 -05:00
|
|
|
run_test "$test" gles2
|
2012-02-23 07:30:51 -05:00
|
|
|
fi
|
|
|
|
|
2018-12-01 00:48:38 -05:00
|
|
|
if test "$HAVE_GL" -eq 1; then
|
2012-02-23 07:30:51 -05:00
|
|
|
printf "$GL_FORMAT" \
|
2018-12-01 00:48:38 -05:00
|
|
|
"$(get_status "$gl_glsl_result")" \
|
|
|
|
"$(get_status "$gl3_result")"
|
2012-02-23 07:30:51 -05:00
|
|
|
fi
|
2018-12-01 00:48:38 -05:00
|
|
|
if test "$HAVE_GLES2" -eq 1; then
|
2012-02-23 07:30:51 -05:00
|
|
|
printf "$GLES2_FORMAT" \
|
2019-03-28 14:57:36 -04:00
|
|
|
"$(get_status "$gles2_result")"
|
2012-02-23 07:30:51 -05:00
|
|
|
fi
|
|
|
|
echo ""
|
2011-05-05 18:34:38 -04:00
|
|
|
done
|
|
|
|
|
2018-12-17 10:12:29 -05:00
|
|
|
rm "$LOG"
|
|
|
|
|
2018-12-01 00:48:38 -05:00
|
|
|
exit "$EXIT"
|