[libc-commits] [libc] [libc][test] make `str_to_float_comparison_test` independent of C++ headers. (PR #133978)

Muhammad Bassiouni via libc-commits libc-commits at lists.llvm.org
Fri Apr 4 18:29:52 PDT 2025


https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/133978

>From b6456185a69e136f4ff13fef8605db294c5b9f44 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Tue, 1 Apr 2025 22:12:56 +0200
Subject: [PATCH 01/15] [libc][test] make test independent of C++ headers

---
 .../str_to_float_comparison_test.cpp          | 65 +++++++++----------
 1 file changed, 32 insertions(+), 33 deletions(-)

diff --git a/libc/test/src/__support/str_to_float_comparison_test.cpp b/libc/test/src/__support/str_to_float_comparison_test.cpp
index 61bfc3cd0903a..81193f4723624 100644
--- a/libc/test/src/__support/str_to_float_comparison_test.cpp
+++ b/libc/test/src/__support/str_to_float_comparison_test.cpp
@@ -8,14 +8,11 @@
 
 // #include "src/__support/str_float_conv_utils.h"
 
-#include <stdlib.h> // For string to float functions
-
 // #include "src/__support/FPUtil/FPBits.h"
 
-#include <cstdint>
-#include <fstream>
-#include <iostream>
-#include <string>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 // The intent of this test is to read in files in the format used in this test
 // dataset: https://github.com/nigeltao/parse-number-fxx-test-data
@@ -59,16 +56,17 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
   int32_t curFails = 0;    // Only counts actual failures, not bitdiffs.
   int32_t curBitDiffs = 0; // A bitdiff is when the expected result and actual
                            // result are off by +/- 1 bit.
-  std::string line;
-  std::string num;
+  char line[100];
+  char num[100];
 
-  std::ifstream fileStream(inputFileName, std::ifstream::in);
+  auto *fileHandle = fopen(inputFileName, "r");
 
-  if (!fileStream.is_open()) {
-    std::cout << "file '" << inputFileName << "' failed to open. Exiting.\n";
+  if (!fileHandle) {
+    printf("file '%s' failed to open. Exiting.\n", inputFileName);
     return 1;
   }
-  while (getline(fileStream, line)) {
+
+  while (fgets(line, sizeof(line), fileHandle)) {
     if (line[0] == '#') {
       continue;
     }
@@ -76,13 +74,13 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
     uint32_t expectedFloatRaw;
     uint64_t expectedDoubleRaw;
 
-    expectedFloatRaw = fastHexToU32(line.c_str() + 5);
-    expectedDoubleRaw = fastHexToU64(line.c_str() + 14);
-    num = line.substr(31);
+    expectedFloatRaw = fastHexToU32(line + 5);
+    expectedDoubleRaw = fastHexToU64(line + 14);
+    sscanf(line + 31, "%s", num);
 
-    float floatResult = strtof(num.c_str(), nullptr);
+    float floatResult = strtof(num, nullptr);
 
-    double doubleResult = strtod(num.c_str(), nullptr);
+    double doubleResult = strtod(num, nullptr);
 
     uint32_t floatRaw = *(uint32_t *)(&floatResult);
 
@@ -101,9 +99,8 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
         curFails++;
       }
       if (curFails + curBitDiffs < 10) {
-        std::cout << "Float fail for '" << num << "'. Expected " << std::hex
-                  << expectedFloatRaw << " but got " << floatRaw << "\n"
-                  << std::dec;
+        printf("Float fail for '%s'. Expected %x but got %x\n", num,
+               expectedFloatRaw, floatRaw);
       }
     }
 
@@ -120,14 +117,13 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
         curFails++;
       }
       if (curFails + curBitDiffs < 10) {
-        std::cout << "Double fail for '" << num << "'. Expected " << std::hex
-                  << expectedDoubleRaw << " but got " << doubleRaw << "\n"
-                  << std::dec;
+        printf("Double fail for '%s'. Expected %lx but got %lx\n", num,
+               expectedDoubleRaw, doubleRaw);
       }
     }
   }
 
-  fileStream.close();
+  fclose(fileHandle);
 
   *totalBitDiffs += curBitDiffs;
   *totalFails += curFails;
@@ -151,7 +147,7 @@ int main(int argc, char *argv[]) {
 
   int total = 0;
   for (int i = 1; i < argc; i++) {
-    std::cout << "Starting file " << argv[i] << "\n";
+    printf("Starting file %s\n", argv[i]);
     int curResult =
         checkFile(argv[i], &fails, &bitdiffs, detailedBitDiffs, &total);
     if (curResult == 1) {
@@ -161,13 +157,16 @@ int main(int argc, char *argv[]) {
       result = 2;
     }
   }
-  std::cout << "Results:\n"
-            << "Total significant failed conversions: " << fails << "\n"
-            << "Total conversions off by +/- 1 bit: " << bitdiffs << "\n"
-            << "\t" << detailedBitDiffs[0] << "\tfloat low\n"
-            << "\t" << detailedBitDiffs[1] << "\tfloat high\n"
-            << "\t" << detailedBitDiffs[2] << "\tdouble low\n"
-            << "\t" << detailedBitDiffs[3] << "\tdouble high\n"
-            << "Total lines: " << total << "\n";
+  printf("Results:\n"
+         "Total significant failed conversions: %d\n"
+         "Total conversions off by +/- 1 bit: %d\n"
+         "\t%d\tfloat low\n"
+         "\t%d\tfloat high\n"
+         "\t%d\tdouble low\n"
+         "\t%d\tdouble high\n"
+         "Total lines: %d\n",
+         fails, bitdiffs, detailedBitDiffs[0], detailedBitDiffs[1],
+         detailedBitDiffs[2], detailedBitDiffs[3], total);
+
   return result;
 }

>From 70ecf0174e2ded8184c63c856a62d73d35fc596f Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Wed, 2 Apr 2025 00:18:09 +0200
Subject: [PATCH 02/15] remove executable and convert to unit test

---
 libc/test/src/__support/CMakeLists.txt        | 37 ++++-----
 .../str_to_float_comparison_test.cpp          | 81 +++++++++----------
 2 files changed, 54 insertions(+), 64 deletions(-)

diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index d056969034d69..6513e534607b9 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -249,31 +249,22 @@ add_libc_test(
     libc.src.__support.memory_size
 )
 
-# FIXME: We shouldn't have regular executables created because we could be
-#        cross-compiling the tests and running through an emulator.
 if(NOT LIBC_TARGET_OS_IS_GPU)
-  add_executable(
-    libc_str_to_float_comparison_test
-    str_to_float_comparison_test.cpp
-  )
-
-  target_link_libraries(libc_str_to_float_comparison_test
-    PRIVATE
-      "${LIBC_TARGET}"
-  )
-
-  add_executable(
-    libc_system_str_to_float_comparison_test
-    str_to_float_comparison_test.cpp
+  add_libc_test(
+    str_to_float_comparison_test
+    SUITE
+      libc-support-tests
+    SRCS
+      str_to_float_comparison_test.cpp
+    DEPENDS
+      libc.src.stdio.printf
+      libc.src.stdio.fopen
+      libc.src.stdio.fclose
+      libc.src.stdio.fgets
+      libc.src.stdlib.strtof
+      libc.src.stdlib.strtod
+    NO_RUN_POSTBUILD
   )
-
-  set(float_test_file ${CMAKE_CURRENT_SOURCE_DIR}/str_to_float_comparison_data.txt)
-
-  add_custom_command(TARGET libc_str_to_float_comparison_test
-                     POST_BUILD
-                     COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:libc_str_to_float_comparison_test> ${float_test_file}
-                     COMMENT "Test the strtof and strtod implementations against precomputed results."
-                     VERBATIM)
 endif()
 
 add_subdirectory(CPP)
diff --git a/libc/test/src/__support/str_to_float_comparison_test.cpp b/libc/test/src/__support/str_to_float_comparison_test.cpp
index 81193f4723624..5f3100d3b5946 100644
--- a/libc/test/src/__support/str_to_float_comparison_test.cpp
+++ b/libc/test/src/__support/str_to_float_comparison_test.cpp
@@ -6,13 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-// #include "src/__support/str_float_conv_utils.h"
-
-// #include "src/__support/FPUtil/FPBits.h"
-
+#include "src/stdio/fclose.h"
+#include "src/stdio/fgets.h"
+#include "src/stdio/fopen.h"
+#include "src/stdio/printf.h"
+#include "src/stdlib/strtod.h"
+#include "src/stdlib/strtof.h"
+#include "test/UnitTest/Test.h"
 #include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
 
 // The intent of this test is to read in files in the format used in this test
 // dataset: https://github.com/nigeltao/parse-number-fxx-test-data
@@ -56,17 +57,18 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
   int32_t curFails = 0;    // Only counts actual failures, not bitdiffs.
   int32_t curBitDiffs = 0; // A bitdiff is when the expected result and actual
                            // result are off by +/- 1 bit.
-  char line[100];
-  char num[100];
+  char *line = nullptr;
+  char *num = nullptr;
 
-  auto *fileHandle = fopen(inputFileName, "r");
+  auto *fileHandle = LIBC_NAMESPACE::fopen(inputFileName, "r");
 
   if (!fileHandle) {
-    printf("file '%s' failed to open. Exiting.\n", inputFileName);
+    LIBC_NAMESPACE::printf("file '%s' failed to open. Exiting.\n",
+                           inputFileName);
     return 1;
   }
 
-  while (fgets(line, sizeof(line), fileHandle)) {
+  while (LIBC_NAMESPACE::fgets(line, 100, fileHandle)) {
     if (line[0] == '#') {
       continue;
     }
@@ -76,11 +78,11 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
 
     expectedFloatRaw = fastHexToU32(line + 5);
     expectedDoubleRaw = fastHexToU64(line + 14);
-    sscanf(line + 31, "%s", num);
+    num = line + 31;
 
-    float floatResult = strtof(num, nullptr);
+    float floatResult = LIBC_NAMESPACE::strtof(num, nullptr);
 
-    double doubleResult = strtod(num, nullptr);
+    double doubleResult = LIBC_NAMESPACE::strtod(num, nullptr);
 
     uint32_t floatRaw = *(uint32_t *)(&floatResult);
 
@@ -99,8 +101,8 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
         curFails++;
       }
       if (curFails + curBitDiffs < 10) {
-        printf("Float fail for '%s'. Expected %x but got %x\n", num,
-               expectedFloatRaw, floatRaw);
+        LIBC_NAMESPACE::printf("Float fail for '%s'. Expected %x but got %x\n",
+                               num, expectedFloatRaw, floatRaw);
       }
     }
 
@@ -117,13 +119,14 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
         curFails++;
       }
       if (curFails + curBitDiffs < 10) {
-        printf("Double fail for '%s'. Expected %lx but got %lx\n", num,
-               expectedDoubleRaw, doubleRaw);
+        LIBC_NAMESPACE::printf(
+            "Double fail for '%s'. Expected %lx but got %lx\n", num,
+            expectedDoubleRaw, doubleRaw);
       }
     }
   }
 
-  fclose(fileHandle);
+  LIBC_NAMESPACE::fclose(fileHandle);
 
   *totalBitDiffs += curBitDiffs;
   *totalFails += curFails;
@@ -134,7 +137,7 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
   return 0;
 }
 
-int main(int argc, char *argv[]) {
+TEST(LlvmLibcStrToFloatComparisonTest, CheckFile) {
   int result = 0;
   int fails = 0;
 
@@ -146,27 +149,23 @@ int main(int argc, char *argv[]) {
   int detailedBitDiffs[4] = {0, 0, 0, 0};
 
   int total = 0;
-  for (int i = 1; i < argc; i++) {
-    printf("Starting file %s\n", argv[i]);
-    int curResult =
-        checkFile(argv[i], &fails, &bitdiffs, detailedBitDiffs, &total);
-    if (curResult == 1) {
-      result = 1;
-      break;
-    } else if (curResult == 2) {
-      result = 2;
-    }
+
+  char filename[] = "str_to_float_comparison_data.txt";
+  LIBC_NAMESPACE::printf("Starting file %s\n", filename);
+  int curResult =
+      checkFile(filename, &fails, &bitdiffs, detailedBitDiffs, &total);
+  if (curResult == 1) {
+    result = 1;
+  } else if (curResult == 2) {
+    result = 2;
   }
-  printf("Results:\n"
-         "Total significant failed conversions: %d\n"
-         "Total conversions off by +/- 1 bit: %d\n"
-         "\t%d\tfloat low\n"
-         "\t%d\tfloat high\n"
-         "\t%d\tdouble low\n"
-         "\t%d\tdouble high\n"
-         "Total lines: %d\n",
-         fails, bitdiffs, detailedBitDiffs[0], detailedBitDiffs[1],
-         detailedBitDiffs[2], detailedBitDiffs[3], total);
 
-  return result;
+  EXPECT_EQ(result, 0);
+  EXPECT_EQ(fails, 0);
+  EXPECT_EQ(bitdiffs, 0);
+  EXPECT_EQ(detailedBitDiffs[0], 0);
+  EXPECT_EQ(detailedBitDiffs[1], 0);
+  EXPECT_EQ(detailedBitDiffs[2], 0);
+  EXPECT_EQ(detailedBitDiffs[3], 0);
+  EXPECT_EQ(total, 0);
 }

>From 6eb6fae4bbfba01cac34eac7398415ac630612e2 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Wed, 2 Apr 2025 05:04:04 +0200
Subject: [PATCH 03/15] make test support more than one test file

---
 libc/test/src/__support/CMakeLists.txt        |  6 ++-
 .../str_to_float_comparison_test.cpp          | 41 +++++++++++--------
 2 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 6513e534607b9..fff371bd9da50 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -254,6 +254,8 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
     str_to_float_comparison_test
     SUITE
       libc-support-tests
+    NO_RUN_POSTBUILD
+    ENV "FILES=${CMAKE_CURRENT_SOURCE_DIR}/str_to_float_comparison_data.txt"
     SRCS
       str_to_float_comparison_test.cpp
     DEPENDS
@@ -263,7 +265,9 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
       libc.src.stdio.fgets
       libc.src.stdlib.strtof
       libc.src.stdlib.strtod
-    NO_RUN_POSTBUILD
+      libc.src.stdlib.getenv
+      libc.src.string.strtok
+      libc.src.__support.CPP.bit
   )
 endif()
 
diff --git a/libc/test/src/__support/str_to_float_comparison_test.cpp b/libc/test/src/__support/str_to_float_comparison_test.cpp
index 5f3100d3b5946..f7d47db4c518c 100644
--- a/libc/test/src/__support/str_to_float_comparison_test.cpp
+++ b/libc/test/src/__support/str_to_float_comparison_test.cpp
@@ -6,12 +6,15 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/CPP/bit.h"
 #include "src/stdio/fclose.h"
 #include "src/stdio/fgets.h"
 #include "src/stdio/fopen.h"
 #include "src/stdio/printf.h"
+#include "src/stdlib/getenv.h"
 #include "src/stdlib/strtod.h"
 #include "src/stdlib/strtof.h"
+#include "src/string/strtok.h"
 #include "test/UnitTest/Test.h"
 #include <stdint.h>
 
@@ -57,8 +60,8 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
   int32_t curFails = 0;    // Only counts actual failures, not bitdiffs.
   int32_t curBitDiffs = 0; // A bitdiff is when the expected result and actual
                            // result are off by +/- 1 bit.
-  char *line = nullptr;
-  char *num = nullptr;
+  char line[100];
+  char *num;
 
   auto *fileHandle = LIBC_NAMESPACE::fopen(inputFileName, "r");
 
@@ -68,7 +71,7 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
     return 1;
   }
 
-  while (LIBC_NAMESPACE::fgets(line, 100, fileHandle)) {
+  while (LIBC_NAMESPACE::fgets(line, sizeof(line), fileHandle)) {
     if (line[0] == '#') {
       continue;
     }
@@ -84,9 +87,9 @@ int checkFile(char *inputFileName, int *totalFails, int *totalBitDiffs,
 
     double doubleResult = LIBC_NAMESPACE::strtod(num, nullptr);
 
-    uint32_t floatRaw = *(uint32_t *)(&floatResult);
+    uint32_t floatRaw = LIBC_NAMESPACE::cpp::bit_cast<uint32_t>(floatResult);
 
-    uint64_t doubleRaw = *(uint64_t *)(&doubleResult);
+    uint64_t doubleRaw = LIBC_NAMESPACE::cpp::bit_cast<uint64_t>(doubleResult);
 
     if (!(expectedFloatRaw == floatRaw)) {
       if (expectedFloatRaw == floatRaw + 1 ||
@@ -150,22 +153,24 @@ TEST(LlvmLibcStrToFloatComparisonTest, CheckFile) {
 
   int total = 0;
 
-  char filename[] = "str_to_float_comparison_data.txt";
-  LIBC_NAMESPACE::printf("Starting file %s\n", filename);
-  int curResult =
-      checkFile(filename, &fails, &bitdiffs, detailedBitDiffs, &total);
-  if (curResult == 1) {
-    result = 1;
-  } else if (curResult == 2) {
-    result = 2;
+  char *files = LIBC_NAMESPACE::getenv("FILES");
+  for (char *file = LIBC_NAMESPACE::strtok(files, ","); file != nullptr;
+       file = LIBC_NAMESPACE::strtok(nullptr, ",")) {
+    int curResult =
+        checkFile(file, &fails, &bitdiffs, detailedBitDiffs, &total);
+    if (curResult == 1) {
+      result = 1;
+    } else if (curResult == 2) {
+      result = 2;
+    }
   }
 
   EXPECT_EQ(result, 0);
   EXPECT_EQ(fails, 0);
   EXPECT_EQ(bitdiffs, 0);
-  EXPECT_EQ(detailedBitDiffs[0], 0);
-  EXPECT_EQ(detailedBitDiffs[1], 0);
-  EXPECT_EQ(detailedBitDiffs[2], 0);
-  EXPECT_EQ(detailedBitDiffs[3], 0);
-  EXPECT_EQ(total, 0);
+  EXPECT_EQ(detailedBitDiffs[0], 0); // float low
+  EXPECT_EQ(detailedBitDiffs[1], 0); // float high
+  EXPECT_EQ(detailedBitDiffs[2], 0); // double low
+  EXPECT_EQ(detailedBitDiffs[3], 0); // double high
+  EXPECT_EQ(total, 6);
 }

>From e0e77cdc94dc43083b1dc559ca3080ec29fee21c Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Wed, 2 Apr 2025 07:10:53 +0200
Subject: [PATCH 04/15] remove unnecessary condition

---
 libc/test/src/__support/CMakeLists.txt | 40 ++++++++++++--------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index fff371bd9da50..685ac9bd40668 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -249,27 +249,25 @@ add_libc_test(
     libc.src.__support.memory_size
 )
 
-if(NOT LIBC_TARGET_OS_IS_GPU)
-  add_libc_test(
-    str_to_float_comparison_test
-    SUITE
-      libc-support-tests
-    NO_RUN_POSTBUILD
-    ENV "FILES=${CMAKE_CURRENT_SOURCE_DIR}/str_to_float_comparison_data.txt"
-    SRCS
-      str_to_float_comparison_test.cpp
-    DEPENDS
-      libc.src.stdio.printf
-      libc.src.stdio.fopen
-      libc.src.stdio.fclose
-      libc.src.stdio.fgets
-      libc.src.stdlib.strtof
-      libc.src.stdlib.strtod
-      libc.src.stdlib.getenv
-      libc.src.string.strtok
-      libc.src.__support.CPP.bit
-  )
-endif()
+add_libc_test(
+  str_to_float_comparison_test
+  SUITE
+    libc-support-tests
+  NO_RUN_POSTBUILD
+  ENV "FILES=${CMAKE_CURRENT_SOURCE_DIR}/str_to_float_comparison_data.txt"
+  SRCS
+    str_to_float_comparison_test.cpp
+  DEPENDS
+    libc.src.stdio.printf
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.fgets
+    libc.src.stdlib.strtof
+    libc.src.stdlib.strtod
+    libc.src.stdlib.getenv
+    libc.src.string.strtok
+    libc.src.__support.CPP.bit
+)
 
 add_subdirectory(CPP)
 add_subdirectory(File)

>From 8154f3f8840d89cc649b0c66d86ff3a455f50c98 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Wed, 2 Apr 2025 07:27:18 +0200
Subject: [PATCH 05/15] add `NO_RUN_POSTBUILD` to hermitic test

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 45a36abd8ce1b..09dddb1a1f6d9 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -642,7 +642,7 @@ function(add_libc_hermetic test_name)
   endif()
   cmake_parse_arguments(
     "HERMETIC_TEST"
-    "IS_GPU_BENCHMARK" # Optional arguments
+    "IS_GPU_BENCHMARK;NO_RUN_POSTBUILD" # Optional arguments
     "SUITE" # Single value arguments
     "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;LOADER_ARGS" # Multi-value arguments
     ${ARGN}
@@ -701,6 +701,7 @@ function(add_libc_hermetic test_name)
   endif()
   list(REMOVE_DUPLICATES link_object_files)
 
+
   # Make a library of all deps
   add_library(
     ${fq_target_name}.__libc__
@@ -713,7 +714,12 @@ function(add_libc_hermetic test_name)
   set_target_properties(${fq_target_name}.__libc__
       PROPERTIES ARCHIVE_OUTPUT_NAME ${fq_target_name}.libc)
 
-  set(fq_build_target_name ${fq_target_name}.__build__)
+  if(HERMETIC_TEST_NO_RUN_POSTBUILD)
+    set(fq_build_target_name ${fq_target_name})
+  else()
+    set(fq_build_target_name ${fq_target_name}.__build__)
+  endif()
+
   add_executable(
     ${fq_build_target_name}
     EXCLUDE_FROM_ALL
@@ -811,6 +817,14 @@ function(add_libc_hermetic test_name)
       SYMBOLIC "TRUE"
   )
 
+  if(NOT HERMETIC_TEST_NO_RUN_POSTBUILD)
+    add_custom_target(
+      ${fq_target_name}
+      COMMAND ${fq_build_target_name}
+      COMMENT "Running hermetic test ${fq_target_name}"
+    )
+  endif()
+
   add_dependencies(${HERMETIC_TEST_SUITE} ${fq_target_name})
   if(NOT ${HERMETIC_TEST_IS_GPU_BENCHMARK})
     # If it is a benchmark, it will already have been added to the

>From bad7c0cf6c8b488a34ee464d3f5f55075571fa76 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Wed, 2 Apr 2025 07:44:01 +0200
Subject: [PATCH 06/15] add `ENV` to unit test

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 31 +++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 09dddb1a1f6d9..86c299c9cd340 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -191,8 +191,11 @@ endfunction(get_object_files_for_test)
 #      SRCS  <list of .cpp files for the test>
 #      HDRS  <list of .h files for the test>
 #      DEPENDS <list of dependencies>
+#      ARGS <list of command line arguments to be passed to the test>
+#      ENV <list of environment variables to set before running the test>
 #      COMPILE_OPTIONS <list of special compile options for this target>
 #      LINK_LIBRARIES <list of linking libraries for this target>
+#      LOADER_ARGS <list of special args to loaders (like the GPU loader)>
 #    )
 function(create_libc_unittest fq_target_name)
   if(NOT LLVM_INCLUDE_TESTS)
@@ -203,7 +206,7 @@ function(create_libc_unittest fq_target_name)
     "LIBC_UNITTEST"
     "NO_RUN_POSTBUILD;C_TEST" # Optional arguments
     "SUITE;CXX_STANDARD" # Single value arguments
-    "SRCS;HDRS;DEPENDS;COMPILE_OPTIONS;LINK_LIBRARIES;FLAGS" # Multi-value arguments
+    "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;LOADER_ARGS;FLAGS" # Multi-value arguments
     ${ARGN}
   )
   if(NOT LIBC_UNITTEST_SRCS)
@@ -316,6 +319,32 @@ function(create_libc_unittest fq_target_name)
 
   target_link_libraries(${fq_build_target_name} PRIVATE ${link_libraries})
 
+  if(TARGET libc.utils.gpu.loader)
+    add_dependencies(${fq_build_target_name} libc.utils.gpu.loader)
+    get_target_property(gpu_loader_exe libc.utils.gpu.loader "EXECUTABLE")
+  endif()
+
+  set(test_cmd ${LIBC_UNITTEST_ENV}
+      $<$<BOOL:${LIBC_TARGET_OS_IS_GPU}>:${gpu_loader_exe}> ${CMAKE_CROSSCOMPILING_EMULATOR} ${LIBC_UNITTEST_LOADER_ARGS}
+      $<TARGET_FILE:${fq_build_target_name}> ${LIBC_UNITTEST_ARGS})
+  add_custom_target(
+    ${fq_target_name}
+    DEPENDS ${fq_target_name}-cmd
+  )
+
+  add_custom_command(
+    OUTPUT ${fq_target_name}-cmd
+    COMMAND ${test_cmd}
+    COMMAND_EXPAND_LISTS
+    COMMENT "Running unit test ${fq_target_name}"
+    ${LIBC_UNIT_TEST_JOB_POOL}
+  )
+
+  set_source_files_properties(${fq_target_name}-cmd
+    PROPERTIES
+      SYMBOLIC "TRUE"
+  )
+
   if(NOT LIBC_UNITTEST_NO_RUN_POSTBUILD)
     add_custom_target(
       ${fq_target_name}

>From a0d1cff3bf96f35f813b50fbc168ec1d4dd6110d Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Wed, 2 Apr 2025 23:18:12 +0200
Subject: [PATCH 07/15] fix target naming collision

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 77 +++++++++-------------
 libc/test/src/__support/CMakeLists.txt     |  4 +-
 2 files changed, 34 insertions(+), 47 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 86c299c9cd340..a1f6b3bdbd022 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -324,32 +324,26 @@ function(create_libc_unittest fq_target_name)
     get_target_property(gpu_loader_exe libc.utils.gpu.loader "EXECUTABLE")
   endif()
 
-  set(test_cmd ${LIBC_UNITTEST_ENV}
-      $<$<BOOL:${LIBC_TARGET_OS_IS_GPU}>:${gpu_loader_exe}> ${CMAKE_CROSSCOMPILING_EMULATOR} ${LIBC_UNITTEST_LOADER_ARGS}
-      $<TARGET_FILE:${fq_build_target_name}> ${LIBC_UNITTEST_ARGS})
-  add_custom_target(
-    ${fq_target_name}
-    DEPENDS ${fq_target_name}-cmd
-  )
-
-  add_custom_command(
-    OUTPUT ${fq_target_name}-cmd
-    COMMAND ${test_cmd}
-    COMMAND_EXPAND_LISTS
-    COMMENT "Running unit test ${fq_target_name}"
-    ${LIBC_UNIT_TEST_JOB_POOL}
-  )
-
-  set_source_files_properties(${fq_target_name}-cmd
-    PROPERTIES
-      SYMBOLIC "TRUE"
-  )
-
   if(NOT LIBC_UNITTEST_NO_RUN_POSTBUILD)
+    set(test_cmd ${LIBC_UNITTEST_ENV}
+        $<$<BOOL:${LIBC_TARGET_OS_IS_GPU}>:${gpu_loader_exe}> ${CMAKE_CROSSCOMPILING_EMULATOR} ${LIBC_UNITTEST_LOADER_ARGS}
+        $<TARGET_FILE:${fq_build_target_name}> ${LIBC_UNITTEST_ARGS})
     add_custom_target(
       ${fq_target_name}
-      COMMAND ${fq_build_target_name}
+      DEPENDS ${fq_target_name}-cmd
+    )
+
+    add_custom_command(
+      OUTPUT ${fq_target_name}-cmd
+      COMMAND ${test_cmd}
+      COMMAND_EXPAND_LISTS
       COMMENT "Running unit test ${fq_target_name}"
+      ${LIBC_UNIT_TEST_JOB_POOL}
+    )
+
+    set_source_files_properties(${fq_target_name}-cmd
+      PROPERTIES
+        SYMBOLIC "TRUE"
     )
   endif()
 
@@ -730,7 +724,6 @@ function(add_libc_hermetic test_name)
   endif()
   list(REMOVE_DUPLICATES link_object_files)
 
-
   # Make a library of all deps
   add_library(
     ${fq_target_name}.__libc__
@@ -825,32 +818,26 @@ function(add_libc_hermetic test_name)
     get_target_property(gpu_loader_exe libc.utils.gpu.loader "EXECUTABLE")
   endif()
 
-  set(test_cmd ${HERMETIC_TEST_ENV}
-      $<$<BOOL:${LIBC_TARGET_OS_IS_GPU}>:${gpu_loader_exe}> ${CMAKE_CROSSCOMPILING_EMULATOR} ${HERMETIC_TEST_LOADER_ARGS}
-      $<TARGET_FILE:${fq_build_target_name}> ${HERMETIC_TEST_ARGS})
-  add_custom_target(
-    ${fq_target_name}
-    DEPENDS ${fq_target_name}-cmd
-  )
-
-  add_custom_command(
-    OUTPUT ${fq_target_name}-cmd
-    COMMAND ${test_cmd}
-    COMMAND_EXPAND_LISTS
-    COMMENT "Running hermetic test ${fq_target_name}"
-    ${LIBC_HERMETIC_TEST_JOB_POOL}
-  )
-
-  set_source_files_properties(${fq_target_name}-cmd
-    PROPERTIES
-      SYMBOLIC "TRUE"
-  )
-
   if(NOT HERMETIC_TEST_NO_RUN_POSTBUILD)
+    set(test_cmd ${HERMETIC_TEST_ENV}
+        $<$<BOOL:${LIBC_TARGET_OS_IS_GPU}>:${gpu_loader_exe}> ${CMAKE_CROSSCOMPILING_EMULATOR} ${HERMETIC_TEST_LOADER_ARGS}
+        $<TARGET_FILE:${fq_build_target_name}> ${HERMETIC_TEST_ARGS})
     add_custom_target(
       ${fq_target_name}
-      COMMAND ${fq_build_target_name}
+      DEPENDS ${fq_target_name}-cmd
+    )
+
+    add_custom_command(
+      OUTPUT ${fq_target_name}-cmd
+      COMMAND ${test_cmd}
+      COMMAND_EXPAND_LISTS
       COMMENT "Running hermetic test ${fq_target_name}"
+      ${LIBC_HERMETIC_TEST_JOB_POOL}
+    )
+
+    set_source_files_properties(${fq_target_name}-cmd
+      PROPERTIES
+        SYMBOLIC "TRUE"
     )
   endif()
 
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 685ac9bd40668..097c29af50f77 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -251,10 +251,9 @@ add_libc_test(
 
 add_libc_test(
   str_to_float_comparison_test
+  NO_RUN_POSTBUILD
   SUITE
     libc-support-tests
-  NO_RUN_POSTBUILD
-  ENV "FILES=${CMAKE_CURRENT_SOURCE_DIR}/str_to_float_comparison_data.txt"
   SRCS
     str_to_float_comparison_test.cpp
   DEPENDS
@@ -267,6 +266,7 @@ add_libc_test(
     libc.src.stdlib.getenv
     libc.src.string.strtok
     libc.src.__support.CPP.bit
+  ENV "FILES=${CMAKE_CURRENT_SOURCE_DIR}/str_to_float_comparison_data.txt"
 )
 
 add_subdirectory(CPP)

>From 81b9a9c32f69f238ef8fa791ff80b1961d166826 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Wed, 2 Apr 2025 23:45:29 +0200
Subject: [PATCH 08/15] fix argument name

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index bd7e90d1e6fac..c3a684541a000 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -665,7 +665,7 @@ function(add_libc_hermetic test_name)
   endif()
   cmake_parse_arguments(
     "HERMETIC_TEST"
-    "IS_GPU_BENCHMARK;NO_RUNPOSTBUILD" # Optional arguments
+    "IS_GPU_BENCHMARK;NO_RUN_POSTBUILD" # Optional arguments
     "SUITE;CXX_STANDARD" # Single value arguments
     "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;LOADER_ARGS" # Multi-value arguments
     ${ARGN}

>From 95d43fbe222d42c23b4070848780434ce2458b9d Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Wed, 2 Apr 2025 23:48:10 +0200
Subject: [PATCH 09/15] move `ENV` above `DEPENDS`

---
 libc/test/src/__support/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 097c29af50f77..03f6f896150a6 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -256,6 +256,7 @@ add_libc_test(
     libc-support-tests
   SRCS
     str_to_float_comparison_test.cpp
+  ENV "FILES=${CMAKE_CURRENT_SOURCE_DIR}/str_to_float_comparison_data.txt"
   DEPENDS
     libc.src.stdio.printf
     libc.src.stdio.fopen
@@ -266,7 +267,6 @@ add_libc_test(
     libc.src.stdlib.getenv
     libc.src.string.strtok
     libc.src.__support.CPP.bit
-  ENV "FILES=${CMAKE_CURRENT_SOURCE_DIR}/str_to_float_comparison_data.txt"
 )
 
 add_subdirectory(CPP)

>From 10ddac3ab80a4694d5df1cc50b801eb1bb9e7be9 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Wed, 2 Apr 2025 23:56:46 +0200
Subject: [PATCH 10/15] remove GPU configs from unit test

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index c3a684541a000..4e99e048164dc 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -191,11 +191,9 @@ endfunction(get_object_files_for_test)
 #      SRCS  <list of .cpp files for the test>
 #      HDRS  <list of .h files for the test>
 #      DEPENDS <list of dependencies>
-#      ARGS <list of command line arguments to be passed to the test>
 #      ENV <list of environment variables to set before running the test>
 #      COMPILE_OPTIONS <list of special compile options for this target>
 #      LINK_LIBRARIES <list of linking libraries for this target>
-#      LOADER_ARGS <list of special args to loaders (like the GPU loader)>
 #    )
 function(create_libc_unittest fq_target_name)
   if(NOT LLVM_INCLUDE_TESTS)
@@ -206,7 +204,7 @@ function(create_libc_unittest fq_target_name)
     "LIBC_UNITTEST"
     "NO_RUN_POSTBUILD;C_TEST" # Optional arguments
     "SUITE;CXX_STANDARD" # Single value arguments
-    "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;LOADER_ARGS;FLAGS" # Multi-value arguments
+    "SRCS;HDRS;DEPENDS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;FLAGS" # Multi-value arguments
     ${ARGN}
   )
   if(NOT LIBC_UNITTEST_SRCS)
@@ -319,15 +317,9 @@ function(create_libc_unittest fq_target_name)
 
   target_link_libraries(${fq_build_target_name} PRIVATE ${link_libraries})
 
-  if(TARGET libc.utils.gpu.loader)
-    add_dependencies(${fq_build_target_name} libc.utils.gpu.loader)
-    get_target_property(gpu_loader_exe libc.utils.gpu.loader "EXECUTABLE")
-  endif()
-
   if(NOT LIBC_UNITTEST_NO_RUN_POSTBUILD)
     set(test_cmd ${LIBC_UNITTEST_ENV}
-        $<$<BOOL:${LIBC_TARGET_OS_IS_GPU}>:${gpu_loader_exe}> ${CMAKE_CROSSCOMPILING_EMULATOR} ${LIBC_UNITTEST_LOADER_ARGS}
-        $<TARGET_FILE:${fq_build_target_name}> ${LIBC_UNITTEST_ARGS})
+        ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${fq_build_target_name}>)
     add_custom_target(
       ${fq_target_name}
       DEPENDS ${fq_target_name}-cmd

>From 9cdff938b22c740baac7ccf764172fd18917cfa9 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Thu, 3 Apr 2025 01:25:26 +0200
Subject: [PATCH 11/15] change cmd target name

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 4e99e048164dc..d1f94aa05ce04 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -322,18 +322,18 @@ function(create_libc_unittest fq_target_name)
         ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${fq_build_target_name}>)
     add_custom_target(
       ${fq_target_name}
-      DEPENDS ${fq_target_name}-cmd
+      DEPENDS ${fq_target_name}.__cmd__
     )
 
     add_custom_command(
-      OUTPUT ${fq_target_name}-cmd
+      OUTPUT ${fq_target_name}.__cmd__
       COMMAND ${test_cmd}
       COMMAND_EXPAND_LISTS
       COMMENT "Running unit test ${fq_target_name}"
       ${LIBC_UNIT_TEST_JOB_POOL}
     )
 
-    set_source_files_properties(${fq_target_name}-cmd
+    set_source_files_properties(${fq_target_name}.__cmd__
       PROPERTIES
         SYMBOLIC "TRUE"
     )
@@ -820,18 +820,18 @@ function(add_libc_hermetic test_name)
         $<TARGET_FILE:${fq_build_target_name}> ${HERMETIC_TEST_ARGS})
     add_custom_target(
       ${fq_target_name}
-      DEPENDS ${fq_target_name}-cmd
+      DEPENDS ${fq_target_name}.__cmd__
     )
 
     add_custom_command(
-      OUTPUT ${fq_target_name}-cmd
+      OUTPUT ${fq_target_name}.__cmd__
       COMMAND ${test_cmd}
       COMMAND_EXPAND_LISTS
       COMMENT "Running hermetic test ${fq_target_name}"
       ${LIBC_HERMETIC_TEST_JOB_POOL}
     )
 
-    set_source_files_properties(${fq_target_name}-cmd
+    set_source_files_properties(${fq_target_name}.__cmd__
       PROPERTIES
         SYMBOLIC "TRUE"
     )

>From 2ad8344170c897098f9c01db8b6963420b22c65f Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Sat, 5 Apr 2025 01:53:45 +0200
Subject: [PATCH 12/15] copy string to prevent env pointer manipulation

---
 libc/test/src/__support/CMakeLists.txt                   | 2 ++
 libc/test/src/__support/str_to_float_comparison_test.cpp | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 03f6f896150a6..78aa8b4c0aa0e 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -265,7 +265,9 @@ add_libc_test(
     libc.src.stdlib.strtof
     libc.src.stdlib.strtod
     libc.src.stdlib.getenv
+    libc.src.stdlib.free
     libc.src.string.strtok
+    libc.src.string.strdup
     libc.src.__support.CPP.bit
 )
 
diff --git a/libc/test/src/__support/str_to_float_comparison_test.cpp b/libc/test/src/__support/str_to_float_comparison_test.cpp
index f7d47db4c518c..1c562bfe4b9ea 100644
--- a/libc/test/src/__support/str_to_float_comparison_test.cpp
+++ b/libc/test/src/__support/str_to_float_comparison_test.cpp
@@ -14,7 +14,9 @@
 #include "src/stdlib/getenv.h"
 #include "src/stdlib/strtod.h"
 #include "src/stdlib/strtof.h"
+#include "src/stdlib/free.h"
 #include "src/string/strtok.h"
+#include "src/string/strdup.h"
 #include "test/UnitTest/Test.h"
 #include <stdint.h>
 
@@ -154,6 +156,7 @@ TEST(LlvmLibcStrToFloatComparisonTest, CheckFile) {
   int total = 0;
 
   char *files = LIBC_NAMESPACE::getenv("FILES");
+  files = LIBC_NAMESPACE::strdup(files);
   for (char *file = LIBC_NAMESPACE::strtok(files, ","); file != nullptr;
        file = LIBC_NAMESPACE::strtok(nullptr, ",")) {
     int curResult =
@@ -165,6 +168,8 @@ TEST(LlvmLibcStrToFloatComparisonTest, CheckFile) {
     }
   }
 
+  LIBC_NAMESPACE::free(files);
+
   EXPECT_EQ(result, 0);
   EXPECT_EQ(fails, 0);
   EXPECT_EQ(bitdiffs, 0);

>From d2c9f1b542206a18dd4c256c7334880469c9be82 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Sat, 5 Apr 2025 01:54:28 +0200
Subject: [PATCH 13/15] Update LLVMLibCTestRules.cmake

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index d1f94aa05ce04..b1a8213364476 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -322,20 +322,8 @@ function(create_libc_unittest fq_target_name)
         ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${fq_build_target_name}>)
     add_custom_target(
       ${fq_target_name}
-      DEPENDS ${fq_target_name}.__cmd__
-    )
-
-    add_custom_command(
-      OUTPUT ${fq_target_name}.__cmd__
-      COMMAND ${test_cmd}
-      COMMAND_EXPAND_LISTS
+      COMMAND ${LIBC_UNITTEST_ENV} ${CMAKE_CROSSCOMPILING_EMULATOR} ${fq_build_target_name}
       COMMENT "Running unit test ${fq_target_name}"
-      ${LIBC_UNIT_TEST_JOB_POOL}
-    )
-
-    set_source_files_properties(${fq_target_name}.__cmd__
-      PROPERTIES
-        SYMBOLIC "TRUE"
     )
   endif()
 

>From 34b4f1488f048dd5ee03e79b73ebbd6cb72bdab6 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Sat, 5 Apr 2025 02:04:31 +0200
Subject: [PATCH 14/15] fix formatting

---
 libc/test/src/__support/str_to_float_comparison_test.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/test/src/__support/str_to_float_comparison_test.cpp b/libc/test/src/__support/str_to_float_comparison_test.cpp
index 1c562bfe4b9ea..2f31ef06a1e48 100644
--- a/libc/test/src/__support/str_to_float_comparison_test.cpp
+++ b/libc/test/src/__support/str_to_float_comparison_test.cpp
@@ -11,12 +11,12 @@
 #include "src/stdio/fgets.h"
 #include "src/stdio/fopen.h"
 #include "src/stdio/printf.h"
+#include "src/stdlib/free.h"
 #include "src/stdlib/getenv.h"
 #include "src/stdlib/strtod.h"
 #include "src/stdlib/strtof.h"
-#include "src/stdlib/free.h"
-#include "src/string/strtok.h"
 #include "src/string/strdup.h"
+#include "src/string/strtok.h"
 #include "test/UnitTest/Test.h"
 #include <stdint.h>
 

>From 7590cc7fd9bb3276af1c01c44588c9462bd69d3b Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Sat, 5 Apr 2025 03:28:32 +0200
Subject: [PATCH 15/15] remove unnecessary free operation

---
 libc/test/src/__support/CMakeLists.txt                   | 1 -
 libc/test/src/__support/str_to_float_comparison_test.cpp | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 78aa8b4c0aa0e..971389ee6a3da 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -265,7 +265,6 @@ add_libc_test(
     libc.src.stdlib.strtof
     libc.src.stdlib.strtod
     libc.src.stdlib.getenv
-    libc.src.stdlib.free
     libc.src.string.strtok
     libc.src.string.strdup
     libc.src.__support.CPP.bit
diff --git a/libc/test/src/__support/str_to_float_comparison_test.cpp b/libc/test/src/__support/str_to_float_comparison_test.cpp
index 2f31ef06a1e48..b0fbf56845aa3 100644
--- a/libc/test/src/__support/str_to_float_comparison_test.cpp
+++ b/libc/test/src/__support/str_to_float_comparison_test.cpp
@@ -11,7 +11,6 @@
 #include "src/stdio/fgets.h"
 #include "src/stdio/fopen.h"
 #include "src/stdio/printf.h"
-#include "src/stdlib/free.h"
 #include "src/stdlib/getenv.h"
 #include "src/stdlib/strtod.h"
 #include "src/stdlib/strtof.h"
@@ -168,8 +167,6 @@ TEST(LlvmLibcStrToFloatComparisonTest, CheckFile) {
     }
   }
 
-  LIBC_NAMESPACE::free(files);
-
   EXPECT_EQ(result, 0);
   EXPECT_EQ(fails, 0);
   EXPECT_EQ(bitdiffs, 0);



More information about the libc-commits mailing list