diff --git a/libc/test/src/math/differential_testing/BinaryOpSingleOutputDiff.h b/libc/test/src/math/differential_testing/BinaryOpSingleOutputDiff.h --- a/libc/test/src/math/differential_testing/BinaryOpSingleOutputDiff.h +++ b/libc/test/src/math/differential_testing/BinaryOpSingleOutputDiff.h @@ -7,8 +7,9 @@ //===----------------------------------------------------------------------===// #include "src/__support/FPUtil/FPBits.h" -#include "utils/testutils/StreamWrapper.h" -#include "utils/testutils/Timer.h" +#include "test/src/math/differential_testing/Timer.h" + +#include namespace __llvm_libc { namespace testing { @@ -24,8 +25,7 @@ static uint64_t run_diff_in_range(Func myFunc, Func otherFunc, UIntType startingBit, UIntType endingBit, - UIntType N, - testutils::OutputFileStream &log) { + UIntType N, std::ofstream &log) { uint64_t result = 0; if (endingBit < startingBit) { return result; @@ -58,7 +58,7 @@ static void run_perf_in_range(Func myFunc, Func otherFunc, UIntType startingBit, UIntType endingBit, - UIntType N, testutils::OutputFileStream &log) { + UIntType N, std::ofstream &log) { auto runner = [=](Func func) { volatile T result; if (endingBit < startingBit) { @@ -105,7 +105,7 @@ } static void run_perf(Func myFunc, Func otherFunc, const char *logFile) { - testutils::OutputFileStream log(logFile); + std::ofstream log(logFile); log << " Performance tests with inputs in denormal range:\n"; run_perf_in_range(myFunc, otherFunc, /* startingBit= */ UIntType(0), /* endingBit= */ FPBits::MAX_SUBNORMAL, 1'000'001, log); @@ -121,7 +121,7 @@ static void run_diff(Func myFunc, Func otherFunc, const char *logFile) { uint64_t diffCount = 0; - testutils::OutputFileStream log(logFile); + std::ofstream log(logFile); log << " Diff tests with inputs in denormal range:\n"; diffCount += run_diff_in_range( myFunc, otherFunc, /* startingBit= */ UIntType(0), diff --git a/libc/test/src/math/differential_testing/CMakeLists.txt b/libc/test/src/math/differential_testing/CMakeLists.txt --- a/libc/test/src/math/differential_testing/CMakeLists.txt +++ b/libc/test/src/math/differential_testing/CMakeLists.txt @@ -1,3 +1,11 @@ +add_library( + libc_diff_test_utils + Timer.cpp + Timer.h +) + +# A convenience target to build all differential tests. +add_custom_target(libc-math-differential-tests) function(add_diff_binary target_name) cmake_parse_arguments( @@ -39,8 +47,6 @@ ${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR} - ${LIBC_BUILD_DIR} - ${LIBC_BUILD_DIR}/include ) if(DIFF_COMPILE_OPTIONS) target_compile_options( @@ -51,7 +57,7 @@ target_link_libraries( ${fq_target_name} - PRIVATE ${link_object_files} libc_test_utils) + PRIVATE ${link_object_files} libc_test_utils libc_diff_test_utils) set_target_properties(${fq_target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) @@ -69,6 +75,7 @@ libc.src.__support.FPUtil.fp_bits ${fq_deps_list} ) + add_dependencies(libc-math-differential-tests ${fq_target_name}) endfunction() add_header_library( diff --git a/libc/test/src/math/differential_testing/SingleInputSingleOutputDiff.h b/libc/test/src/math/differential_testing/SingleInputSingleOutputDiff.h --- a/libc/test/src/math/differential_testing/SingleInputSingleOutputDiff.h +++ b/libc/test/src/math/differential_testing/SingleInputSingleOutputDiff.h @@ -7,8 +7,9 @@ //===----------------------------------------------------------------------===// #include "src/__support/FPUtil/FPBits.h" -#include "utils/testutils/StreamWrapper.h" -#include "utils/testutils/Timer.h" +#include "test/src/math/differential_testing/Timer.h" + +#include namespace __llvm_libc { namespace testing { @@ -24,7 +25,7 @@ static void runDiff(Func myFunc, Func otherFunc, const char *logFile) { UIntType diffCount = 0; - testutils::OutputFileStream log(logFile); + std::ofstream log(logFile); log << "Starting diff for values from 0 to " << UIntMax << '\n' << "Only differing results will be logged.\n\n"; for (UIntType bits = 0;; ++bits) { @@ -47,8 +48,7 @@ } static void runPerfInRange(Func myFunc, Func otherFunc, UIntType startingBit, - UIntType endingBit, - testutils::OutputFileStream &log) { + UIntType endingBit, std::ofstream &log) { auto runner = [=](Func func) { volatile T result; for (UIntType bits = startingBit;; ++bits) { @@ -89,7 +89,7 @@ } static void runPerf(Func myFunc, Func otherFunc, const char *logFile) { - testutils::OutputFileStream log(logFile); + std::ofstream log(logFile); log << " Performance tests with inputs in denormal range:\n"; runPerfInRange(myFunc, otherFunc, /* startingBit= */ UIntType(0), /* endingBit= */ FPBits::MAX_SUBNORMAL, log); diff --git a/libc/utils/testutils/Timer.h b/libc/test/src/math/differential_testing/Timer.h rename from libc/utils/testutils/Timer.h rename to libc/test/src/math/differential_testing/Timer.h diff --git a/libc/utils/testutils/Timer.cpp b/libc/test/src/math/differential_testing/Timer.cpp rename from libc/utils/testutils/Timer.cpp rename to libc/test/src/math/differential_testing/Timer.cpp diff --git a/libc/utils/testutils/CMakeLists.txt b/libc/utils/testutils/CMakeLists.txt --- a/libc/utils/testutils/CMakeLists.txt +++ b/libc/utils/testutils/CMakeLists.txt @@ -13,7 +13,5 @@ ExecuteFunction.h ${FDReaderFile} FDReader.h - Timer.h - Timer.cpp RoundingModeUtils.cpp )