Skip to content

Commit

Permalink
[libc] Make a couple of math smoke tests more robust. (#120808)
Browse files Browse the repository at this point in the history
Make sure to clear out all FE_ALL_EXCEPT bits both before and after
invoking function under test -- otherwise the very first check for the
exception bits in the unit test may fail due to bits set prior to test
invocation.
  • Loading branch information
vonosmas authored Dec 21, 2024
1 parent 96839a4 commit 6ecedb0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions libc/test/src/math/smoke/CanonicalizeTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "hdr/math_macros.h"

#define TEST_SPECIAL(x, y, expected, expected_exception) \
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \
EXPECT_EQ(expected, f(&x, &y)); \
EXPECT_FP_EXCEPTION(expected_exception); \
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT)
Expand Down
1 change: 1 addition & 0 deletions libc/test/src/math/smoke/FModTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "hdr/fenv_macros.h"

#define TEST_SPECIAL(x, y, expected, dom_err, expected_exception) \
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \
EXPECT_FP_EQ(expected, f(x, y)); \
EXPECT_MATH_ERRNO((dom_err) ? EDOM : 0); \
EXPECT_FP_EXCEPTION(expected_exception); \
Expand Down

0 comments on commit 6ecedb0

Please sign in to comment.