Add a wrapper library to help testing without NPOTs.

* tests/tools/Makefile.am: Optionally build the
	libdisable-npots.la library depending on whether libdl was
	detected in the configure script. A helper script is also
	generated to setup the LD_PRELOAD.

	* tests/conform/Makefile.am: There are now two versions of the
	test-report and full-report rules. test-report-normal is the same
	as before and test-report-disable-npots runs the tests with the
	disable-npots wrapper script. The full-report rule runs both of
	them and displays two separate HTML files. The test-report rule
	just runs the normal version as before.

	* configure.ac: Add a test for libdl

	* tests/tools/disable-npots.sh.in: New file. Template for the
	helper script

	* tests/tools/disable-npots.c: New file
This commit is contained in:
Neil Roberts 2008-11-24 15:44:16 +00:00
parent 8ff85615b3
commit 596d4628e6
7 changed files with 200 additions and 7 deletions

3
.gitignore vendored
View File

@ -115,6 +115,8 @@ stamp-h1
/tests/conform/test-conformance
/tests/conform/test-conformance-results.xml
/tests/conform/test-conformance-results.html
/tests/conform/test-conformance-results-dn.xml
/tests/conform/test-conformance-results-dn.html
/tests/conform/test_entry_append_some
/tests/conform/test_entry_cursor
/tests/conform/test_entry_delete_chars
@ -147,6 +149,7 @@ stamp-h1
/tests/conform/test_paint_opacity
/tests/conform/test_rectangle_opacity
/tests/micro-bench/test-text
/tests/tools/disable-npots.sh
/clutter/x11/clutter-x11-enum-types.[ch]
/clutter/x11/stamp-clutter-x11-enum-types.h
/po/Makefile.in.in

View File

@ -1,3 +1,26 @@
2008-11-24 Neil Roberts <neil@linux.intel.com>
Add a wrapper library to help testing without NPOTs.
* tests/tools/Makefile.am: Optionally build the
libdisable-npots.la library depending on whether libdl was
detected in the configure script. A helper script is also
generated to setup the LD_PRELOAD.
* tests/conform/Makefile.am: There are now two versions of the
test-report and full-report rules. test-report-normal is the same
as before and test-report-disable-npots runs the tests with the
disable-npots wrapper script. The full-report rule runs both of
them and displays two separate HTML files. The test-report rule
just runs the normal version as before.
* configure.ac: Add a test for libdl
* tests/tools/disable-npots.sh.in: New file. Template for the
helper script
* tests/tools/disable-npots.c: New file
2008-11-24 Neil Roberts <neil@linux.intel.com>
* clutter/cogl/gl/cogl-texture.c (cogl_texture_polygon): Fix the

View File

@ -242,6 +242,11 @@ if test "x$xinput" = "xyes"; then
X11_LIBS="$X11_LIBS -lXi"
fi
dnl This is only used to decide whether to build
dnl tests/tools/disable-npots.la
AC_CHECK_LIB(dl, dlopen, HAVE_LIBDL=yes, HAVE_LIBDL=no)
AM_CONDITIONAL(HAVE_LIBDL, test "x$HAVE_LIBDL" != "xno")
clutter_gl_header=""
use_gles2_wrapper="no"

View File

@ -39,19 +39,62 @@ test_conformance_CFLAGS = \
$(CLUTTER_CFLAGS)
test_conformance_LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la
.PHONY: test test-report full-report
.PHONY: test
.PHONY: test-report test-report-normal test-report-disable-npots
.PHONY: full-report full-report-normal full-report-disable-npots
.PHONY: full-report-generate
test:
gtester -o=test-conformance-results.xml ./test-conformance
test-report:
test-report-normal:
gtester -o=test-conformance-results.xml -k ./test-conformance \
&& gtester-report test-conformance-results.xml > test-conformance-results.html \
&& ( gtester-report test-conformance-results.xml \
| sed 's/>GTester Unit Test Report</>GTester Unit Test Report (normal)</' \
> test-conformance-results.html ) \
&& gnome-open ./test-conformance-results.html
full-report:
test-report-disable-npots:
../tools/disable-npots.sh \
gtester -o=test-conformance-results-dn.xml -k ./test-conformance \
&& ( gtester-report test-conformance-results-dn.xml \
| sed 's/>GTester Unit Test Report</>GTester Unit Test Report (no NPOTs)</' \
> test-conformance-results-dn.html ) \
&& gnome-open ./test-conformance-results-dn.html
test-report: test-report-normal
full-report-normal:
gtester -o=test-conformance-results.xml -k -m=slow ./test-conformance \
&& gtester-report test-conformance-results.xml > test-conformance-results.html \
&& gnome-open ./test-conformance-results.html
&& ( gtester-report test-conformance-results.xml \
| sed 's/>GTester Unit Test Report</>GTester Unit Test Report (normal)</' \
> test-conformance-results.html )
full-report-disable-npots:
../tools/disable-npots.sh \
gtester -o=test-conformance-results-dn.xml -k -m=slow ./test-conformance \
&& ( gtester-report test-conformance-results-dn.xml \
| sed 's/>GTester Unit Test Report</>GTester Unit Test Report (no NPOTs)</' \
> test-conformance-results-dn.html )
REPORTS = test-conformance-results.html
if HAVE_LIBDL
REPORTS += test-conformance-results-dn.html
full-report-generate: full-report-normal full-report-disable-npots
else
full-report-generate: full-report-normal
endif
full-report: full-report-generate
for x in $(REPORTS); do \
gnome-open "$$x"; \
done
EXTRA_DIST = ADDING_NEW_TESTS

View File

@ -1,2 +1,22 @@
lib_LTLIBRARIES =
EXTRA_DIST = README
if HAVE_LIBDL
lib_LTLIBRARIES += libdisable-npots.la
endif
libdisable_npots_la_SOURCES = disable-npots.c
libdisable_npots_la_LIBADD = -ldl
all-local : disable-npots.sh
clean-local :
rm -f disable-npots.sh
disable-npots.sh : $(top_builddir)/tests/tools/disable-npots.sh.in
sed 's|--builddir--|'`cd '$(top_builddir)' && pwd`'|' < $< > $@ && \
chmod 755 disable-npots.sh
EXTRA_DIST = README disable-npots.sh.in

View File

@ -0,0 +1,84 @@
/*
* This file can be build as a shared library and then used as an
* LD_PRELOAD to fake a system where NPOTs is not supported. It simply
* overrides glGetString and removes the extension strings.
*/
#include <GL/gl.h>
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
typedef const GLubyte * (* GetStringFunc) (GLenum name);
static const char * const bad_strings[]
= { "GL_ARB_texture_non_power_of_two",
"GL_ARB_texture_rectangle",
"GL_EXT_texture_rectangle",
NULL };
const GLubyte *
glGetString (GLenum name)
{
const GLubyte *ret = NULL;
static void *gl_lib = NULL;
static GetStringFunc func = NULL;
static GLubyte *extensions = NULL;
if (gl_lib == NULL
&& (gl_lib = dlopen ("libGL.so", RTLD_LAZY)) == NULL)
fprintf (stderr, "dlopen: %s\n", dlerror ());
else if (func == NULL
&& (func = (GetStringFunc) dlsym (gl_lib, "glGetString")) == NULL)
fprintf (stderr, "dlsym: %s\n", dlerror ());
else
{
ret = (* func) (name);
if (name == GL_EXTENSIONS)
{
if (extensions == NULL)
{
if ((extensions = (GLubyte *) strdup ((char *) ret)) == NULL)
fprintf (stderr, "strdup: %s\n", strerror (errno));
else
{
GLubyte *dst = extensions, *src = extensions;
while (1)
{
const char * const *str = bad_strings;
GLubyte *end;
while (isspace (*src))
*(dst++) = *(src++);
if (*src == 0)
break;
for (end = src + 1; *end && !isspace (*end); end++);
while (*str && strncmp ((char *) src, *str, end - src))
str++;
if (*str == NULL)
{
memcpy (dst, src, end - src);
dst += end - src;
}
src = end;
}
*dst = '\0';
}
}
ret = extensions;
}
}
return ret;
}

View File

@ -0,0 +1,15 @@
#!/bin/sh
# This script sets up the LD_PRELOAD environment to use
# libdisable-npots.la
# Read the .la file so we can get the library name
. "--builddir--/tests/tools/libdisable-npots.la"
if test -n "$LD_PRELOAD"; then
LD_PRELOAD="${LD_PRELOAD}:";
fi
export LD_PRELOAD="${LD_PRELOAD}--builddir--/tests/tools/.libs/${dlname}"
exec "$@"