From 0a48cb7d81077fa34bb14a5d074586ddd15e9ae1 Mon Sep 17 00:00:00 2001 From: Thomas Kittelmann Date: Fri, 7 Feb 2025 13:21:22 +0100 Subject: [PATCH] Disable FPE checking on arm --- tests/libs/lib_fpe/FPE.cc | 2 +- tests/modules/lib_fpe/fpe.cc | 9 +++++++-- tests/pypath/NCTestUtils/enable_fpe.py | 6 ++++++ tests/scripts/fpe.py | 13 ++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/libs/lib_fpe/FPE.cc b/tests/libs/lib_fpe/FPE.cc index bbc64926..53aaa0fc 100644 --- a/tests/libs/lib_fpe/FPE.cc +++ b/tests/libs/lib_fpe/FPE.cc @@ -21,7 +21,7 @@ #include "TestLib_fpe/FPE.hh" -#if defined(__APPLE__) || defined(_WIN32) || defined(WIN32) +#if defined(__APPLE__) || defined(_WIN32) || defined(WIN32) || defined(__arm) || defined(__arm64) || defined(__aarch64__) || defined(__arm__) || defined(_M_ARM64) || defined(__amd64) || defined(__amd64__) void NCTests::catch_fpe(){} #else diff --git a/tests/modules/lib_fpe/fpe.cc b/tests/modules/lib_fpe/fpe.cc index 3ac029eb..186a5772 100644 --- a/tests/modules/lib_fpe/fpe.cc +++ b/tests/modules/lib_fpe/fpe.cc @@ -23,16 +23,20 @@ NCTEST_CTYPE_DICTIONARY { - return "void nctest_catch_fpe()"; + return + "void nctest_catch_fpe();" + "int nctest_can_catch_fpe();" + ; } //todo: try to enable on osx/windows? -#if defined (_WIN32) || defined (__CYGWIN__) || defined (WIN32) || defined(__APPLE__) +#if defined(__APPLE__) || defined(_WIN32) || defined(WIN32) || defined(__arm) || defined(__arm64) || defined(__aarch64__) || defined(__arm__) || defined(_M_ARM64) # define NCTEST_SKIP_FPE #endif #ifdef NCTEST_SKIP_FPE NCTEST_CTYPES void nctest_catch_fpe(){} +NCTEST_CTYPES int nctest_can_catch_fpe(){ return 0; } #else # include @@ -90,6 +94,7 @@ namespace { } } +NCTEST_CTYPES int nctest_can_catch_fpe(){ return 1; } NCTEST_CTYPES void nctest_catch_fpe() { try { diff --git a/tests/pypath/NCTestUtils/enable_fpe.py b/tests/pypath/NCTestUtils/enable_fpe.py index 669f35eb..cd4bfd28 100644 --- a/tests/pypath/NCTestUtils/enable_fpe.py +++ b/tests/pypath/NCTestUtils/enable_fpe.py @@ -26,10 +26,16 @@ __all__=[] +_can_catch = [False] +def is_catching_fpe(): + return _can_catch[0] + def _enable_fpe(): from .loadlib import Lib lib = Lib('fpe') lib.nctest_catch_fpe() + if lib.nctest_can_catch_fpe(): + _can_catch[0] = True return lib __keepalive = _enable_fpe() diff --git a/tests/scripts/fpe.py b/tests/scripts/fpe.py index 0abcb293..b2f40acd 100755 --- a/tests/scripts/fpe.py +++ b/tests/scripts/fpe.py @@ -56,7 +56,18 @@ def div_in_subproc( a, b ): def main(): div_in_subproc( 1.0,2.0) div_in_subproc( 10.0,2.0 ) - if platform.system().lower() not in ('windows','darwin'): + + can_catch_fpe = NCTestUtils.enable_fpe.is_catching_fpe() + + if platform.system().lower() in ('windows','darwin'): + assert not can_catch_fpe + else: + if 'intel' in platform.processor().lower(): + assert can_catch_fpe + elif 'aarch64' in platform.processor().lower(): + assert not can_catch_fpe + + if can_catch_fpe: div_in_subproc( 1.0, 0.0 ) if __name__ == '__main__':