Struggling with unit test

Stephan Bergmann sbergman at redhat.com
Tue May 14 07:30:44 UTC 2019


On 14/05/2019 02:32, Regina Henschel wrote:
> I need help again. I try to write a unit test 
> https://gerrit.libreoffice.org/#/c/72229/
> It works with Windows10. But Jenkins fails on Mac with message
> https://ci.libreoffice.org/job/gerrit_mac/32803/
> 
> Undefined symbols for architecture x86_64:
>    "SdrObjCustomShape::DragMoveCustomShapeHdl(Point const&, unsigned 
> short, bool)", referenced from:
>        (anonymous namespace)::testTdf115813_OOXML_XY_handle::TestBody() 
> in customshapes.o
>    "SdrObjCustomShape::GetInteractionHandles() const", referenced from:
>        (anonymous namespace)::testTdf115813_OOXML_XY_handle::TestBody() 
> in customshapes.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> 
> I have now build it in a VM with Ubuntu 16.0 LTS. There too I get an 
> error. Here the message is
> cd /home/vmregina/lo/core/svx && make -j 4 -rs check
> [build DEP] LNK:CppunitTest/libtest_svx_unit.so
> [build LNK] CppunitTest/libtest_svx_unit.so
> /usr/bin/ld.gold: error: 
> /home/vmregina/lo/core/workdir/CxxObject/svx/qa/unit/customshapes.o: 
> requires dynamic R_X86_64_PC32 reloc against 
> '_ZNK17SdrObjCustomShape21GetInteractionHandlesEv' which may overflow at 
> runtime; recompile with -fPIC
> /home/vmregina/lo/core/svx/qa/unit/customshapes.cxx:361: error: 
> undefined reference to 'SdrObjCustomShape::GetInteractionHandles() const'
> /home/vmregina/lo/core/svx/qa/unit/customshapes.cxx:365: error: 
> undefined reference to 'SdrObjCustomShape::GetInteractionHandles() const'
> /home/vmregina/lo/core/svx/qa/unit/customshapes.cxx:369: error: 
> undefined reference to 'SdrObjCustomShape::DragMoveCustomShapeHdl(Point 
> const&, unsigned short, bool)'
> /home/vmregina/lo/core/svx/qa/unit/customshapes.cxx:371: error: 
> undefined reference to 'SdrObjCustomShape::GetInteractionHandles() const'
> collect2: error: ld returned 1 exit status
> /home/vmregina/lo/core/solenv/gbuild/LinkTarget.mk:635: recipe for 
> target 
> '/home/vmregina/lo/core/workdir/LinkTarget/CppunitTest/libtest_svx_unit.so' 
> failed
> make[1]: *** 
> [/home/vmregina/lo/core/workdir/LinkTarget/CppunitTest/libtest_svx_unit.so] 
> Error 1
> Makefile:120: recipe for target 'svx.check' failed
> make: *** [svx.check] Error 2
> 
> What is needed for these systems? Does it make a difference whether it 
> is a debug build or not? My current Windows setting is a non-debug 
> build, in the Linux VM it is a debug-build.

In include/svx/svdoashp.hxx, the SdrObjCustomShape member functions 
GetInteractionHandles and DragMoveCustomShapeHdl are marked as 
SVX_DLLPRIVATE (i.e., SAL_DLLPRIVATE).  On Windows, that happens to have 
no effect, but on other platforms it prevents those symbols from being 
exported from the svxcore library, so you can't actually access those 
functions from test code.

The technically preferred solution would be if you can somehow avoid 
calling those functions directly from the test code.  Less appealing 
hacks to get it working are either to not mark those functions as 
SVX_DLLPRIVATE in include/svx/svdoashp.hxx, or to make 
svx/CppunitTest_svx_unit.mk use gb_CppunitTest_use_library_objects to 
directly include (copies of) the svxcore objects, instead of using 
gb_CppunitTest_use_libraries to link against the svxcore library.


More information about the LibreOffice mailing list