[RFC/PATCH 0/2] The beginnings of an in-server unit test suite.

Peter Hutterer peter.hutterer at who-t.net
Wed Apr 22 00:05:31 PDT 2009


On Tue, Apr 21, 2009 at 06:36:06AM -0700, Dan Nicholson wrote:
> > diff --git a/test/Makefile.am b/test/Makefile.am
> > new file mode 100644
> > index 0000000..6abcc92
> > --- /dev/null
> > +++ b/test/Makefile.am
> > @@ -0,0 +1,52 @@
> > +if UNITTESTS
> > +check_PROGRAMS = xkb
> > +check_LTLIBRARIES = libxservertest.la libxservertest_t.la
> > +
> > +TESTS=$(check_PROGRAMS)
> > +
> > +# This makefile is not happy if you have concurrent makes going on.
> > +AM_MAKEFLAGS = -j1
> > +
> > +AM_CFLAGS = $(DIX_CFLAGS) $(GLIB_CFLAGS) @XORG_CFLAGS@
> > +INCLUDES = @XORG_INCS@
> > +TEST_LDFLAGS=.libs/libxservertest_t.a $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLIB_LIBS)
> > +
> > +xkb_LDFLAGS=$(TEST_LDFLAGS)
> 
> It might not ever matter, but this breaks how arguments are ordered
> for libtool. For programs, you want to use _LDADD to add libraries.

thanks, amended.

> > +
> > +
> > +libxservertest_la_LIBADD = \
> > +            $(XSERVER_LIBS) \
> > +            $(top_builddir)/hw/xfree86/loader/libloader.la \
> > +            $(top_builddir)/hw/xfree86/os-support/libxorgos.la \
> > +            $(top_builddir)/hw/xfree86/common/libcommon.la \
> > +            $(top_builddir)/hw/xfree86/parser/libxf86config.la \
> > +            $(top_builddir)/hw/xfree86/dixmods/libdixmods.la \
> > +            $(top_builddir)/hw/xfree86/modes/libxf86modes.la \
> > +            $(top_builddir)/hw/xfree86/ramdac/libramdac.la \
> > +            $(top_builddir)/hw/xfree86/ddc/libddc.la \
> > +            $(top_builddir)/hw/xfree86/i2c/libi2c.la \
> > +            $(top_builddir)/hw/xfree86/dixmods/libxorgxkb.la \
> > +            $(top_builddir)/hw/xfree86/libxorg.la \
> > +            $(top_builddir)/mi/libmi.la \
> > +            $(top_builddir)/os/libos.la \
> > +            @XORG_LIBS@
> > +
> > +CLEANFILES=libxservertest_t.c libxservertest.c
> > +
> > +libxservertest_t.c:
> > +       touch $@
> > +
> > +libxservertest.c:
> > +       touch $@
> > +
> > +# libxservertest.la defines main, so we need to get rid of it somehow.
> > +# we do this by copying libxservertest.a into libxservertest_t.a and removing the
> > +# symbol during the copy process.
> > +libxservertest_t.la: libxservertest.la
> > +       $(OBJCOPY) --strip-symbol=main .libs/libxservertest.a .libs/libxservertest_t.a
> 
> If this is how you want to do it, don't define libxservertest_t as a
> libtool library (check_LTLIBRARIES). It just confuses the tools. Just
> make the target libxservertest.a and then the file make is looking for
> (libxserverttest_t.a) will actually be there. Since you're defining a
> custom rule for generating the .a, there's no benefit to defining it
> as libtool library. It also means you don't have to create
> libxservertest_t.c.

amended, thanks

> 
> On the other hand, it's pretty gross. :) The two alternatives that come to mind:
> 
> 1. Don't actually define main in dix. Instead have it called dixmain
> or something so that any DDX (or test program) can decide to override
> it or not. I think you already mentioned this.

this is part one of the plan. I've got a patch sitting locally that does
exactly that and it simplifies the makefile quite a bit.
the reason why I did the symbol override was to slot the suite in without any
major changes to the server itself.
anyway - moving main() into a libmain.la makes the whole think simpler for now.

> 2. Try to get libtool to not export main from libxservert.la. I
> haven't tried this, but I believe you could do:
> 
> libxservertest_la_LDFLAGS = -export-symbols-regex '...'
> 
> Unfortunately, my regex foo does not match my autotools foo, so I
> don't know a regex that says "everything except main".

I played with that and failed miserably. couldn't even get it to only export
the regex I provided.

anyway - longer-term it would be good if we could automate the stripping of
symbols somehow so that we can override server function with test dummies. Not
sure how to do that yet, but either the objcopy or the export-symbols-regex
seems to be the best approaches here.

ideally, a test case "foo" would just specify that it needs to override
e.g. mieqEnqueue and GetPointerEvents and the build system strips it out
accordingly.

If you have any input on that - much appreciated, I have a couple of testcases
that would need that functionality.

> > +
> > +
> > +all:
> > +       echo "Run 'make check' to run the test suite"
> 
> @echo ... to suppress the command being printed.

amended, thanks. Below is the updated Makefile.am
 
Cheers,
  Peter



More information about the xorg-devel mailing list