From c5a650a8286539a57ad9862b5f3ea1d6d8e55a0f Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Fri, 3 Nov 2023 19:12:28 +0100 Subject: [PATCH] tests: Fix hostbuild tests not running when cross-compiling --- test/CMakeLists.txt | 4 ++-- test/hostbuild/CMakeLists.txt | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 37d50585..1a42ba4d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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}") @@ -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() diff --git a/test/hostbuild/CMakeLists.txt b/test/hostbuild/CMakeLists.txt index d98bba00..0d1c831c 100644 --- a/test/hostbuild/CMakeLists.txt +++ b/test/hostbuild/CMakeLists.txt @@ -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() +