Skip to content

Commit

Permalink
tests: Fix hostbuild tests not running when cross-compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwe committed Nov 3, 2023
1 parent e5dcca9 commit c5a650a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if(CORROSION_TESTS_INSTALL_CORROSION)
endif()

function(corrosion_tests_add_test test_name bin_names)
set(options "")
set(options "IS_HOSTBUILD")
set(one_value_kewords "TEST_SRC_DIR")
set(multi_value_keywords "")
cmake_parse_arguments(PARSE_ARGV 2 TST "${options}" "${one_value_kewords}" "${multi_value_keywords}")
Expand Down Expand Up @@ -141,7 +141,7 @@ function(corrosion_tests_add_test test_name bin_names)
set_tests_properties("${test_name}_run_${bin}" PROPERTIES FIXTURES_REQUIRED "build_fixture_${test_name}")
# CMAKE_CROSSCOMPILING is not set when cross-compiling with VS (via -A flag).
# Todo: We could run x86 binaries on x64 hosts.
if(CMAKE_CROSSCOMPILING OR CMAKE_VS_PLATFORM_NAME)
if((CMAKE_CROSSCOMPILING OR CMAKE_VS_PLATFORM_NAME) AND NOT "${TST_IS_HOSTBUILD}")
# Todo: In the future we could potentially run some tests with qemu.
set_tests_properties("${test_name}_run_${bin}" PROPERTIES DISABLED TRUE)
endif()
Expand Down
9 changes: 2 additions & 7 deletions test/hostbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# FIXME: ONly test this when cross-compiling?
corrosion_tests_add_test(hostbuild "rust-host-program")
corrosion_tests_add_test(hostbuild "rust-host-program" IS_HOSTBUILD)

set_tests_properties("hostbuild_run_rust-host-program" PROPERTIES PASS_REGULAR_EXPRESSION
"^ok\r?\nHello Rust Hostbuild, I am an external C function"
)
# Run tests are disabled by default when cross-compiling, however we still want to test hostbuild!
# So we manually re-enable the test here.
if(CMAKE_CROSSCOMPILING)
set_tests_properties("hostbuild_run_rust-host-program" PROPERTIES DISABLED FALSE)
endif()

0 comments on commit c5a650a

Please sign in to comment.