diff options
Diffstat (limited to 'libc/test')
-rw-r--r-- | libc/test/integration/src/stdlib/gpu/malloc_stress.cpp | 28 | ||||
-rw-r--r-- | libc/test/shared/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libc/test/shared/shared_math_test.cpp | 1 |
3 files changed, 30 insertions, 0 deletions
diff --git a/libc/test/integration/src/stdlib/gpu/malloc_stress.cpp b/libc/test/integration/src/stdlib/gpu/malloc_stress.cpp index 77479f8..4c540a8 100644 --- a/libc/test/integration/src/stdlib/gpu/malloc_stress.cpp +++ b/libc/test/integration/src/stdlib/gpu/malloc_stress.cpp @@ -14,6 +14,20 @@ using namespace LIBC_NAMESPACE; +static inline uint32_t entropy() { + return (static_cast<uint32_t>(gpu::processor_clock()) ^ + (gpu::get_thread_id_x() * 0x632be59b) ^ + (gpu::get_block_id_x() * 0x85157af5)) * + 0x9e3779bb; +} + +static inline uint32_t xorshift32(uint32_t &state) { + state ^= state << 13; + state ^= state >> 17; + state ^= state << 5; + return state * 0x9e3779bb; +} + static inline void use(uint8_t *ptr, uint32_t size) { EXPECT_NE(ptr, nullptr); for (int i = 0; i < size; ++i) @@ -34,5 +48,19 @@ TEST_MAIN(int, char **, char **) { for (int i = 0; i < 256; ++i) free(ptrs[i]); + + uint32_t state = entropy(); + for (int i = 0; i < 1024; ++i) { + if (xorshift32(state) % 2) { + uint64_t size = xorshift32(state) % 256 + 16; + uint64_t *ptr = reinterpret_cast<uint64_t *>(malloc(size)); + *ptr = gpu::get_thread_id(); + + EXPECT_EQ(*ptr, gpu::get_thread_id()); + ASSERT_TRUE(ptr); + ASSERT_TRUE(__builtin_is_aligned(ptr, 16)); + free(ptr); + } + } return 0; } diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt index e93fbb9..77f3617 100644 --- a/libc/test/shared/CMakeLists.txt +++ b/libc/test/shared/CMakeLists.txt @@ -16,6 +16,7 @@ add_fp_unittest( libc.src.__support.math.asin libc.src.__support.math.asinf libc.src.__support.math.asinf16 + libc.src.__support.math.asinhf 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 51d38ec..2e4450a 100644 --- a/libc/test/shared/shared_math_test.cpp +++ b/libc/test/shared/shared_math_test.cpp @@ -42,6 +42,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat) { EXPECT_FP_EQ(0x1.921fb6p+0, LIBC_NAMESPACE::shared::acosf(0.0f)); EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::acoshf(1.0f)); EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::asinf(0.0f)); + EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::asinhf(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)); |