[haiku-development] Re: Help needed with the unit testing framework

  • From: pulkomandy <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 29 Jul 2014 16:26:59 +0200

On Mon, Jul 28, 2014 at 08:33:59PM +0200, Ingo Weinhold wrote:
> On 28.07.2014 12:54, pulkomandy wrote:
> >Knowing that this only happens with gcc2, I think it somehow misses the fact
> >that the method is virtual when compiling the base class, and generates a
> >direct call instead of a virtual one (going through the vtable).
> 
> It's fairly easy to verify/refute that theory by using objdump on the code
> that invokes the method (objdump -D --demangle ...). If you build with debug
> info you can even interleave the disassembly with the source code (-S
> option).

Ok, using this I noticed that a proper virtual call was generated, but
the offset to the vtable was different. This helped me understand the
problem. The TestShell class has some optional features that are
disabled by the NO_ELF_SYMBOL_PATCHING define. This define is set when
compiling the lib, but not when compiling UnitTester, and with gcc2 it
seems the vtable layout is different (even though I see no extra virtual
method being defined when the define is unset).

Adding the define to UnitTester jamfile fixes the issue, and shows that
the implementation of LoadDynamicTests there is crashing. I will fix
that before I commit the change.

What's the best way to deal with this define? I can think of several
solutions but not sure which is the best:
* Have the methods defined in all cases, and move the define to their
implementations, so the vtable layout is the same in both case
* Remove support for symbol patching, as it looks like it can only used
in BeOS (I'm not sure if running our tests on BeOS using the unit test
framework is still possible)
* Make sure the define is always set properly, for example by adding it
to the UnitTest and UnitTestLib rules.

-- 
Adrien.

Other related posts: