Skip to content

Commit 23ffb38

Browse files
vonosmastomtor
authored andcommitted
[libc] Reduce direct use of errno in src/stdlib and src/__support tests. (llvm#143767)
* Get rid of libc_errno assignments in str_to_* __support tests, since those API have been migrated to return error in a struct instead. * Migrate tests for atof and to strto* functions from <stdlib.h> and for strdup from <string.h> to use ErrnoCheckingTest harness.
1 parent 615ddb0 commit 23ffb38

13 files changed

+24
-86
lines changed

libc/test/src/__support/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ add_libc_test(
127127
libc.src.__support.integer_literals
128128
libc.src.__support.str_to_float
129129
libc.src.__support.uint128
130-
libc.src.errno.errno
131130
)
132131

133132

@@ -140,7 +139,6 @@ add_libc_test(
140139
DEPENDS
141140
libc.src.__support.integer_literals
142141
libc.src.__support.str_to_integer
143-
libc.src.errno.errno
144142
)
145143

146144
add_libc_test(

libc/test/src/__support/str_to_double_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ TEST(LlvmLibcStrToDblTest, SimpleDecimalConversionExtraTypes) {
9999
uint64_t double_output_mantissa = 0;
100100
uint32_t output_exp2 = 0;
101101

102-
LIBC_NAMESPACE::libc_errno = 0;
103102
auto double_result =
104103
internal::simple_decimal_conversion<double>("123456789012345678900");
105104

libc/test/src/__support/str_to_float_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ TEST(LlvmLibcStrToFltTest, SimpleDecimalConversionExtraTypes) {
5555
uint32_t float_output_mantissa = 0;
5656
uint32_t output_exp2 = 0;
5757

58-
LIBC_NAMESPACE::libc_errno = 0;
5958
auto float_result =
6059
internal::simple_decimal_conversion<float>("123456789012345678900");
6160
float_output_mantissa = float_result.num.mantissa;

libc/test/src/__support/str_to_fp_test.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "src/__support/macros/config.h"
1111
#include "src/__support/str_to_float.h"
1212
#include "src/__support/uint128.h"
13-
#include "src/errno/libc_errno.h"
1413

1514
#include "test/UnitTest/Test.h"
1615

@@ -67,7 +66,6 @@ template <typename T> struct LlvmLibcStrToFloatTest : public testing::Test {
6766
const int expectedErrno = 0) {
6867
StorageType actual_output_mantissa = 0;
6968
uint32_t actual_output_exp2 = 0;
70-
LIBC_NAMESPACE::libc_errno = 0;
7169

7270
auto result = internal::simple_decimal_conversion<T>(numStart);
7371

libc/test/src/__support/str_to_integer_test.cpp

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

99
#include "src/__support/str_to_integer.h"
10-
#include "src/errno/libc_errno.h"
1110
#include <stddef.h>
1211

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

libc/test/src/stdlib/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_libc_test(
99
DEPENDS
1010
libc.src.errno.errno
1111
libc.src.stdlib.atof
12+
libc.test.UnitTest.ErrnoCheckingTest
1213
)
1314

1415
add_header_library(
@@ -64,6 +65,7 @@ add_fp_unittest(
6465
libc.src.errno.errno
6566
libc.src.stdlib.strtod
6667
libc.src.__support.FPUtil.fenv_impl
68+
libc.test.UnitTest.ErrnoCheckingTest
6769
)
6870

6971
add_fp_unittest(
@@ -76,6 +78,7 @@ add_fp_unittest(
7678
libc.src.errno.errno
7779
libc.src.stdlib.strtof
7880
libc.src.__support.FPUtil.fenv_impl
81+
libc.test.UnitTest.ErrnoCheckingTest
7982
)
8083

8184
add_header_library(
@@ -86,6 +89,7 @@ add_header_library(
8689
libc.src.__support.CPP.limits
8790
libc.src.__support.CPP.type_traits
8891
libc.src.errno.errno
92+
libc.test.UnitTest.ErrnoCheckingTest
8993
)
9094

9195
add_libc_test(
@@ -133,6 +137,7 @@ add_libc_test(
133137
libc.src.errno.errno
134138
libc.src.__support.uint128
135139
libc.src.stdlib.strtold
140+
libc.test.UnitTest.ErrnoCheckingTest
136141
)
137142

138143
add_libc_test(

0 commit comments

Comments
 (0)