Unit testing with Google test / Google mock

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
JonHarrison
New User
Posts: 2
Joined: Mon May 21, 2018 3:42 pm

Unit testing with Google test / Google mock

Post by JonHarrison »

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

Post by robertxmos »

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

Post by JonHarrison »

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

Post by robertxmos »

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
Post Reply