diff options
Diffstat (limited to 'libc/test')
35 files changed, 689 insertions, 9 deletions
diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt index d92ab6f..f1a83fc 100644 --- a/libc/test/UnitTest/CMakeLists.txt +++ b/libc/test/UnitTest/CMakeLists.txt @@ -125,6 +125,7 @@ add_unittest_framework_library( RoundingModeUtils.h DEPENDS LibcTest + libc.test.UnitTest.ErrnoCheckingTest libc.test.UnitTest.string_utils libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits diff --git a/libc/test/UnitTest/FEnvSafeTest.cpp b/libc/test/UnitTest/FEnvSafeTest.cpp index 168b1d4..f644569 100644 --- a/libc/test/UnitTest/FEnvSafeTest.cpp +++ b/libc/test/UnitTest/FEnvSafeTest.cpp @@ -9,8 +9,10 @@ #include "FEnvSafeTest.h" #include "src/__support/FPUtil/FEnvImpl.h" +#include "src/__support/libc_errno.h" #include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" +#include "test/UnitTest/ErrnoCheckingTest.h" namespace LIBC_NAMESPACE_DECL { namespace testing { @@ -25,6 +27,10 @@ void FEnvSafeTest::TearDown() { if (!should_be_unchanged) { restore_fenv(); } + // TODO (PR 135320): Remove this override once all FEnvSafeTest instances are + // updated to validate or ignore errno. + libc_errno = 0; + ErrnoCheckingTest::TearDown(); } void FEnvSafeTest::get_fenv(fenv_t &fenv) { diff --git a/libc/test/UnitTest/FEnvSafeTest.h b/libc/test/UnitTest/FEnvSafeTest.h index a3c5e62..1e10629 100644 --- a/libc/test/UnitTest/FEnvSafeTest.h +++ b/libc/test/UnitTest/FEnvSafeTest.h @@ -12,6 +12,7 @@ #include "hdr/types/fenv_t.h" #include "src/__support/CPP/utility.h" #include "src/__support/macros/config.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" namespace LIBC_NAMESPACE_DECL { @@ -20,7 +21,7 @@ namespace testing { // This provides a test fixture (or base class for other test fixtures) that // asserts that each test does not leave the FPU state represented by `fenv_t` // (aka `FPState`) perturbed from its initial state. -class FEnvSafeTest : public Test { +class FEnvSafeTest : public ErrnoCheckingTest { public: void TearDown() override; diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index da15cf2..592cd1b 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -14,8 +14,10 @@ #include "src/__support/FPUtil/FEnvImpl.h" #include "src/__support/FPUtil/FPBits.h" #include "src/__support/FPUtil/fpbits_str.h" +#include "src/__support/libc_errno.h" #include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/RoundingModeUtils.h" #include "test/UnitTest/StringUtils.h" #include "test/UnitTest/Test.h" @@ -166,7 +168,7 @@ CFPMatcher<T, C> getMatcherComplex(T expectedValue) { return CFPMatcher<T, C>(expectedValue); } -template <typename T> struct FPTest : public Test { +template <typename T> struct FPTest : public ErrnoCheckingTest { using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>; using StorageType = typename FPBits::StorageType; static constexpr StorageType STORAGE_MAX = @@ -191,6 +193,13 @@ template <typename T> struct FPTest : public Test { fputil::testing::RoundingMode::Downward, fputil::testing::RoundingMode::TowardZero, }; + + void TearDown() override { + // TODO (PR 135320): Remove this override once all FPTest instances are + // updated to validate or ignore errno. + libc_errno = 0; + ErrnoCheckingTest::TearDown(); + } }; // Add facility to test Flush-Denormal-To-Zero (FTZ) and Denormal-As-Zero (DAZ) diff --git a/libc/test/integration/src/__support/GPU/CMakeLists.txt b/libc/test/integration/src/__support/GPU/CMakeLists.txt index e066830..1fb175b 100644 --- a/libc/test/integration/src/__support/GPU/CMakeLists.txt +++ b/libc/test/integration/src/__support/GPU/CMakeLists.txt @@ -27,3 +27,16 @@ add_integration_test( LOADER_ARGS --threads 64 ) + +add_libc_test( + fixedstack_test + SUITE + libc-support-gpu-tests + SRCS + fixedstack_test.cpp + DEPENDS + libc.src.__support.GPU.fixedstack + LOADER_ARGS + --threads 32 + --blocks 16 +) diff --git a/libc/test/integration/src/__support/GPU/fixedstack_test.cpp b/libc/test/integration/src/__support/GPU/fixedstack_test.cpp new file mode 100644 index 0000000..fde51df --- /dev/null +++ b/libc/test/integration/src/__support/GPU/fixedstack_test.cpp @@ -0,0 +1,44 @@ +//===-- Integration test for the lock-free stack --------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "src/__support/GPU/fixedstack.h" +#include "src/__support/GPU/utils.h" +#include "test/IntegrationTest/test.h" + +using namespace LIBC_NAMESPACE; + +static FixedStack<uint32_t, 2048> global_stack; + +void run() { + // We need enough space in the stack as threads in flight can temporarily + // consume memory before they finish comitting it back to the stack. + ASSERT_EQ(gpu::get_num_blocks() * gpu::get_num_threads(), 512); + + uint32_t val; + uint32_t num_threads = static_cast<uint32_t>(gpu::get_num_threads()); + for (int i = 0; i < 256; ++i) { + EXPECT_TRUE(global_stack.push(UINT32_MAX)) + EXPECT_TRUE(global_stack.pop(val)) + ASSERT_TRUE(val < num_threads || val == UINT32_MAX); + } + + EXPECT_TRUE(global_stack.push(static_cast<uint32_t>(gpu::get_thread_id()))); + EXPECT_TRUE(global_stack.push(static_cast<uint32_t>(gpu::get_thread_id()))); + EXPECT_TRUE(global_stack.pop(val)); + ASSERT_TRUE(val < num_threads || val == UINT32_MAX); + + // Fill the rest of the stack with the default value. + while (!global_stack.push(UINT32_MAX)) + ; +} + +TEST_MAIN(int argc, char **argv, char **envp) { + run(); + + return 0; +} diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt index f5ea510..9685aea 100644 --- a/libc/test/shared/CMakeLists.txt +++ b/libc/test/shared/CMakeLists.txt @@ -27,6 +27,7 @@ add_fp_unittest( libc.src.__support.math.atanhf libc.src.__support.math.atanhf16 libc.src.__support.math.cbrt + libc.src.__support.math.cbrtf libc.src.__support.math.erff libc.src.__support.math.exp libc.src.__support.math.exp10 diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp index 3d64e5e..5e57c49e 100644 --- a/libc/test/shared/shared_math_test.cpp +++ b/libc/test/shared/shared_math_test.cpp @@ -49,6 +49,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat) { EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::atan2f(0.0f, 0.0f)); EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::atanf(0.0f)); EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::atanhf(0.0f)); + EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::cbrtf(0.0f)); EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::erff(0.0f)); EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::exp10f(0.0f)); EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::expf(0.0f)); diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt index 43cde0d..a74f9fe 100644 --- a/libc/test/src/math/CMakeLists.txt +++ b/libc/test/src/math/CMakeLists.txt @@ -2972,6 +2972,118 @@ add_fp_unittest( libc.src.__support.macros.properties.types ) +add_fp_unittest( + bf16add_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + bf16add_test.cpp + HDRS + AddTest.h + DEPENDS + libc.src.math.bf16add + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( + bf16addf_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + bf16addf_test.cpp + HDRS + AddTest.h + DEPENDS + libc.src.math.bf16addf + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( + bf16addl_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + bf16addl_test.cpp + HDRS + AddTest.h + DEPENDS + libc.src.math.bf16addl + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( + bf16addf128_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + bf16addf128_test.cpp + HDRS + AddTest.h + DEPENDS + libc.src.math.bf16addf128 + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( + bf16sub_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + bf16sub_test.cpp + HDRS + SubTest.h + DEPENDS + libc.src.math.bf16sub + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( + bf16subf_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + bf16subf_test.cpp + HDRS + SubTest.h + DEPENDS + libc.src.math.bf16subf + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( + bf16subl_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + bf16subl_test.cpp + HDRS + SubTest.h + DEPENDS + libc.src.math.bf16subl + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( + bf16subf128_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + bf16subf128_test.cpp + HDRS + SubTest.h + DEPENDS + libc.src.math.bf16subf128 + libc.src.__support.FPUtil.bfloat16 +) + add_subdirectory(generic) add_subdirectory(smoke) diff --git a/libc/test/src/math/bf16add_test.cpp b/libc/test/src/math/bf16add_test.cpp new file mode 100644 index 0000000..9e9c594 --- /dev/null +++ b/libc/test/src/math/bf16add_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16add ---------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "AddTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16add.h" + +LIST_ADD_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16add) diff --git a/libc/test/src/math/bf16addf128_test.cpp b/libc/test/src/math/bf16addf128_test.cpp new file mode 100644 index 0000000..46f7ad3 --- /dev/null +++ b/libc/test/src/math/bf16addf128_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16addf128 -----------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "AddTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16addf128.h" + +LIST_ADD_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16addf128) diff --git a/libc/test/src/math/bf16addf_test.cpp b/libc/test/src/math/bf16addf_test.cpp new file mode 100644 index 0000000..06d56cf --- /dev/null +++ b/libc/test/src/math/bf16addf_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16addf --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "AddTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16addf.h" + +LIST_ADD_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16addf) diff --git a/libc/test/src/math/bf16addl_test.cpp b/libc/test/src/math/bf16addl_test.cpp new file mode 100644 index 0000000..bf54827 --- /dev/null +++ b/libc/test/src/math/bf16addl_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16addl --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "AddTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16addl.h" + +LIST_ADD_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16addl) diff --git a/libc/test/src/math/bf16sub_test.cpp b/libc/test/src/math/bf16sub_test.cpp new file mode 100644 index 0000000..4a793dc --- /dev/null +++ b/libc/test/src/math/bf16sub_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16sub ---------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SubTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16sub.h" + +LIST_SUB_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16sub) diff --git a/libc/test/src/math/bf16subf128_test.cpp b/libc/test/src/math/bf16subf128_test.cpp new file mode 100644 index 0000000..25d6711 --- /dev/null +++ b/libc/test/src/math/bf16subf128_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16subf128 -----------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SubTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16subf128.h" + +LIST_SUB_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16subf128) diff --git a/libc/test/src/math/bf16subf_test.cpp b/libc/test/src/math/bf16subf_test.cpp new file mode 100644 index 0000000..e8c7440 --- /dev/null +++ b/libc/test/src/math/bf16subf_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16subf --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SubTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16subf.h" + +LIST_SUB_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16subf) diff --git a/libc/test/src/math/bf16subl_test.cpp b/libc/test/src/math/bf16subl_test.cpp new file mode 100644 index 0000000..2997369 --- /dev/null +++ b/libc/test/src/math/bf16subl_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16subl --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SubTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16subl.h" + +LIST_SUB_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16subl) diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index a722f61..dc1850a 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -345,6 +345,19 @@ add_fp_unittest( ) add_fp_unittest( + truncbf16_test + SUITE + libc-math-smoke-tests + SRCS + truncbf16_test.cpp + HDRS + TruncTest.h + DEPENDS + libc.src.math.truncbf16 + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( canonicalize_test SUITE libc-math-smoke-tests @@ -544,6 +557,19 @@ add_fp_unittest( ) add_fp_unittest( + ceilbf16_test + SUITE + libc-math-smoke-tests + SRCS + ceilbf16_test.cpp + HDRS + CeilTest.h + DEPENDS + libc.src.math.ceilbf16 + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( dfmal_test SUITE libc-math-smoke-tests @@ -664,6 +690,19 @@ add_fp_unittest( ) add_fp_unittest( + floorbf16_test + SUITE + libc-math-smoke-tests + SRCS + floorbf16_test.cpp + HDRS + FloorTest.h + DEPENDS + libc.src.math.floorbf16 + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( round_test SUITE libc-math-smoke-tests @@ -728,6 +767,19 @@ add_fp_unittest( ) add_fp_unittest( + roundbf16_test + SUITE + libc-math-smoke-tests + SRCS + roundbf16_test.cpp + HDRS + RoundTest.h + DEPENDS + libc.src.math.roundbf16 + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( roundeven_test SUITE libc-math-smoke-tests @@ -792,6 +844,19 @@ add_fp_unittest( ) add_fp_unittest( + roundevenbf16_test + SUITE + libc-math-smoke-tests + SRCS + roundevenbf16_test.cpp + HDRS + RoundEvenTest.h + DEPENDS + libc.src.math.roundevenbf16 + libc.src.__support.FPUtil.bfloat16 +) + +add_fp_unittest( lround_test SUITE libc-math-smoke-tests @@ -5400,3 +5465,131 @@ add_fp_unittest( libc.src.__support.macros.properties.os libc.src.__support.macros.properties.types ) + +add_fp_unittest( + bf16add_test + SUITE + libc-math-smoke-tests + SRCS + bf16add_test.cpp + HDRS + AddTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.bf16add + libc.src.__support.FPUtil.bfloat16 + libc.src.__support.macros.properties.os +) + +add_fp_unittest( + bf16addf_test + SUITE + libc-math-smoke-tests + SRCS + bf16addf_test.cpp + HDRS + AddTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.bf16addf + libc.src.__support.FPUtil.bfloat16 + libc.src.__support.macros.properties.os +) + +add_fp_unittest( + bf16addl_test + SUITE + libc-math-smoke-tests + SRCS + bf16addl_test.cpp + HDRS + AddTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.bf16addl + libc.src.__support.FPUtil.bfloat16 + libc.src.__support.macros.properties.os +) + +add_fp_unittest( + bf16addf128_test + SUITE + libc-math-smoke-tests + SRCS + bf16addf128_test.cpp + HDRS + AddTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.bf16addf128 + libc.src.__support.FPUtil.bfloat16 + libc.src.__support.macros.properties.os +) + +add_fp_unittest( + bf16sub_test + SUITE + libc-math-smoke-tests + SRCS + bf16sub_test.cpp + HDRS + SubTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.bf16sub + libc.src.__support.FPUtil.bfloat16 + libc.src.__support.macros.properties.os +) + +add_fp_unittest( + bf16subf_test + SUITE + libc-math-smoke-tests + SRCS + bf16subf_test.cpp + HDRS + SubTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.bf16subf + libc.src.__support.FPUtil.bfloat16 + libc.src.__support.macros.properties.os +) + +add_fp_unittest( + bf16subl_test + SUITE + libc-math-smoke-tests + SRCS + bf16subl_test.cpp + HDRS + SubTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.bf16subl + libc.src.__support.FPUtil.bfloat16 + libc.src.__support.macros.properties.os +) + +add_fp_unittest( + bf16subf128_test + SUITE + libc-math-smoke-tests + SRCS + bf16subf128_test.cpp + HDRS + SubTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.bf16subf128 + libc.src.__support.FPUtil.bfloat16 + libc.src.__support.macros.properties.os +) diff --git a/libc/test/src/math/smoke/CeilTest.h b/libc/test/src/math/smoke/CeilTest.h index 7998eab..1839db9 100644 --- a/libc/test/src/math/smoke/CeilTest.h +++ b/libc/test/src/math/smoke/CeilTest.h @@ -59,10 +59,12 @@ public: EXPECT_FP_EQ(T(-10.0), func(T(-10.32))); EXPECT_FP_EQ(T(11.0), func(T(10.65))); EXPECT_FP_EQ(T(-10.0), func(T(-10.65))); + EXPECT_FP_EQ(T(50.0), func(T(49.62))); + EXPECT_FP_EQ(T(-50.0), func(T(-50.31))); EXPECT_FP_EQ(T(124.0), func(T(123.38))); EXPECT_FP_EQ(T(-123.0), func(T(-123.38))); EXPECT_FP_EQ(T(124.0), func(T(123.96))); - EXPECT_FP_EQ(T(-123.0), func(T(-123.96))); + EXPECT_FP_EQ(T(-123.0), func(T(-123.5))); } }; diff --git a/libc/test/src/math/smoke/FloorTest.h b/libc/test/src/math/smoke/FloorTest.h index bc19e4f..cbcf276 100644 --- a/libc/test/src/math/smoke/FloorTest.h +++ b/libc/test/src/math/smoke/FloorTest.h @@ -59,10 +59,11 @@ public: EXPECT_FP_EQ(T(-11.0), func(T(-10.32))); EXPECT_FP_EQ(T(10.0), func(T(10.65))); EXPECT_FP_EQ(T(-11.0), func(T(-10.65))); + EXPECT_FP_EQ(T(50.0), func(T(50.31))); + EXPECT_FP_EQ(T(-50.0), func(T(-49.63))); EXPECT_FP_EQ(T(123.0), func(T(123.38))); EXPECT_FP_EQ(T(-124.0), func(T(-123.38))); - EXPECT_FP_EQ(T(123.0), func(T(123.96))); - EXPECT_FP_EQ(T(-124.0), func(T(-123.96))); + EXPECT_FP_EQ(T(-124.0), func(T(-123.5))); } }; diff --git a/libc/test/src/math/smoke/RoundTest.h b/libc/test/src/math/smoke/RoundTest.h index beb7000..72889da 100644 --- a/libc/test/src/math/smoke/RoundTest.h +++ b/libc/test/src/math/smoke/RoundTest.h @@ -59,8 +59,10 @@ public: EXPECT_FP_EQ(T(-10.0), func(T(-10.32))); EXPECT_FP_EQ(T(11.0), func(T(10.65))); EXPECT_FP_EQ(T(-11.0), func(T(-10.65))); - EXPECT_FP_EQ(T(123.0), func(T(123.38))); - EXPECT_FP_EQ(T(-123.0), func(T(-123.38))); + EXPECT_FP_EQ(T(50.0), func(T(49.63))); + EXPECT_FP_EQ(T(-50.0), func(T(-50.31))); + EXPECT_FP_EQ(T(124.0), func(T(123.5))); + EXPECT_FP_EQ(T(-124.0), func(T(-123.5))); EXPECT_FP_EQ(T(124.0), func(T(123.96))); EXPECT_FP_EQ(T(-124.0), func(T(-123.96))); } diff --git a/libc/test/src/math/smoke/TruncTest.h b/libc/test/src/math/smoke/TruncTest.h index 49688e8..e088f29 100644 --- a/libc/test/src/math/smoke/TruncTest.h +++ b/libc/test/src/math/smoke/TruncTest.h @@ -61,8 +61,8 @@ public: EXPECT_FP_EQ(T(-10.0), func(T(-10.65))); EXPECT_FP_EQ(T(123.0), func(T(123.38))); EXPECT_FP_EQ(T(-123.0), func(T(-123.38))); - EXPECT_FP_EQ(T(123.0), func(T(123.96))); - EXPECT_FP_EQ(T(-123.0), func(T(-123.96))); + EXPECT_FP_EQ(T(123.0), func(T(123.5))); + EXPECT_FP_EQ(T(-123.0), func(T(-123.5))); } }; diff --git a/libc/test/src/math/smoke/bf16add_test.cpp b/libc/test/src/math/smoke/bf16add_test.cpp new file mode 100644 index 0000000..9e9c594 --- /dev/null +++ b/libc/test/src/math/smoke/bf16add_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16add ---------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "AddTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16add.h" + +LIST_ADD_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16add) diff --git a/libc/test/src/math/smoke/bf16addf128_test.cpp b/libc/test/src/math/smoke/bf16addf128_test.cpp new file mode 100644 index 0000000..46f7ad3 --- /dev/null +++ b/libc/test/src/math/smoke/bf16addf128_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16addf128 -----------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "AddTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16addf128.h" + +LIST_ADD_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16addf128) diff --git a/libc/test/src/math/smoke/bf16addf_test.cpp b/libc/test/src/math/smoke/bf16addf_test.cpp new file mode 100644 index 0000000..06d56cf --- /dev/null +++ b/libc/test/src/math/smoke/bf16addf_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16addf --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "AddTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16addf.h" + +LIST_ADD_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16addf) diff --git a/libc/test/src/math/smoke/bf16addl_test.cpp b/libc/test/src/math/smoke/bf16addl_test.cpp new file mode 100644 index 0000000..bf54827 --- /dev/null +++ b/libc/test/src/math/smoke/bf16addl_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16addl --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "AddTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16addl.h" + +LIST_ADD_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16addl) diff --git a/libc/test/src/math/smoke/bf16sub_test.cpp b/libc/test/src/math/smoke/bf16sub_test.cpp new file mode 100644 index 0000000..4a793dc --- /dev/null +++ b/libc/test/src/math/smoke/bf16sub_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16sub ---------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SubTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16sub.h" + +LIST_SUB_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16sub) diff --git a/libc/test/src/math/smoke/bf16subf128_test.cpp b/libc/test/src/math/smoke/bf16subf128_test.cpp new file mode 100644 index 0000000..25d6711 --- /dev/null +++ b/libc/test/src/math/smoke/bf16subf128_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16subf128 -----------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SubTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16subf128.h" + +LIST_SUB_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16subf128) diff --git a/libc/test/src/math/smoke/bf16subf_test.cpp b/libc/test/src/math/smoke/bf16subf_test.cpp new file mode 100644 index 0000000..e8c7440 --- /dev/null +++ b/libc/test/src/math/smoke/bf16subf_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16subf --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SubTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16subf.h" + +LIST_SUB_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16subf) diff --git a/libc/test/src/math/smoke/bf16subl_test.cpp b/libc/test/src/math/smoke/bf16subl_test.cpp new file mode 100644 index 0000000..2997369 --- /dev/null +++ b/libc/test/src/math/smoke/bf16subl_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for bf16subl --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "SubTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/bf16subl.h" + +LIST_SUB_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16subl) diff --git a/libc/test/src/math/smoke/ceilbf16_test.cpp b/libc/test/src/math/smoke/ceilbf16_test.cpp new file mode 100644 index 0000000..dcaf058 --- /dev/null +++ b/libc/test/src/math/smoke/ceilbf16_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for ceilbf16 --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "CeilTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/ceilbf16.h" + +LIST_CEIL_TESTS(bfloat16, LIBC_NAMESPACE::ceilbf16) diff --git a/libc/test/src/math/smoke/floorbf16_test.cpp b/libc/test/src/math/smoke/floorbf16_test.cpp new file mode 100644 index 0000000..9cc77cd --- /dev/null +++ b/libc/test/src/math/smoke/floorbf16_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for floorbf16 -------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "FloorTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/floorbf16.h" + +LIST_FLOOR_TESTS(bfloat16, LIBC_NAMESPACE::floorbf16) diff --git a/libc/test/src/math/smoke/roundbf16_test.cpp b/libc/test/src/math/smoke/roundbf16_test.cpp new file mode 100644 index 0000000..5163868 --- /dev/null +++ b/libc/test/src/math/smoke/roundbf16_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for roundbf16 -------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "RoundTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/roundbf16.h" + +LIST_ROUND_TESTS(bfloat16, LIBC_NAMESPACE::roundbf16) diff --git a/libc/test/src/math/smoke/roundevenbf16_test.cpp b/libc/test/src/math/smoke/roundevenbf16_test.cpp new file mode 100644 index 0000000..711c37a --- /dev/null +++ b/libc/test/src/math/smoke/roundevenbf16_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for roundevenbf16 ---------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "RoundEvenTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/roundevenbf16.h" + +LIST_ROUNDEVEN_TESTS(bfloat16, LIBC_NAMESPACE::roundevenbf16) diff --git a/libc/test/src/math/smoke/truncbf16_test.cpp b/libc/test/src/math/smoke/truncbf16_test.cpp new file mode 100644 index 0000000..970fa69 --- /dev/null +++ b/libc/test/src/math/smoke/truncbf16_test.cpp @@ -0,0 +1,14 @@ +//===-- Unittests for truncbf16 -------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "TruncTest.h" + +#include "src/__support/FPUtil/bfloat16.h" +#include "src/math/truncbf16.h" + +LIST_TRUNC_TESTS(bfloat16, LIBC_NAMESPACE::truncbf16) |