Unit testing with Google test / Google mock

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
JonHarrison
New User
Posts: 2
Joined: Mon May 21, 2018 3:42 pm

Unit testing with Google test / Google mock

Postby JonHarrison » Mon May 21, 2018 3:46 pm

Hi,

Just starting out with XMOS development and want to use the Google test / mock framework for unit testing as I've done on other projects but having problems getting the framework to build under XC / XTimeComposer as standard libraries seem to be missing. Has anyone had any success / have any tips ?

Thanks,

Jon
robertxmos
XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Postby robertxmos » Tue May 22, 2018 9:10 am

Can you be more specific regarding what is missing please.
robert
JonHarrison
New User
Posts: 2
Joined: Mon May 21, 2018 3:42 pm

Postby JonHarrison » Tue May 22, 2018 1:15 pm

Hi Robert,

I've added -DGTEST_HAS_POSIX_RE=0 to the makefile and included gtest-all.cc to the project but it has a number of unresolved references

main.cc: Error: Undefined reference to '_ZN7testing14InitGoogleTestEPiPPc'
main.cc: Error: Undefined reference to '_ZN7testing4Test5SetUpEv'
main.cc: Error: Undefined reference to '_ZN7testing4Test8TearDownEv'
main.cc: Error: Undefined reference to '_ZN7testing4TestC2Ev'
main.cc: Error: Undefined reference to '_ZN7testing4TestD2Ev'
main.cc: Error: Undefined reference to '_ZN7testing8UnitTest11GetInstanceEv'
main.cc: Error: Undefined reference to '_ZN7testing8UnitTest3RunEv'
main.cc: Error: Undefined reference to '_ZN7testing8internal13GetTestTypeIdEv'
main.cc: Error: Undefined reference to '_ZN7testing8internal23MakeAndRegisterTestInfoEPKcS2_S2_S2_NS0_12CodeLocationEPKvPFvvES7_PNS0_15TestFactoryBaseE'
main.cc: Error: Undefined reference to '_ZTIN7testing4TestE'
robertxmos
XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Postby robertxmos » Wed May 23, 2018 11:29 am

Hi,
The missing items look like they are all from the framework viz: testing::InitGoogleTest(int*, char**).
(you can run `c++filt _ZN7testing14InitGoogleTestEPiPPc` to demangle the names).
Have you included the source files to build these items?
Add `-v` to the build flags to see what files are being built and linked.
robert

Who is online

Users browsing this forum: No registered users and 30 guests