Skip to content

Commit

Permalink
Disable FPE checking on arm
Browse files Browse the repository at this point in the history
  • Loading branch information
tkittel committed Feb 7, 2025
1 parent cc10502 commit 0a48cb7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/libs/lib_fpe/FPE.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions tests/modules/lib_fpe/fpe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cassert>
Expand Down Expand Up @@ -90,6 +94,7 @@ namespace {
}
}

NCTEST_CTYPES int nctest_can_catch_fpe(){ return 1; }
NCTEST_CTYPES void nctest_catch_fpe()
{
try {
Expand Down
6 changes: 6 additions & 0 deletions tests/pypath/NCTestUtils/enable_fpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 12 additions & 1 deletion tests/scripts/fpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down

0 comments on commit 0a48cb7

Please sign in to comment.