summaryrefslogtreecommitdiff
path: root/libc/test/UnitTest/LibcTest.cpp
AgeCommit message (Collapse)Author
2025-03-10[libc] Add `-Wno-sign-conversion` & re-attempt `-Wconversion` (#129811)Vinay Deshmukh
Relates to https://github.com/llvm/llvm-project/issues/119281#issuecomment-2699470459
2025-03-05Revert "[libc] Enable -Wconversion for tests. (#127523)"Augie Fackler
This reverts commit 1e6e845d49a336e9da7ca6c576ec45c0b419b5f6 because it changed the 1st parameter of adjust() to be unsigned, but libc itself calls adjust() with a negative argument in align_backward() in op_generic.h.
2025-03-04[libc] Enable -Wconversion for tests. (#127523)Vinay Deshmukh
Relates to: #119281
2025-02-27[libc][stdfix] Implement fixed point bitsfx functions in llvm libc (#128413)Krishna Pandey
Fixes #113359 --------- Signed-off-by: krishna2803 <kpandey81930@gmail.com>
2024-11-12[libc][i386] FPBit support for 96b long double (#115084)Nick Desaulniers
`long double` is haunted on most architectures, but it is especially so on i386-linux-gnu. While have 80b of significant data, on i386-linux-gnu this type has 96b of storage. Fixes for supporting printf family of conversions for `long double` on i386-linux-gnu. This allows the libc-stdlib-tests and libc_stdio_unittests ninja target tests to pass on i386-linux-gnu. Fixes: #110894 Link: #93709 Co-authored-by: Michael Jones <michaelrj@google.com>
2024-07-15[libc][NFC] Fix printed test time in 32-bit systems (#98922)Mikhail R. Gadelha
clock() returns a clock_t, which is a long and might overflow in 32-bit systems when the test takes a long time to run. Changing it to uint64_t fixes this issue. Before: [ RUN ] LlvmLibcHashTest.Avalanche [ OK ] LlvmLibcHashTest.Avalanche (18446744073709551138 ms) After this patch: [ RUN ] LlvmLibcHashTest.Avalanche [ OK ] LlvmLibcHashTest.Avalanche (4154 ms)
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek
This is a part of #97655.
2024-05-30[libc] android atest compat (#93852)Nick Desaulniers (paternity leave)
These changes slighly modify the output of the unittests so that they better match GTest, so that utilities that parse the expected output from GTest (such as Android's unit test harness) can read the output from our unit tests. This allows our unit tests to be run on Android devices. Add very primitive command line parsing to: - support --gtest_color=no to disable printing terminal colors. - recognize --gtest_print_time and print the test time in milliseconds. - most of our unit tests run on the order of microseconds, so its useful to preserve the existing behavior. But upsteram GTest ONLY prints time tests in milliseconds, and Android's atest expects to be able to parse exactly that. Atest always passes --gtest_print_time. The word `took` is removed as that also differs from upstream GTest, tripping up parsers. - ignore other --gtest_* flags Do so so that atest can parse the output correctly. Print the test number count before each run, so that atest can parse this value correctly. Link: https://android-review.googlesource.com/c/platform/external/llvm-libc/+/3107252 Link: https://google.github.io/googletest/advanced.html#colored-terminal-output Link: https://google.github.io/googletest/advanced.html#suppressing-the-elapsed-time
2024-04-06[libc][NFC] Rename `UInt.h` to `big_int.h` and `UInt128.h` to `uint128.h` ↵Guillaume Chatelet
for consistency (#87808)
2024-03-08[libc] Provide `LIBC_TYPES_HAS_INT128` (#84149)Guillaume Chatelet
Umbrella bug #83182
2024-03-08[libc][NFC] Move `BigInt` out of the `cpp` namespace (#84445)Guillaume Chatelet
As noted in https://github.com/llvm/llvm-project/pull/84035#discussion_r1516817755 only files under the CPP folder should be in the `cpp` namespace.
2024-03-07[reland][libc] Remove UB specializations of type traits for `BigInt` (#84299)Guillaume Chatelet
Note: This is a reland of #84035. The standard specifies that it it UB to specialize the following traits: - `std::is_integral` - `std::is_unsigned` - `std::make_unsigned` - `std::make_signed` This patch: - Removes specializations for `BigInt` - Transforms SFINAE for `bit.h` functions from template parameter to return type (This makes specialization easier). - Adds `BigInt` specialization for `bit.h` functions. - Fixes code depending on previous specializations.
2024-03-07Revert "[libc] Remove UB specializations of type traits for `BigInt`" (#84297)Guillaume Chatelet
Reverts llvm/llvm-project#84035 Several bots are failing: - https://lab.llvm.org/buildbot/#/builders/223/builds/37522 - https://lab.llvm.org/buildbot/#/builders/162/builds/51978 - https://lab.llvm.org/buildbot/#/builders/163/builds/52560 - https://lab.llvm.org/buildbot/#/builders/250/builds/19619
2024-03-07[libc] Remove UB specializations of type traits for `BigInt` (#84035)Guillaume Chatelet
The standard specifies that it it UB to specialize the following traits: - `std::is_integral` - `std::is_unsigned` - `std::make_unsigned` - `std::make_signed` This patch: - Removes specializations for `BigInt` - Transforms SFINAE for `bit.h` functions from template parameter to return type (This makes specialization easier). - Adds `BigInt` specialization for `bit.h` functions. - Fixes code depending on previous specializations.
2024-02-29[libc] Revert https://github.com/llvm/llvm-project/pull/83199 since it broke ↵lntue
Fuchsia. (#83374) With some header fix forward for GPU builds.
2024-02-27[libc] Add "include/" to the LLVM include directories (#83199)Joseph Huber
Summary: Recent changes added an include path in the float128 type that used the internal `libc` path to find the macro. This doesn't work once it's installed because we need to search from the root of the install dir. This patch adds "include/" to the include path so that our inclusion of installed headers always match the internal use.
2024-02-15[libc][stdfix] Add support for fixed point types in the testing ↵lntue
infrastructure. (#81819)
2023-11-02[libc] Allow hermetic timing if the `clock` function is built (#71092)Joseph Huber
Summary: This patch fixes some code duplication on the GPU. The GPU build wanted to enable timing for hermetic tests so it built some special case handling into the test suite. Now that `clock` is supported on the target we can simply link against the external interface. Because we include `clock.h` for the CLOCKS_PER_SEC macro we remap the C entrypoint to the internal one if it ends up called. This should allow hermetic tests to run with timing if it is supported.
2023-10-19[libc] Fix accidental LIBC_NAMESPACE_clock_freq (#69620)alfredfo
See-also: https://github.com/llvm/llvm-project/pull/69548
2023-10-02[libc][NFC] Couple of small warning fixes (#67847)Mikhail R. Gadelha
This patch fixes a couple of warnings when compiling with gcc 13: * CPP/type_traits_test.cpp: 'apply' overrides a member function but is not marked 'override' * UnitTest/LibcTest.cpp:98: control reaches end of non-void function * MPFRWrapper/MPFRUtils.cpp:75: control reaches end of non-void function * smoke/FrexpTest.h:92: backslash-newline at end of file * __support/float_to_string.h:118: comparison of unsigned expression in ‘>= 0’ is always true * test/src/__support/CPP/bitset_test.cpp:197: comparison of unsigned expression in ‘>= 0’ is always true --------- Signed-off-by: Mikhail R. Gadelha <mikhail@igalia.com>
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-08-09[libc] Better IntegerToString APIGuillaume Chatelet
This patch is an alternative to D155902. It provides the following benefits: - No buffer manual allocation and error handling for the general case - More flexible API : width specifier, sign and prefix handling - Simpler code The more flexible API removes the need for manually tweaking the buffer afterwards, and so prevents relying on implementation details of IntegerToString. Reviewed By: michaelrj, jhuber6 Differential Revision: https://reviews.llvm.org/D156981
2023-08-08Revert "[libc] Better IntegerToString API"Guillaume Chatelet
This reverts commit 910cc05aae85a6b31e2a2ed87d3dd46db46fce04.
2023-08-08[libc] Better IntegerToString APIGuillaume Chatelet
This patch is an alternative to D155902. It provides the following benefits: - No buffer manual allocation and error handling for the general case - More flexible API : width specifier, sign and prefix handling - Simpler code The more flexible API removes the need for manually tweaking the buffer afterwards, and so prevents relying on implementation details of IntegerToString. Reviewed By: michaelrj, jhuber6 Differential Revision: https://reviews.llvm.org/D156981
2023-07-05[libc][Obvious] Fix timing on AMDGPU not being initializedJoseph Huber
Summary: Reviewer requested that this routine not be a macro, however that means that it was not being intitialized as the static initializer was done before the memcpy from the device. Fix this so we can get timing information.
2023-07-05[libc][Obvious] Fix bad macro check on NVPTX testsJoseph Huber
Summary: I forgot to add the `defined()` check on NVPTX.
2023-07-05[libc] Support timing information in libc testsJoseph Huber
This patch adds the necessary support to provide timing information in `libc` tests. This is useful for determining which tests look what amount of time. We also can use this as a test basis for providing more fine-grained timing when implementing things on the GPU. The main difficulty with this is the fact that the AMDGPU fixed frequency clock operates at an unknown frequency. We need to read this on a per-card basis from the driver and then copy it in. NVPTX on the other hand has a fixed clock at a resolution of 1ns. I have also increased the resolution of the print-outs as the majority of these are below a millisecond for me. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D154446
2023-06-14[libc] Enable custom logging in LibcTestGuillaume Chatelet
This patch mimics the behavior of Google Test and allow users to log custom messages after all flavors of ASSERT_ / EXPECT_. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D152630
2023-06-14Revert D152630 "[libc] Enable custom logging in LibcTest"Guillaume Chatelet
Failing buildbot https://lab.llvm.org/buildbot/#/builders/73/builds/49707 This reverts commit 9a7b4c934893d6bc571e1ce8efab2127ae5f4e45.
2023-06-14[libc] Enable custom logging in LibcTestGuillaume Chatelet
This patch mimics the behavior of Google Test and allow users to log custom messages after all flavors of ASSERT_ / EXPECT_. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D152630
2023-06-13[libc] Add Int<> type and fix (U)Int<128> compatibility issues.Tue Ly
Add Int<> and Int128 types to replace the usage of __int128_t in math functions. Clean up to make sure that (U)Int128 and __(u)int128_t are interchangeable in the code base. Reviewed By: sivachandra, mikhail.ramalho Differential Revision: https://reviews.llvm.org/D152459
2023-06-10[libc][NFC] Introduce a Location object for consistent failure loggingGuillaume Chatelet
This is just an implementation detail. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D152532
2023-06-09[libc][NFC] Simplify LibcTest and trim down string allocationsGuillaume Chatelet
This is a bit of cleanup before working on logging via stream operator (i.e., `EXPECT_XXX() << ...`). Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D152503
2023-05-23[libc] Display unit test runtime for hosted environmentsGuillaume Chatelet
With more tests added to LLVM libc each week we want to keep track of unittest's runtime, especially for low end build bots. Top offender can be tracked with a bit of scripting (spoiler alert, mem function sweep tests are in the top ones) ``` ninja check-libc | grep "ms)" | awk '{print $(NF-1),$0}' | sort -nr | cut -f2- -d' ' ``` Unfortunately this doesn't work for hermetic tests since `clock` is unavailable. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D151097
2023-05-18[libc] Use the new wide integer to hex string facility in LibcTest.Siva Chandra Reddy
The old code, which has regressed over many cleanups, has been replaced with the new wide integer to hex string facility. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D150901
2023-05-18[libc] Add comparison specialization for cpp:string typeJoseph Huber
We compare this type in the string_test. It had no specialization here so it could cause linker errors. This patch simply extends the interface to support it. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D150904
2023-04-24[libc] Add rule named `add_libc_hermetic_test` which adds a hermetic test.Siva Chandra Reddy
A convenience wrapper name `add_libc_test` is also added which adds both a unit test and a hermetic test. The ctype tests have been switched over to use add_libc_test. Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D148756
2023-04-18[libc][NFC] Move ExecuteFunction test util to test/UnitTest.Siva Chandra Reddy
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D148611
2023-04-17[libc][NFC] Remove the StreamWrapper class and use the new test logger.Siva Chandra Reddy
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D148452
2023-04-03[re-reland][libc] Adds string and TestLogger classes, use them in LibcTestGuillaume Chatelet
This is an implementation of https://discourse.llvm.org/t/rfc-running-libc-unit-tests-as-integration-tests/69461. Differential Revision: https://reviews.llvm.org/D147231
2023-04-03Revert D147231 "[reland][libc] Adds string and TestLogger classes, use them ↵Guillaume Chatelet
in LibcTest" Build bot detected a memory leak. This reverts commit b82d04ea4b4f26037be369f101ae7011975df486.
2023-04-03[reland][libc] Adds string and TestLogger classes, use them in LibcTestGuillaume Chatelet
This is an implementation of https://discourse.llvm.org/t/rfc-running-libc-unit-tests-as-integration-tests/69461. Differential Revision: https://reviews.llvm.org/D147231
2023-04-02Revert D147231 "[libc] Adds string and TestLogger classes, use them in LibcTest"Guillaume Chatelet
Does not build with gcc. This reverts commit fc5ae0a7a45bdb5251f3dad3fc07047f987ca447.
2023-04-02[libc] Adds string and TestLogger classes, use them in LibcTestGuillaume Chatelet
This is an implementation of https://discourse.llvm.org/t/rfc-running-libc-unit-tests-as-integration-tests/69461. Differential Revision: https://reviews.llvm.org/D147231
2023-02-07[libc][NFC] Move UnitTest and IntegrationTest to the 'test' directory.Siva Chandra Reddy
This part of the effort to make all test related pieces into the `test` directory. This helps is excluding test related pieces in a straight forward manner if LLVM_INCLUDE_TESTS is OFF. Future patches will also move the MPFR wrapper and testutils into the 'test' directory.