Skip to content

Commit d3d38d2

Browse files
committed
Fix feholdexcept_test.
1 parent 67b6be6 commit d3d38d2

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

libc/test/src/fenv/feholdexcept_test.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,6 @@
2020
using LlvmLibcFEnvTest = LIBC_NAMESPACE::testing::FEnvSafeTest;
2121

2222
TEST_F(LlvmLibcFEnvTest, RaiseAndCrash) {
23-
#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || \
24-
defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
25-
// Few Arm HW implementations do not trap exceptions. We skip this test
26-
// completely on such HW.
27-
//
28-
// Whether HW supports trapping exceptions or not is deduced by enabling an
29-
// exception and reading back to see if the exception got enabled. If the
30-
// exception did not get enabled, then it means that the HW does not support
31-
// trapping exceptions.
32-
LIBC_NAMESPACE::fputil::disable_except(FE_ALL_EXCEPT);
33-
LIBC_NAMESPACE::fputil::enable_except(FE_DIVBYZERO);
34-
if (LIBC_NAMESPACE::fputil::get_except() == 0)
35-
return;
36-
#endif // Architectures where exception trapping is not supported
37-
3823
int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
3924
FE_UNDERFLOW};
4025

@@ -48,6 +33,7 @@ TEST_F(LlvmLibcFEnvTest, RaiseAndCrash) {
4833
// should not crash/invoke the exception handler.
4934
ASSERT_EQ(LIBC_NAMESPACE::fputil::raise_except(e), 0);
5035

36+
#if defined(LIBC_TRAP_ON_RAISE_FP_EXCEPT) && defined(__SSE__)
5137
ASSERT_RAISES_FP_EXCEPT([=] {
5238
// When we put back the saved env, which has the exception enabled, it
5339
// should crash with SIGFPE. Note that we set the old environment
@@ -59,6 +45,7 @@ TEST_F(LlvmLibcFEnvTest, RaiseAndCrash) {
5945
LIBC_NAMESPACE::fputil::set_env(&env);
6046
LIBC_NAMESPACE::fputil::raise_except(e);
6147
});
48+
#endif // LIBC_TRAP_ON_RAISE_FP_EXCEPT
6249

6350
// Cleanup
6451
LIBC_NAMESPACE::fputil::disable_except(FE_ALL_EXCEPT);

0 commit comments

Comments
 (0)