diff --git a/libc/test/src/math/exhaustive/exhaustive_test.h b/libc/test/src/math/exhaustive/exhaustive_test.h --- a/libc/test/src/math/exhaustive/exhaustive_test.h +++ b/libc/test/src/math/exhaustive/exhaustive_test.h @@ -22,5 +22,5 @@ void test_full_range(T start, T stop, int nthreads, mpfr::RoundingMode rounding); - virtual void check(T start, T stop, mpfr::RoundingMode rounding) = 0; + virtual bool check(T start, T stop, mpfr::RoundingMode rounding) = 0; }; diff --git a/libc/test/src/math/exhaustive/exhaustive_test.cpp b/libc/test/src/math/exhaustive/exhaustive_test.cpp --- a/libc/test/src/math/exhaustive/exhaustive_test.cpp +++ b/libc/test/src/math/exhaustive/exhaustive_test.cpp @@ -32,10 +32,11 @@ std::cout << msg.str(); msg.str(""); - check(begin, end, rounding); + bool result = check(begin, end, rounding); msg << "** Finished testing from " << std::dec << begin << " to " << end - << " [0x" << std::hex << begin << ", 0x" << end << ")" << std::endl; + << " [0x" << std::hex << begin << ", 0x" << end + << ") : " << (result ? "PASSED" : "FAILED") << std::endl; std::cout << msg.str(); }); begin += increment; diff --git a/libc/test/src/math/exhaustive/exp2f_test.cpp b/libc/test/src/math/exhaustive/exp2f_test.cpp --- a/libc/test/src/math/exhaustive/exp2f_test.cpp +++ b/libc/test/src/math/exhaustive/exp2f_test.cpp @@ -17,16 +17,18 @@ namespace mpfr = __llvm_libc::testing::mpfr; struct LlvmLibcExp2fExhaustiveTest : public LlvmLibcExhaustiveTest { - void check(uint32_t start, uint32_t stop, + bool check(uint32_t start, uint32_t stop, mpfr::RoundingMode rounding) override { mpfr::ForceRoundingMode r(rounding); uint32_t bits = start; + bool result = true; do { FPBits xbits(bits); float x = float(xbits); - EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 0.5, - rounding); + result = EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, + __llvm_libc::exp2f(x), 0.5, rounding); } while (bits++ < stop); + return result; } }; diff --git a/libc/test/src/math/exhaustive/expf_test.cpp b/libc/test/src/math/exhaustive/expf_test.cpp --- a/libc/test/src/math/exhaustive/expf_test.cpp +++ b/libc/test/src/math/exhaustive/expf_test.cpp @@ -17,16 +17,18 @@ namespace mpfr = __llvm_libc::testing::mpfr; struct LlvmLibcExpfExhaustiveTest : public LlvmLibcExhaustiveTest { - void check(uint32_t start, uint32_t stop, + bool check(uint32_t start, uint32_t stop, mpfr::RoundingMode rounding) override { mpfr::ForceRoundingMode r(rounding); uint32_t bits = start; + bool result = true; do { FPBits xbits(bits); float x = float(xbits); - EXPECT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 0.5, - rounding); + result = EXPECT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), + 0.5, rounding); } while (bits++ < stop); + return result; } }; diff --git a/libc/test/src/math/exhaustive/hypotf_test.cpp b/libc/test/src/math/exhaustive/hypotf_test.cpp --- a/libc/test/src/math/exhaustive/hypotf_test.cpp +++ b/libc/test/src/math/exhaustive/hypotf_test.cpp @@ -18,7 +18,7 @@ namespace mpfr = __llvm_libc::testing::mpfr; struct LlvmLibcHypotfExhaustiveTest : public LlvmLibcExhaustiveTest { - void check(uint32_t start, uint32_t stop, + bool check(uint32_t start, uint32_t stop, mpfr::RoundingMode rounding) override { // Range of the second input: [2^37, 2^48). constexpr uint32_t Y_START = (37U + 127U) << 23; @@ -26,13 +26,14 @@ mpfr::ForceRoundingMode r(rounding); uint32_t xbits = start; + bool result = true; do { float x = float(FPBits(xbits)); uint32_t ybits = Y_START; do { float y = float(FPBits(ybits)); - EXPECT_FP_EQ(__llvm_libc::fputil::hypot(x, y), - __llvm_libc::hypotf(x, y)); + result = EXPECT_FP_EQ(__llvm_libc::fputil::hypot(x, y), + __llvm_libc::hypotf(x, y)); // Using MPFR will be much slower. // mpfr::BinaryInput input{x, y}; // EXPECT_MPFR_MATCH(mpfr::Operation::Hypot, input, @@ -40,6 +41,7 @@ // rounding); } while (ybits++ < Y_STOP); } while (xbits++ < stop); + return result; } }; diff --git a/libc/test/src/math/exhaustive/log10f_test.cpp b/libc/test/src/math/exhaustive/log10f_test.cpp --- a/libc/test/src/math/exhaustive/log10f_test.cpp +++ b/libc/test/src/math/exhaustive/log10f_test.cpp @@ -17,16 +17,18 @@ namespace mpfr = __llvm_libc::testing::mpfr; struct LlvmLibcLog10fExhaustiveTest : public LlvmLibcExhaustiveTest { - void check(uint32_t start, uint32_t stop, + bool check(uint32_t start, uint32_t stop, mpfr::RoundingMode rounding) override { mpfr::ForceRoundingMode r(rounding); uint32_t bits = start; + bool result = true; do { FPBits xbits(bits); float x = float(xbits); - EXPECT_MPFR_MATCH(mpfr::Operation::Log10, x, __llvm_libc::log10f(x), 0.5, - rounding); + result = EXPECT_MPFR_MATCH(mpfr::Operation::Log10, x, + __llvm_libc::log10f(x), 0.5, rounding); } while (bits++ < stop); + return result; } }; diff --git a/libc/test/src/math/exhaustive/log1pf_test.cpp b/libc/test/src/math/exhaustive/log1pf_test.cpp --- a/libc/test/src/math/exhaustive/log1pf_test.cpp +++ b/libc/test/src/math/exhaustive/log1pf_test.cpp @@ -17,16 +17,18 @@ namespace mpfr = __llvm_libc::testing::mpfr; struct LlvmLibclog1pfExhaustiveTest : public LlvmLibcExhaustiveTest { - void check(uint32_t start, uint32_t stop, + bool check(uint32_t start, uint32_t stop, mpfr::RoundingMode rounding) override { mpfr::ForceRoundingMode r(rounding); uint32_t bits = start; + bool result = true; do { FPBits xbits(bits); float x = float(xbits); - EXPECT_MPFR_MATCH(mpfr::Operation::Log1p, x, __llvm_libc::log1pf(x), 0.5, - rounding); + result = EXPECT_MPFR_MATCH(mpfr::Operation::Log1p, x, + __llvm_libc::log1pf(x), 0.5, rounding); } while (bits++ < stop); + return result; } }; diff --git a/libc/test/src/math/exhaustive/log2f_test.cpp b/libc/test/src/math/exhaustive/log2f_test.cpp --- a/libc/test/src/math/exhaustive/log2f_test.cpp +++ b/libc/test/src/math/exhaustive/log2f_test.cpp @@ -17,16 +17,18 @@ namespace mpfr = __llvm_libc::testing::mpfr; struct LlvmLibcLog2fExhaustiveTest : public LlvmLibcExhaustiveTest { - void check(uint32_t start, uint32_t stop, + bool check(uint32_t start, uint32_t stop, mpfr::RoundingMode rounding) override { mpfr::ForceRoundingMode r(rounding); uint32_t bits = start; + bool result = true; do { FPBits xbits(bits); float x = float(xbits); - EXPECT_MPFR_MATCH(mpfr::Operation::Log2, x, __llvm_libc::log2f(x), 0.5, - rounding); + result = EXPECT_MPFR_MATCH(mpfr::Operation::Log2, x, + __llvm_libc::log2f(x), 0.5, rounding); } while (bits++ < stop); + return result; } }; diff --git a/libc/test/src/math/exhaustive/logf_test.cpp b/libc/test/src/math/exhaustive/logf_test.cpp --- a/libc/test/src/math/exhaustive/logf_test.cpp +++ b/libc/test/src/math/exhaustive/logf_test.cpp @@ -17,16 +17,18 @@ namespace mpfr = __llvm_libc::testing::mpfr; struct LlvmLibcLogfExhaustiveTest : public LlvmLibcExhaustiveTest { - void check(uint32_t start, uint32_t stop, + bool check(uint32_t start, uint32_t stop, mpfr::RoundingMode rounding) override { mpfr::ForceRoundingMode r(rounding); uint32_t bits = start; + bool result = true; do { FPBits xbits(bits); float x = float(xbits); - EXPECT_MPFR_MATCH(mpfr::Operation::Log, x, __llvm_libc::logf(x), 0.5, - rounding); + result = EXPECT_MPFR_MATCH(mpfr::Operation::Log, x, __llvm_libc::logf(x), + 0.5, rounding); } while (bits++ < stop); + return result; } }; diff --git a/libc/utils/UnitTest/LibcTest.h b/libc/utils/UnitTest/LibcTest.h --- a/libc/utils/UnitTest/LibcTest.h +++ b/libc/utils/UnitTest/LibcTest.h @@ -387,12 +387,12 @@ #define UNIQUE_VAR(prefix) __CAT(prefix, __LINE__) #define EXPECT_THAT(MATCH, MATCHER) \ - do { \ + [&]() -> bool { \ auto UNIQUE_VAR(__matcher) = (MATCHER); \ - this->testMatch(UNIQUE_VAR(__matcher).match((MATCH)), \ - UNIQUE_VAR(__matcher), #MATCH, #MATCHER, __FILE__, \ - __LINE__); \ - } while (0) + return this->testMatch(UNIQUE_VAR(__matcher).match((MATCH)), \ + UNIQUE_VAR(__matcher), #MATCH, #MATCHER, __FILE__, \ + __LINE__); \ + }() #define ASSERT_THAT(MATCH, MATCHER) \ do { \