166 changes: 83 additions & 83 deletions libc/test/src/string/CMakeLists.txt

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion libc/test/src/string/bzero_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace __llvm_libc {
// Adapt CheckMemset signature to op implementation signatures.
template <auto FnImpl>
void BzeroAdaptor(cpp::span<char> p1, uint8_t value, size_t size) {
assert(value == 0);
FnImpl(p1.begin(), size);
}

Expand Down
6 changes: 4 additions & 2 deletions libc/test/src/string/memory_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
add_libc_unittest(
# This test currently uses too much memory to be made hermetic.
add_libc_test(
utils_test
SUITE
libc_string_unittests
libc-string-tests
SRCS
op_tests.cpp
utils_test.cpp
Expand All @@ -14,4 +15,5 @@ add_libc_unittest(
libc.src.__support.CPP.span
libc.src.__support.macros.sanitizer
libc.src.string.memory_utils.memory_utils
UNIT_TEST_ONLY
)
10 changes: 0 additions & 10 deletions libc/test/src/string/memory_utils/memory_check_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "src/__support/CPP/span.h"
#include "src/__support/macros/sanitizer.h"
#include "src/string/memory_utils/utils.h"
#include <assert.h> // assert
#include <stddef.h> // size_t
#include <stdint.h> // uintxx_t
#include <stdlib.h> // malloc/free
Expand All @@ -24,7 +23,6 @@ namespace __llvm_libc {
// This is a utility class to be used by Buffer below, do not use directly.
struct PoisonedBuffer {
PoisonedBuffer(size_t size) : ptr((char *)malloc(size)) {
assert(ptr);
ASAN_POISON_MEMORY_REGION(ptr, size);
}
~PoisonedBuffer() { free(ptr); }
Expand All @@ -45,11 +43,8 @@ struct Buffer : private PoisonedBuffer {
: PoisonedBuffer(size + kLeeway), size(size) {
offset_ptr = ptr;
offset_ptr += distance_to_next_aligned<kAlign>(ptr);
assert((uintptr_t)(offset_ptr) % kAlign == 0);
if (aligned == Aligned::NO)
++offset_ptr;
assert(offset_ptr > ptr);
assert((offset_ptr + size) < (ptr + size + kLeeway));
ASAN_UNPOISON_MEMORY_REGION(offset_ptr, size);
}
cpp::span<char> span() { return cpp::span<char>(offset_ptr, size); }
Expand Down Expand Up @@ -77,16 +72,13 @@ static inline void Randomize(cpp::span<char> buffer) {
// Copy one span to another.
static inline void ReferenceCopy(cpp::span<char> dst,
const cpp::span<char> src) {
assert(dst.size() == src.size());
for (size_t i = 0; i < dst.size(); ++i)
dst[i] = src[i];
}

// Checks that FnImpl implements the memcpy semantic.
template <auto FnImpl>
bool CheckMemcpy(cpp::span<char> dst, cpp::span<char> src, size_t size) {
assert(dst.size() == src.size());
assert(dst.size() == size);
Randomize(dst);
FnImpl(dst, src, size);
for (size_t i = 0; i < size; ++i)
Expand All @@ -109,7 +101,6 @@ bool CheckMemset(cpp::span<char> dst, uint8_t value, size_t size) {
// Checks that FnImpl implements the bcmp semantic.
template <auto FnImpl>
bool CheckBcmp(cpp::span<char> span1, cpp::span<char> span2, size_t size) {
assert(span1.size() == span2.size());
ReferenceCopy(span2, span1);
// Compare equal
if (int cmp = FnImpl(span1, span2, size); cmp != 0)
Expand All @@ -129,7 +120,6 @@ bool CheckBcmp(cpp::span<char> span1, cpp::span<char> span2, size_t size) {
// Checks that FnImpl implements the memcmp semantic.
template <auto FnImpl>
bool CheckMemcmp(cpp::span<char> span1, cpp::span<char> span2, size_t size) {
assert(span1.size() == span2.size());
ReferenceCopy(span2, span1);
// Compare equal
if (int cmp = FnImpl(span1, span2, size); cmp != 0)
Expand Down
5 changes: 0 additions & 5 deletions libc/test/src/string/memory_utils/op_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "src/string/memory_utils/op_x86.h"
#include "test/UnitTest/Test.h"

#include <assert.h>

#if defined(LIBC_TARGET_ARCH_IS_X86_64) || defined(LIBC_TARGET_ARCH_IS_AARCH64)
#define LLVM_LIBC_HAS_UINT64
#endif
Expand Down Expand Up @@ -75,7 +73,6 @@ void CopyAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
}
template <size_t Size, auto FnImpl>
void CopyBlockAdaptor(cpp::span<char> dst, cpp::span<char> src, size_t size) {
assert(size == Size);
FnImpl(as_byte(dst), as_byte(src));
}

Expand Down Expand Up @@ -157,7 +154,6 @@ void SetAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {
}
template <size_t Size, auto FnImpl>
void SetBlockAdaptor(cpp::span<char> dst, uint8_t value, size_t size) {
assert(size == Size);
FnImpl(as_byte(dst), value);
}

Expand Down Expand Up @@ -235,7 +231,6 @@ int CmpAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
}
template <size_t Size, auto FnImpl>
int CmpBlockAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
assert(size == Size);
return (int)FnImpl(as_byte(p1), as_byte(p2));
}

Expand Down