aboutsummaryrefslogtreecommitdiff
path: root/libc/test/UnitTest
diff options
context:
space:
mode:
Diffstat (limited to 'libc/test/UnitTest')
-rw-r--r--libc/test/UnitTest/CMakeLists.txt1
-rw-r--r--libc/test/UnitTest/FEnvSafeTest.cpp6
-rw-r--r--libc/test/UnitTest/FEnvSafeTest.h3
-rw-r--r--libc/test/UnitTest/FPMatcher.h11
4 files changed, 19 insertions, 2 deletions
diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt
index d92ab6f..f1a83fc 100644
--- a/libc/test/UnitTest/CMakeLists.txt
+++ b/libc/test/UnitTest/CMakeLists.txt
@@ -125,6 +125,7 @@ add_unittest_framework_library(
RoundingModeUtils.h
DEPENDS
LibcTest
+ libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.string_utils
libc.src.__support.CPP.array
libc.src.__support.FPUtil.fp_bits
diff --git a/libc/test/UnitTest/FEnvSafeTest.cpp b/libc/test/UnitTest/FEnvSafeTest.cpp
index 168b1d4..f644569 100644
--- a/libc/test/UnitTest/FEnvSafeTest.cpp
+++ b/libc/test/UnitTest/FEnvSafeTest.cpp
@@ -9,8 +9,10 @@
#include "FEnvSafeTest.h"
#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"
+#include "test/UnitTest/ErrnoCheckingTest.h"
namespace LIBC_NAMESPACE_DECL {
namespace testing {
@@ -25,6 +27,10 @@ void FEnvSafeTest::TearDown() {
if (!should_be_unchanged) {
restore_fenv();
}
+ // TODO (PR 135320): Remove this override once all FEnvSafeTest instances are
+ // updated to validate or ignore errno.
+ libc_errno = 0;
+ ErrnoCheckingTest::TearDown();
}
void FEnvSafeTest::get_fenv(fenv_t &fenv) {
diff --git a/libc/test/UnitTest/FEnvSafeTest.h b/libc/test/UnitTest/FEnvSafeTest.h
index a3c5e62..1e10629 100644
--- a/libc/test/UnitTest/FEnvSafeTest.h
+++ b/libc/test/UnitTest/FEnvSafeTest.h
@@ -12,6 +12,7 @@
#include "hdr/types/fenv_t.h"
#include "src/__support/CPP/utility.h"
#include "src/__support/macros/config.h"
+#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/Test.h"
namespace LIBC_NAMESPACE_DECL {
@@ -20,7 +21,7 @@ namespace testing {
// This provides a test fixture (or base class for other test fixtures) that
// asserts that each test does not leave the FPU state represented by `fenv_t`
// (aka `FPState`) perturbed from its initial state.
-class FEnvSafeTest : public Test {
+class FEnvSafeTest : public ErrnoCheckingTest {
public:
void TearDown() override;
diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h
index da15cf2..592cd1b 100644
--- a/libc/test/UnitTest/FPMatcher.h
+++ b/libc/test/UnitTest/FPMatcher.h
@@ -14,8 +14,10 @@
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/fpbits_str.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"
+#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/RoundingModeUtils.h"
#include "test/UnitTest/StringUtils.h"
#include "test/UnitTest/Test.h"
@@ -166,7 +168,7 @@ CFPMatcher<T, C> getMatcherComplex(T expectedValue) {
return CFPMatcher<T, C>(expectedValue);
}
-template <typename T> struct FPTest : public Test {
+template <typename T> struct FPTest : public ErrnoCheckingTest {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using StorageType = typename FPBits::StorageType;
static constexpr StorageType STORAGE_MAX =
@@ -191,6 +193,13 @@ template <typename T> struct FPTest : public Test {
fputil::testing::RoundingMode::Downward,
fputil::testing::RoundingMode::TowardZero,
};
+
+ void TearDown() override {
+ // TODO (PR 135320): Remove this override once all FPTest instances are
+ // updated to validate or ignore errno.
+ libc_errno = 0;
+ ErrnoCheckingTest::TearDown();
+ }
};
// Add facility to test Flush-Denormal-To-Zero (FTZ) and Denormal-As-Zero (DAZ)