[libc][NFC] Switch string and errno tests to libc_errno.
authorSiva Chandra Reddy <sivachandra@google.com>
Mon, 13 Mar 2023 22:11:07 +0000 (22:11 +0000)
committerSiva Chandra Reddy <sivachandra@google.com>
Mon, 13 Mar 2023 22:22:00 +0000 (22:22 +0000)
libc/test/src/__support/CMakeLists.txt
libc/test/src/__support/str_to_float_test.cpp
libc/test/src/errno/errno_test.cpp
libc/test/src/string/CMakeLists.txt
libc/test/src/string/strdup_test.cpp

index fa35aa45712ff74be1a7caca9a8611281efa3c2a..a8c55172388823a14a201a36998d6d3dc52d15b7 100644 (file)
@@ -40,6 +40,7 @@ add_libc_unittest(
   DEPENDS
     libc.src.__support.str_to_float
     libc.src.__support.uint128
+    libc.src.errno.errno
 )
 
 add_libc_unittest(
index b5bb3b931a8af8713c29782b27bc375842bc8c43..4ebdb33549ef621bc86df93365f08a9282e3615b 100644 (file)
@@ -9,6 +9,7 @@
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/UInt128.h"
 #include "src/__support/str_to_float.h"
+#include "src/errno/libc_errno.h"
 
 #include "test/UnitTest/Test.h"
 
@@ -78,7 +79,7 @@ public:
     typename __llvm_libc::fputil::FPBits<T>::UIntType actual_output_mantissa =
         0;
     uint32_t actual_output_exp2 = 0;
-    errno = 0;
+    libc_errno = 0;
 
     auto result = __llvm_libc::internal::simple_decimal_conversion<T>(numStart);
 
@@ -250,7 +251,7 @@ TEST(LlvmLibcStrToFloatTest, SimpleDecimalConversionExtraTypes) {
   uint32_t float_output_mantissa = 0;
   uint32_t output_exp2 = 0;
 
-  errno = 0;
+  libc_errno = 0;
   auto float_result = __llvm_libc::internal::simple_decimal_conversion<float>(
       "123456789012345678900");
   float_output_mantissa = float_result.num.mantissa;
@@ -262,7 +263,7 @@ TEST(LlvmLibcStrToFloatTest, SimpleDecimalConversionExtraTypes) {
   uint64_t double_output_mantissa = 0;
   output_exp2 = 0;
 
-  errno = 0;
+  libc_errno = 0;
   auto double_result = __llvm_libc::internal::simple_decimal_conversion<double>(
       "123456789012345678900");
 
index 86a9a88e866859bce4a2e5ff557dbace3bb12533..33185c2bcf6f54957ecd57d35aafff424d00b458 100644 (file)
@@ -6,11 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/errno/llvmlibc_errno.h"
+#include "src/errno/libc_errno.h"
 #include "test/UnitTest/Test.h"
 
 TEST(LlvmLibcErrnoTest, Basic) {
   int test_val = 123;
-  llvmlibc_errno = test_val;
-  ASSERT_EQ(test_val, llvmlibc_errno);
+  libc_errno = test_val;
+  ASSERT_EQ(test_val, libc_errno);
 }
index c9623a330b1c2c44ec2ac6e289f19110f896d5c2..67f49ab3a114feffb0bea8e220fd43c9dd85ff83 100644 (file)
@@ -161,7 +161,6 @@ add_libc_unittest(
   SRCS
     strdup_test.cpp
   DEPENDS
-    libc.include.errno
     libc.include.stdlib
     libc.src.string.strdup
     libc.src.errno.errno
index ffbc55a70fb215c03224722ae9648418e6b533b8..ee46882233dd37aea2c8047cda5d32328c2784ab 100644 (file)
@@ -6,18 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/errno/libc_errno.h"
 #include "src/string/strdup.h"
 #include "test/UnitTest/Test.h"
 
-#include <errno.h>
 #include <stdlib.h>
 
 TEST(LlvmLibcStrDupTest, EmptyString) {
   const char *empty = "";
 
-  errno = 0;
+  libc_errno = 0;
   char *result = __llvm_libc::strdup(empty);
-  ASSERT_EQ(errno, 0);
+  ASSERT_EQ(libc_errno, 0);
 
   ASSERT_NE(result, static_cast<char *>(nullptr));
   ASSERT_NE(empty, const_cast<const char *>(result));
@@ -28,9 +28,9 @@ TEST(LlvmLibcStrDupTest, EmptyString) {
 TEST(LlvmLibcStrDupTest, AnyString) {
   const char *abc = "abc";
 
-  errno = 0;
+  libc_errno = 0;
   char *result = __llvm_libc::strdup(abc);
-  ASSERT_EQ(errno, 0);
+  ASSERT_EQ(libc_errno, 0);
 
   ASSERT_NE(result, static_cast<char *>(nullptr));
   ASSERT_NE(abc, const_cast<const char *>(result));
@@ -39,9 +39,9 @@ TEST(LlvmLibcStrDupTest, AnyString) {
 }
 
 TEST(LlvmLibcStrDupTest, NullPtr) {
-  errno = 0;
+  libc_errno = 0;
   char *result = __llvm_libc::strdup(nullptr);
-  ASSERT_EQ(errno, 0);
+  ASSERT_EQ(libc_errno, 0);
 
   ASSERT_EQ(result, static_cast<char *>(nullptr));
 }