mutter/cogl/tests/run-tests.sh

170 lines
3.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -o pipefail
if test -z "$G_DEBUG"; then
G_DEBUG=fatal-warnings
else
G_DEBUG="$G_DEBUG,fatal-warnings"
fi
export G_DEBUG
ENVIRONMENT_CONFIG=$1
shift
TEST_BINARY=$1
shift
UNIT_TESTS=$1
shift
. "$ENVIRONMENT_CONFIG"
set +m
LOG=$(mktemp)
trap "" ERR
trap "" SIGABRT
trap "" SIGFPE
trap "" SIGSEGV
EXIT=0
MISSING_FEATURE="WARNING: Missing required feature";
KNOWN_FAILURE="WARNING: Test is known to fail";
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
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)
echo -n "FIXME";;
# Special value we use to indicate that the test passed
# but we weren't expecting it to pass‽
400)
echo -n 'PASS!';;
# Special value to indicate the test is missing a required feature
500)
echo -n "n/a";;
0)
echo -n "ok";;
*)
echo -n "FAIL";;
esac
}
run_test()
{
if [ -n "${VERBOSE-}" ]; then
echo "running $TEST_BINARY $1:"
$TEST_BINARY $1 2>&1 | tee "$LOG"
else
$($TEST_BINARY $1 &> "$LOG")
fi
TMP=$?
var_name=$2_result
eval "$var_name=$TMP"
if grep -q "$MISSING_FEATURE" "$LOG"; then
if test "$TMP" -ne 0; then
eval "$var_name=500"
else
eval "$var_name=400"
fi
elif grep -q "$KNOWN_FAILURE" "$LOG"; then
if test $TMP -ne 0; then
eval "$var_name=300"
else
eval "$var_name=400"
fi
else
if test "$TMP" -ne 0; then EXIT=$TMP; fi
fi
}
if [ -z "$UNIT_TESTS" ]; then
echo Missing unit-tests file or names
exit 1
fi
TITLE_FORMAT="%35s"
printf "$TITLE_FORMAT" "Test"
if test "$HAVE_GL" -eq 1; then
GL_FORMAT=" %6s %8s %7s %6s"
printf "$GL_FORMAT" "GL+GLSL" "GL3"
fi
if test "$HAVE_GLES2" -eq 1; then
GLES2_FORMAT=" %6s"
printf "$GLES2_FORMAT" "ES2"
fi
echo ""
if [ -f "$UNIT_TESTS" ]; then
UNIT_TESTS="$(cat $UNIT_TESTS)"
fi
if [ -z "$RUN_TESTS_QUIET" ] || [ "$(echo "$UNIT_TESTS" | wc -w )" -gt 1 ]; then
echo ""
fi
for test in $UNIT_TESTS
do
printf $TITLE_FORMAT "$test:"
export COGL_DEBUG=
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
export COGL_DRIVER=gl
export COGL_DEBUG=disable-fixed,disable-arbfp
run_test "$test" gl_glsl
Add a GL 3 driver This adds a new CoglDriver for GL 3 called COGL_DRIVER_GL3. When requested, the GLX, EGL and SDL2 winsyss will set the necessary attributes to request a forward-compatible core profile 3.1 context. That means it will have no deprecated features. To simplify the explosion of checks for specific combinations of context->driver, many of these conditionals have now been replaced with private feature flags that are checked instead. The GL and GLES drivers now initialise these private feature flags depending on which driver is used. The fixed function backends now explicitly check whether the fixed function private feature is available which means the GL3 driver will fall back to always using the GLSL progend. Since Rob's latest patches the GLSL progend no longer uses any fixed function API anyway so it should just work. The driver is currently lower priority than COGL_DRIVER_GL so it will not be used unless it is specificly requested. We may want to change this priority at some point because apparently Mesa can make some memory savings if a core profile context is used. In GL 3, getting the combined extensions string with glGetString is deprecated so this patch changes it to use glGetStringi to build up an array of extensions instead. _cogl_context_get_gl_extensions now returns this array instead of trying to return a const string. The caller is expected to free the array. Some issues with this patch: • GL 3 does not support GL_ALPHA format textures. We should probably make this a feature flag or something. Cogl uses this to render text which currently just throws a GL error and breaks so it's pretty important to do something about this before considering the GL3 driver to be stable. • GL 3 doesn't support client side vertex buffers. This probably doesn't matter because CoglBuffer won't normally use malloc'd buffers if VBOs are available, but it might but worth making malloc'd buffers a private feature and forcing it not to use them. • GL 3 doesn't support the default vertex array object. This patch just makes it create and bind a single non-default vertex array object which gets used just like the normal default object. Ideally it would be good to use vertex array objects properly and attach them to a CoglPrimitive to cache the state. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 66c9db993595b3a22e63f4c201ea468bc9b88cb6)
2012-09-26 15:32:36 -04:00
export COGL_DRIVER=gl3
export COGL_DEBUG=
run_test "$test" gl3
fi
if test "$HAVE_GLES2" -eq 1; then
export COGL_DRIVER=gles2
export COGL_DEBUG=
run_test "$test" gles2
fi
if test "$HAVE_GL" -eq 1; then
printf "$GL_FORMAT" \
"$(get_status "$gl_glsl_result")" \
"$(get_status "$gl3_result")"
fi
if test "$HAVE_GLES2" -eq 1; then
printf "$GLES2_FORMAT" \
"$(get_status "$gles2_result")"
fi
echo ""
done
rm "$LOG"
exit "$EXIT"