43 changes: 21 additions & 22 deletions libc/test/src/fenv/exception_status_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@
#include "src/fenv/fetestexcept.h"

#include "src/__support/FPUtil/FEnvImpl.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/Test.h"

#include "hdr/fenv_macros.h"

TEST(LlvmLibcExceptionStatusTest, RaiseAndTest) {
#include "excepts.h"

using LlvmLibcExceptionStatusTest = LIBC_NAMESPACE::testing::FEnvSafeTest;

TEST_F(LlvmLibcExceptionStatusTest, RaiseAndTest) {
// This test raises a set of exceptions and checks that the exception
// status flags are updated. The intention is really not to invoke the
// exception handler. Hence, we will disable all exceptions at the
// beginning.
LIBC_NAMESPACE::fputil::disable_except(FE_ALL_EXCEPT);

int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
FE_UNDERFLOW};

constexpr int ALL_EXCEPTS =
FE_DIVBYZERO | FE_INVALID | FE_INEXACT | FE_OVERFLOW | FE_UNDERFLOW;

for (int e : excepts) {
for (int e : EXCEPTS) {
int r = LIBC_NAMESPACE::feraiseexcept(e);
ASSERT_EQ(r, 0);
int s = LIBC_NAMESPACE::fetestexcept(e);
Expand All @@ -47,8 +46,8 @@ TEST(LlvmLibcExceptionStatusTest, RaiseAndTest) {
ASSERT_EQ(s, e);
}

for (int e1 : excepts) {
for (int e2 : excepts) {
for (int e1 : EXCEPTS) {
for (int e2 : EXCEPTS) {
int e = e1 | e2;
int r = LIBC_NAMESPACE::feraiseexcept(e);
ASSERT_EQ(r, 0);
Expand All @@ -67,9 +66,9 @@ TEST(LlvmLibcExceptionStatusTest, RaiseAndTest) {
}
}

for (int e1 : excepts) {
for (int e2 : excepts) {
for (int e3 : excepts) {
for (int e1 : EXCEPTS) {
for (int e2 : EXCEPTS) {
for (int e3 : EXCEPTS) {
int e = e1 | e2 | e3;
int r = LIBC_NAMESPACE::feraiseexcept(e);
ASSERT_EQ(r, 0);
Expand All @@ -89,10 +88,10 @@ TEST(LlvmLibcExceptionStatusTest, RaiseAndTest) {
}
}

for (int e1 : excepts) {
for (int e2 : excepts) {
for (int e3 : excepts) {
for (int e4 : excepts) {
for (int e1 : EXCEPTS) {
for (int e2 : EXCEPTS) {
for (int e3 : EXCEPTS) {
for (int e4 : EXCEPTS) {
int e = e1 | e2 | e3 | e4;
int r = LIBC_NAMESPACE::feraiseexcept(e);
ASSERT_EQ(r, 0);
Expand All @@ -113,11 +112,11 @@ TEST(LlvmLibcExceptionStatusTest, RaiseAndTest) {
}
}

for (int e1 : excepts) {
for (int e2 : excepts) {
for (int e3 : excepts) {
for (int e4 : excepts) {
for (int e5 : excepts) {
for (int e1 : EXCEPTS) {
for (int e2 : EXCEPTS) {
for (int e3 : EXCEPTS) {
for (int e4 : EXCEPTS) {
for (int e5 : EXCEPTS) {
int e = e1 | e2 | e3 | e4 | e5;
int r = LIBC_NAMESPACE::feraiseexcept(e);
ASSERT_EQ(r, 0);
Expand Down
24 changes: 24 additions & 0 deletions libc/test/src/fenv/excepts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===-- List of all FE_* constants for tests -----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//

#ifndef LLVM_LIBC_TEST_SRC_FENV_EXCEPTS_H
#define LLVM_LIBC_TEST_SRC_FENV_EXCEPTS_H

#include "hdr/fenv_macros.h"

constexpr int EXCEPTS[] = {
FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW, FE_UNDERFLOW,
};

// We '|' the individual exception flags instead of using FE_ALL_EXCEPT
// as it can include non-standard extensions. Note that we should be able
// to compile this file with headers from other libcs as well.
constexpr int ALL_EXCEPTS =
FE_DIVBYZERO | FE_INVALID | FE_INEXACT | FE_OVERFLOW | FE_UNDERFLOW;

#endif // LLVM_LIBC_TEST_SRC_FENV_EXCEPTS_H
21 changes: 12 additions & 9 deletions libc/test/src/fenv/feclearexcept_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@
#include "src/fenv/feclearexcept.h"

#include "src/__support/FPUtil/FEnvImpl.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/Test.h"

#include "hdr/fenv_macros.h"
#include <stdint.h>

TEST(LlvmLibcFEnvTest, ClearTest) {
uint16_t excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
FE_UNDERFLOW};
#include "excepts.h"

using LlvmLibcFEnvTest = LIBC_NAMESPACE::testing::FEnvSafeTest;

TEST_F(LlvmLibcFEnvTest, ClearTest) {
LIBC_NAMESPACE::fputil::disable_except(FE_ALL_EXCEPT);
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);

for (uint16_t e : excepts)
for (int e : EXCEPTS)
ASSERT_EQ(LIBC_NAMESPACE::fputil::test_except(e), 0);

LIBC_NAMESPACE::fputil::raise_except(FE_ALL_EXCEPT);

for (uint16_t e1 : excepts) {
for (uint16_t e2 : excepts) {
for (uint16_t e3 : excepts) {
for (uint16_t e4 : excepts) {
for (uint16_t e5 : excepts) {
for (int e1 : EXCEPTS) {
for (int e2 : EXCEPTS) {
for (int e3 : EXCEPTS) {
for (int e4 : EXCEPTS) {
for (int e5 : EXCEPTS) {
// We clear one exception and test to verify that it was cleared.
LIBC_NAMESPACE::feclearexcept(e1 | e2 | e3 | e4 | e5);
ASSERT_EQ(
Expand Down
7 changes: 6 additions & 1 deletion libc/test/src/fenv/feenableexcept_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
#include "src/fenv/feenableexcept.h"
#include "src/fenv/fegetexcept.h"

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/Test.h"

#include "hdr/fenv_macros.h"

TEST(LlvmLibcFEnvTest, EnableTest) {
#include "excepts.h"

using LlvmLibcFEnvTest = LIBC_NAMESPACE::testing::FEnvSafeTest;

TEST_F(LlvmLibcFEnvTest, EnableTest) {
#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || \
defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
// Few Arm HW implementations do not trap exceptions. We skip this test
Expand Down
7 changes: 6 additions & 1 deletion libc/test/src/fenv/feholdexcept_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@

#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/macros/properties/architectures.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPExceptMatcher.h"
#include "test/UnitTest/Test.h"

TEST(LlvmLibcFEnvTest, RaiseAndCrash) {
#include "excepts.h"

using LlvmLibcFEnvTest = LIBC_NAMESPACE::testing::FEnvSafeTest;

TEST_F(LlvmLibcFEnvTest, RaiseAndCrash) {
#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || \
defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
// Few Arm HW implementations do not trap exceptions. We skip this test
Expand Down
5 changes: 3 additions & 2 deletions libc/test/src/fenv/feupdateenv_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#include "src/fenv/feupdateenv.h"

#include "src/__support/FPUtil/FEnvImpl.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/Test.h"

#include <signal.h>
using LlvmLibcFEnvTest = LIBC_NAMESPACE::testing::FEnvSafeTest;

TEST(LlvmLibcFEnvTest, UpdateEnvTest) {
TEST_F(LlvmLibcFEnvTest, UpdateEnvTest) {
LIBC_NAMESPACE::fputil::disable_except(FE_ALL_EXCEPT);
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);

Expand Down
14 changes: 8 additions & 6 deletions libc/test/src/fenv/getenv_and_setenv_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@
#include "src/fenv/fesetround.h"

#include "src/__support/FPUtil/FEnvImpl.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/Test.h"

TEST(LlvmLibcFenvTest, GetEnvAndSetEnv) {
#include "excepts.h"

using LlvmLibcFEnvTest = LIBC_NAMESPACE::testing::FEnvSafeTest;

TEST_F(LlvmLibcFEnvTest, GetEnvAndSetEnv) {
// We will disable all exceptions to prevent invocation of the exception
// handler.
LIBC_NAMESPACE::fputil::disable_except(FE_ALL_EXCEPT);

int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
FE_UNDERFLOW};

for (int e : excepts) {
for (int e : EXCEPTS) {
LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT);

// Save the cleared environment.
Expand Down Expand Up @@ -71,7 +73,7 @@ TEST(LlvmLibcFenvTest, Set_FE_DFL_ENV) {
}

#ifdef _WIN32
TEST(LlvmLibcFenvTest, Windows_Set_Get_Test) {
TEST_F(LlvmLibcFEnvTest, Windows_Set_Get_Test) {
// If a valid fenv_t is written, then reading it back out should be identical.
fenv_t setEnv = {0x7e00053e, 0x0f00000f};
fenv_t getEnv;
Expand Down
9 changes: 6 additions & 3 deletions libc/test/src/fenv/rounding_mode_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
#include "src/fenv/fegetround.h"
#include "src/fenv/fesetround.h"

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/Test.h"

#include "hdr/fenv_macros.h"

TEST(LlvmLibcRoundingModeTest, SetAndGet) {
using LlvmLibcRoundingModeTest = LIBC_NAMESPACE::testing::FEnvSafeTest;

TEST_F(LlvmLibcRoundingModeTest, SetAndGet) {
struct ResetDefaultRoundingMode {
int original;
int original = LIBC_NAMESPACE::fegetround();
~ResetDefaultRoundingMode() { LIBC_NAMESPACE::fesetround(original); }
} reset{LIBC_NAMESPACE::fegetround()};
} reset;

int s = LIBC_NAMESPACE::fesetround(FE_TONEAREST);
EXPECT_EQ(s, 0);
Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/CeilTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -14,7 +15,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class CeilTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class CeilTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/CopySignTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -15,7 +16,7 @@
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T>
class CopySignTest : public LIBC_NAMESPACE::testing::Test {
class CopySignTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/FAbsTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_FABSTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_FABSTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -17,7 +18,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class FAbsTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FAbsTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/FDimTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
class FDimTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
using FuncPtr = T (*)(T, T);
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/FMaxTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_FMAXTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_FMAXTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -17,7 +18,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class FMaxTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FMaxTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/FMinTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_FMINTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_FMINTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -17,7 +18,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class FMinTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FMinTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/FModTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

Expand All @@ -24,7 +25,8 @@

#define TEST_REGULAR(x, y, expected) TEST_SPECIAL(x, y, expected, false, 0)

template <typename T> class FmodTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/FloorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_FLOORTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_FLOORTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -17,7 +18,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class FloorTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FloorTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/FmaTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
#include "src/__support/FPUtil/FPBits.h"
#include "src/stdlib/rand.h"
#include "src/stdlib/srand.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T>
class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
class FmaTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
private:
using Func = T (*)(T, T, T);
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/FrexpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "src/__support/FPUtil/BasicOperations.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -15,7 +16,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class FrexpTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FrexpTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/HypotTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define LLVM_LIBC_TEST_SRC_MATH_HYPOTTEST_H

#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -19,7 +20,7 @@
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T>
class HypotTestTemplate : public LIBC_NAMESPACE::testing::Test {
class HypotTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
private:
using Func = T (*)(T, T);
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/ILogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
#include "src/__support/CPP/limits.h" // INT_MAX
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/Test.h"

class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
template <typename T> struct ILogbFunc {
typedef int (*Func)(T);
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/LdExpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
#include "src/__support/CPP/limits.h" // INT_MAX
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/NormalFloat.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"
#include <stdint.h>

template <typename T>
class LdExpTestTemplate : public LIBC_NAMESPACE::testing::Test {
class LdExpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using NormalFloat = LIBC_NAMESPACE::fputil::NormalFloat<T>;
using StorageType = typename FPBits::StorageType;
Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/LogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -15,7 +16,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class LogbTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class LogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/ModfTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -16,7 +17,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class ModfTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class ModfTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/NextAfterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::Test {
class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using StorageType = typename FPBits::StorageType;

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/RIntTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -25,7 +26,7 @@ static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
FE_TONEAREST};

template <typename T>
class RIntTestTemplate : public LIBC_NAMESPACE::testing::Test {
class RIntTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
typedef T (*RIntFunc)(T);

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/RemQuoTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T>
class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::Test {
class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using StorageType = typename FPBits::StorageType;

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/RoundEvenTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_ROUNDEVENTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_ROUNDEVENTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -18,7 +19,7 @@
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T>
class RoundEvenTest : public LIBC_NAMESPACE::testing::Test {
class RoundEvenTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/RoundTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_ROUNDTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_ROUNDTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -17,7 +18,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class RoundTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class RoundTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
6 changes: 5 additions & 1 deletion libc/test/src/math/RoundToIntegerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -24,7 +25,8 @@ static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
FE_TONEAREST};

template <typename F, typename I, bool TestModes = false>
class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
class RoundToIntegerTestTemplate
: public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
typedef I (*RoundToIntegerFunc)(F);

Expand Down Expand Up @@ -81,6 +83,8 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {

public:
void SetUp() override {
LIBC_NAMESPACE::testing::FEnvSafeTest::SetUp();

if (math_errhandling & MATH_ERREXCEPT) {
// We will disable all exceptions so that the test will not
// crash with SIGFPE. We can still use fetestexcept to check
Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/SqrtTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "src/__support/CPP/bit.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -15,7 +16,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class SqrtTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class SqrtTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/TruncTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_TRUNCTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_TRUNCTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -17,7 +18,8 @@

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T> class TruncTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class TruncTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h" // ldexp
#include "src/__support/FPUtil/generic/FMod.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
Expand All @@ -18,7 +19,7 @@
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

template <typename T, bool InverseMultiplication>
class LlvmLibcFModTest : public LIBC_NAMESPACE::testing::Test {
class LlvmLibcFModTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using U = typename FPBits::StorageType;
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/CanonicalizeTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/integer_literals.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

Expand All @@ -26,7 +27,7 @@
using LIBC_NAMESPACE::operator""_u128;

template <typename T>
class CanonicalizeTest : public LIBC_NAMESPACE::testing::Test {
class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/CeilTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_CEILTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_CEILTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T> class CeilTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class CeilTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/CopySignTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_COPYSIGNTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_COPYSIGNTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T>
class CopySignTest : public LIBC_NAMESPACE::testing::Test {
class CopySignTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/FAbsTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FABSTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FABSTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T> class FAbsTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FAbsTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FDimTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
class FDimTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
using FuncPtr = T (*)(T, T);
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/FMaxTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T> class FMaxTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FMaxTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FMaximumMagNumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FMaximumMagNumTest : public LIBC_NAMESPACE::testing::Test {
class FMaximumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FMaximumMagTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUM_MAGTEST_H

#include "src/__support/FPUtil/BasicOperations.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FMaximumMagTest : public LIBC_NAMESPACE::testing::Test {
class FMaximumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FMaximumNumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMNUMTEST_H

#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FMaximumNumTest : public LIBC_NAMESPACE::testing::Test {
class FMaximumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FMaximumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FMaximumTest : public LIBC_NAMESPACE::testing::Test {
class FMaximumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/FMinTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T> class FMinTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FMinTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FMinimumMagNumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FMinimumMagNumTest : public LIBC_NAMESPACE::testing::Test {
class FMinimumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FMinimumMagTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUM_MAGTEST_H

#include "src/__support/FPUtil/BasicOperations.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FMinimumMagTest : public LIBC_NAMESPACE::testing::Test {
class FMinimumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FMinimumNumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMNUMTEST_H

#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FMinimumNumTest : public LIBC_NAMESPACE::testing::Test {
class FMinimumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FMinimumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FMinimumTest : public LIBC_NAMESPACE::testing::Test {
class FMinimumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/FModTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

Expand All @@ -24,7 +25,8 @@

#define TEST_REGULAR(x, y, expected) TEST_SPECIAL(x, y, expected, false, 0)

template <typename T> class FmodTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/FloorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FLOORTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FLOORTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T> class FloorTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FloorTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FmaTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#define LLVM_LIBC_TEST_SRC_MATH_FMATEST_H

#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
class FmaTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
private:
using Func = T (*)(T, T, T);
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/FrexpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
//===----------------------------------------------------------------------===//

#include "src/__support/FPUtil/BasicOperations.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T> class FrexpTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class FrexpTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FromfpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#ifndef LIBC_TEST_SRC_MATH_SMOKE_FROMFPTEST_H
#define LIBC_TEST_SRC_MATH_SMOKE_FROMFPTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FromfpTestTemplate : public LIBC_NAMESPACE::testing::Test {
class FromfpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/FromfpxTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#ifndef LIBC_TEST_SRC_MATH_SMOKE_FROMFPXTEST_H
#define LIBC_TEST_SRC_MATH_SMOKE_FROMFPXTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class FromfpxTestTemplate : public LIBC_NAMESPACE::testing::Test {
class FromfpxTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/HypotTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
#define LLVM_LIBC_TEST_SRC_MATH_HYPOTTEST_H

#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T>
class HypotTestTemplate : public LIBC_NAMESPACE::testing::Test {
class HypotTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
private:
using Func = T (*)(T, T);
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/ILogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
#include "src/__support/CPP/limits.h" // INT_MAX
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/Test.h"

template <typename OutType, typename InType>
class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<InType>;
using StorageType = typename FPBits::StorageType;

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/LdExpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
#include "src/__support/CPP/limits.h" // INT_MAX
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/NormalFloat.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include <stdint.h>

template <typename T>
class LdExpTestTemplate : public LIBC_NAMESPACE::testing::Test {
class LdExpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using NormalFloat = LIBC_NAMESPACE::fputil::NormalFloat<T>;
using StorageType = typename FPBits::StorageType;
Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/LogbTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
//===----------------------------------------------------------------------===//

#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T> class LogbTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class LogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/ModfTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T> class ModfTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class ModfTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/NextAfterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

Expand All @@ -29,7 +30,7 @@
ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, FE_INEXACT | FE_OVERFLOW)

template <typename T>
class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::Test {
class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using StorageType = typename FPBits::StorageType;

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/NextDownTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class NextDownTestTemplate : public LIBC_NAMESPACE::testing::Test {
class NextDownTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/NextTowardTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

Expand All @@ -30,7 +31,7 @@
ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, FE_INEXACT | FE_OVERFLOW)

template <typename T>
class NextTowardTestTemplate : public LIBC_NAMESPACE::testing::Test {
class NextTowardTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using ToFPBits = LIBC_NAMESPACE::fputil::FPBits<long double>;
using StorageType = typename FPBits::StorageType;
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/NextUpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTUPTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTUPTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class NextUpTestTemplate : public LIBC_NAMESPACE::testing::Test {
class NextUpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/RIntTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

Expand All @@ -22,7 +23,7 @@ static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
FE_TONEAREST};

template <typename T>
class RIntTestTemplate : public LIBC_NAMESPACE::testing::Test {
class RIntTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
typedef T (*RIntFunc)(T);

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/RemQuoTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::Test {
class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using StorageType = typename FPBits::StorageType;

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/RoundEvenTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_ROUNDEVENTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_ROUNDEVENTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T>
class RoundEvenTest : public LIBC_NAMESPACE::testing::Test {
class RoundEvenTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/RoundTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_ROUNDTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_ROUNDTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T> class RoundTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class RoundTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
6 changes: 5 additions & 1 deletion libc/test/src/math/smoke/RoundToIntegerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

Expand All @@ -21,7 +22,8 @@ static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
FE_TONEAREST};

template <typename F, typename I, bool TestModes = false>
class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {
class RoundToIntegerTestTemplate
: public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
typedef I (*RoundToIntegerFunc)(F);

Expand Down Expand Up @@ -61,6 +63,8 @@ class RoundToIntegerTestTemplate : public LIBC_NAMESPACE::testing::Test {

public:
void SetUp() override {
LIBC_NAMESPACE::testing::FEnvSafeTest::SetUp();

if (math_errhandling & MATH_ERREXCEPT) {
// We will disable all exceptions so that the test will not
// crash with SIGFPE. We can still use fetestexcept to check
Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/SqrtTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
//===----------------------------------------------------------------------===//

#include "src/__support/CPP/bit.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T> class SqrtTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class SqrtTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
4 changes: 3 additions & 1 deletion libc/test/src/math/smoke/TruncTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_TRUNCTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_TRUNCTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/math_macros.h"

template <typename T> class TruncTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
class TruncTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/UfromfpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#ifndef LIBC_TEST_SRC_MATH_SMOKE_UFROMFPTEST_H
#define LIBC_TEST_SRC_MATH_SMOKE_UFROMFPTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class UfromfpTestTemplate : public LIBC_NAMESPACE::testing::Test {
class UfromfpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/UfromfpxTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#ifndef LIBC_TEST_SRC_MATH_SMOKE_UFROMFPXTEST_H
#define LIBC_TEST_SRC_MATH_SMOKE_UFROMFPXTEST_H

#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

template <typename T>
class UfromfpxTestTemplate : public LIBC_NAMESPACE::testing::Test {
class UfromfpxTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {

DECLARE_SPECIAL_CONSTANTS(T)

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/nan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

#include "src/__support/FPUtil/FPBits.h"
#include "src/math/nan.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <signal.h>

class LlvmLibcNanTest : public LIBC_NAMESPACE::testing::Test {
class LlvmLibcNanTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
using StorageType = LIBC_NAMESPACE::fputil::FPBits<double>::StorageType;

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/nanf128_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/uint128.h"
#include "src/math/nanf128.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

class LlvmLibcNanf128Test : public LIBC_NAMESPACE::testing::Test {
class LlvmLibcNanf128Test : public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
using FPBits128 = LIBC_NAMESPACE::fputil::FPBits<float128>;
using StorageType = FPBits128::StorageType;
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/nanf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

#include "src/__support/FPUtil/FPBits.h"
#include "src/math/nanf.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <signal.h>

class LlvmLibcNanfTest : public LIBC_NAMESPACE::testing::Test {
class LlvmLibcNanfTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
using StorageType = LIBC_NAMESPACE::fputil::FPBits<float>::StorageType;

Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/math/smoke/nanl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "src/__support/FPUtil/FPBits.h"
#include "src/math/nanl.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include <signal.h>
Expand All @@ -22,7 +23,7 @@
#error "Unknown long double type"
#endif

class LlvmLibcNanlTest : public LIBC_NAMESPACE::testing::Test {
class LlvmLibcNanlTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
public:
using StorageType = LIBC_NAMESPACE::fputil::FPBits<long double>::StorageType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ libc_support_library(
libc_support_library(
name = "fp_test_helpers",
srcs = [
"FEnvSafeTest.cpp",
"FPExceptMatcher.cpp",
"RoundingModeUtils.cpp",
],
hdrs = [
"FEnvSafeTest.h",
"FPExceptMatcher.h",
"FPMatcher.h",
"RoundingModeUtils.h",
Expand All @@ -87,8 +89,8 @@ libc_support_library(
"//libc:__support_fputil_fpbits_str",
"//libc:__support_fputil_rounding_mode",
"//libc:hdr_math_macros",
"//libc:hdr_fenv_macros",
"//libc:types_fenv_t",
"//libc:hdr_fenv_macros",
"//libc:types_fenv_t",
],
)

Expand Down