Skip to content

Commit 807ee5d

Browse files
authored
[libc] Clean up errno header usage in all remaining math/smoke tests. (#157565)
This is a follow-up to #157517, which fixes the remaining math/smoke tests, and changes them to only include `hdr/errno_macros.h`, as the tests just need the errno values to pass into `EXPECT_MATH_ERRO` macro. A couple non-mechanical changes include: * slightly better test coverage for some exp/log tests -- that actually validates that errno is set to `EDOM` or `ERANGE` for certain inputs; * explicit inclusion of `src/__support/libc_errno.h` in RoundToIntegerTest template, which still needs to be fixed. With this change there's a single libc_errno usage left: ``` $ grep -lrnH "libc_errno.h" test/src/math/smoke test/src/math/smoke/RoundToIntegerTest.h ```
1 parent 7123463 commit 807ee5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+172
-227
lines changed

libc/test/src/math/smoke/CMakeLists.txt

Lines changed: 54 additions & 59 deletions
Large diffs are not rendered by default.

libc/test/src/math/smoke/FModTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H
1010
#define LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H
1111

12+
#include "hdr/errno_macros.h"
1213
#include "src/__support/FPUtil/FEnvImpl.h"
13-
#include "src/__support/libc_errno.h"
1414
#include "test/UnitTest/FEnvSafeTest.h"
1515
#include "test/UnitTest/FPMatcher.h"
1616
#include "test/UnitTest/Test.h"

libc/test/src/math/smoke/RoundToIntegerTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "src/__support/CPP/algorithm.h"
1313
#include "src/__support/FPUtil/FEnvImpl.h"
1414
#include "src/__support/FPUtil/FPBits.h"
15+
#include "src/__support/libc_errno.h"
1516
#include "test/UnitTest/FEnvSafeTest.h"
1617
#include "test/UnitTest/FPMatcher.h"
1718
#include "test/UnitTest/Test.h"

libc/test/src/math/smoke/atan2f_test.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88

99
#include "hdr/math_macros.h"
1010
#include "src/__support/FPUtil/FPBits.h"
11-
#include "src/__support/libc_errno.h"
1211
#include "src/math/atan2f.h"
1312
#include "test/UnitTest/FPMatcher.h"
1413
#include "test/UnitTest/Test.h"
1514

1615
using LlvmLibcAtan2fTest = LIBC_NAMESPACE::testing::FPTest<float>;
1716

1817
TEST_F(LlvmLibcAtan2fTest, SpecialNumbers) {
19-
libc_errno = 0;
20-
2118
EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atan2f(sNaN, sNaN),
2219
FE_INVALID);
2320
EXPECT_MATH_ERRNO(0);

libc/test/src/math/smoke/atanf16_test.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/libc_errno.h"
109
#include "src/math/atanf16.h"
1110
#include "test/UnitTest/FPMatcher.h"
1211
#include "test/UnitTest/Test.h"
1312

1413
using LlvmLibcAtanf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
1514

1615
TEST_F(LlvmLibcAtanf16Test, SpecialNumbers) {
17-
libc_errno = 0;
1816
EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::atanf16(aNaN));
1917
EXPECT_MATH_ERRNO(0);
2018

libc/test/src/math/smoke/atanf_test.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "hdr/math_macros.h"
1010
#include "src/__support/FPUtil/FPBits.h"
11-
#include "src/__support/libc_errno.h"
1211
#include "src/math/atanf.h"
1312
#include "test/UnitTest/FPMatcher.h"
1413
#include "test/UnitTest/Test.h"
@@ -18,7 +17,6 @@
1817
using LlvmLibcAtanfTest = LIBC_NAMESPACE::testing::FPTest<float>;
1918

2019
TEST_F(LlvmLibcAtanfTest, SpecialNumbers) {
21-
libc_errno = 0;
2220
EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atanf(sNaN), FE_INVALID);
2321
EXPECT_MATH_ERRNO(0);
2422

libc/test/src/math/smoke/atanhf16_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "hdr/errno_macros.h"
910
#include "src/__support/FPUtil/cast.h"
10-
#include "src/__support/libc_errno.h"
1111
#include "src/math/atanhf16.h"
1212
#include "test/UnitTest/FPMatcher.h"
1313
#include "test/UnitTest/Test.h"
1414

1515
using LlvmLibcAtanhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
1616

1717
TEST_F(LlvmLibcAtanhf16Test, SpecialNumbers) {
18-
libc_errno = 0;
1918
EXPECT_FP_EQ_WITH_EXCEPTION_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf16(sNaN),
2019
FE_INVALID);
2120
EXPECT_MATH_ERRNO(0);

libc/test/src/math/smoke/atanhf_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "hdr/errno_macros.h"
910
#include "hdr/math_macros.h"
1011
#include "src/__support/FPUtil/FPBits.h"
11-
#include "src/__support/libc_errno.h"
1212
#include "src/math/atanhf.h"
1313
#include "test/UnitTest/FPMatcher.h"
1414
#include "test/UnitTest/Test.h"
@@ -20,7 +20,6 @@ using LIBC_NAMESPACE::Sign;
2020
using LlvmLibcAtanhfTest = LIBC_NAMESPACE::testing::FPTest<float>;
2121

2222
TEST_F(LlvmLibcAtanhfTest, SpecialNumbers) {
23-
libc_errno = 0;
2423
EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atanhf(sNaN), FE_INVALID);
2524
EXPECT_MATH_ERRNO(0);
2625
// TODO: Strengthen errno,exception checks and remove these assert macros

libc/test/src/math/smoke/atanpif16_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/libc_errno.h"
109
#include "src/math/atanpif16.h"
1110
#include "test/UnitTest/FPMatcher.h"
1211

libc/test/src/math/smoke/cosf16_test.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/libc_errno.h"
9+
#include "hdr/errno_macros.h"
1010
#include "src/math/cosf16.h"
1111
#include "test/UnitTest/FPMatcher.h"
1212
#include "test/UnitTest/Test.h"
1313

1414
using LlvmLibcCosf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
1515

1616
TEST_F(LlvmLibcCosf16Test, SpecialNumbers) {
17-
libc_errno = 0;
18-
1917
EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cosf16(sNaN), FE_INVALID);
2018
EXPECT_MATH_ERRNO(0);
2119

0 commit comments

Comments
 (0)