I'd like to run our cross-compiled unit test suite on my host system using qemu and invoke the tests with CTest.
For that purpose I've configured and set up CMake with the necessary toolchain information, such as: CMAKE_SYSTEM_PROCESSOR: armv5e-our, CMAKE_CROSS_COMPILING=TRUE, CMAKE_CROSSCOMPILING_EMULATOR='/opt/xunil/1.0.0/sysroots/x86_64-oursdk-linux/usr/bin/qemu-arm;-L;/opt/xunil/1.0.0/sysroots/armv5e-our-linux-gnueabi/' and so forth.
For our new unit tests, written in Google Test, this works like a charm and CTest reports that all tests pass successfully :-)
However, now when I try to include the old unit tests written in CxxTest, I've run into trouble. The unit tests are simple and a simplified CMake config is simple as well:
find_package(CxxTest)
if (CXXTEST_FOUND)
include_directories(${CXXTEST_INCLUDE_DIRS})
CXXTEST_ADD_TEST(myunittest testRunner.cpp ${CMAKE_CURRENT_SOURCE_DIR}/myunittest.h)
set_target_properties(myunittest PROPERTIES LINKER_LANGUAGE CXX)
get_target_property(emulator myunittest CROSSCOMPILING_EMULATOR)
message(STATUS "myunittest:CROSSCOMPILING_EMULATOR='${emulator}'")
target_link_libraries(myunittest myunittestlib)
endif()
I've verified that the test target's CROSSCOMPILING_EMULATOR property is set as specified by the CMAKE_CROSSCOMPILING_EMULATOR.
Therefore, CXXTEST_ADD_TEST, which in turn calls CMake's add_test(), should have enough of information for CMake/CTest to run the unit test using qemu as specified, at least according to the documentation of CROSSCOMPILING_EMULATOR. And I've verified it to work using gtest above (though I'm not sure how gtest calls add_test(), maybe it uses the add_test(NAME) variant, but that should not matter according to the docs).
I should mention that myunittest is successfully built and when manually executing it from the command line using qemu-arm it runs just fine with all unit tests passed.
However, when I run the unit tests using CTest, the CxxTest fails and I see the following:
$ ctest -VV
test 1
1: Test command: /opt/xunil/1.0.0/sysroots/x86_64-oursdk-linux/usr/bin/qemu-arm "-L" "/opt/xunil/1.0.0/sysroots/armv5e-our-linux-gnueabi/" "/home/rune/devel/xyz-apps/bld/libxyz/test/unittest1" "--gtest_filter=UnitTest1.BasicAssertions" "--gtest_also_run_disabled_tests"
1: Running main() from /home/rune/devel/xyz-apps/bld/_deps/googletest-src/googletest/src/gtest_main.cc
1/2 Test #1: UnitTest1.BasicAssertions ....... Passed 0.09 sec
test 2
2: Test command: /home/rune/devel/xyz-apps/bld/libxyz/test/myunittest
2: /home/rune/devel/xyz-apps/bld/libxyz/test/myunittest: 1: Syntax error: word unexpected (expecting ")")
2/2 Test #2: myunittest ...................***Failed 0.01 sec
50% tests passed, 1 tests failed out of 2
The following tests FAILED:
2 - myunittest (Failed)
Obviously, according to the second Test command printout (if CTest's printout can be trusted), the CxxTest's unit test is surprisingly not invoked using the qemu-arm emulator!? How come? Have I done something wrong? Can I workaround this somehow?
Any tips would be much appreciated!