Page 1 of 1

Unit testing with Google test / Google mock

Posted: Mon May 21, 2018 3:46 pm
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

Re: Unit testing with Google test / Google mock

Posted: Tue May 22, 2018 9:10 am
by robertxmos
Can you be more specific regarding what is missing please.
robert

Re: Unit testing with Google test / Google mock

Posted: Tue May 22, 2018 1:15 pm
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'

Re: Unit testing with Google test / Google mock

Posted: Wed May 23, 2018 11:29 am
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