Revert D152630 "[libc] Enable custom logging in LibcTest"

Failing buildbot https://lab.llvm.org/buildbot/#/builders/73/builds/49707
This reverts commit 9a7b4c9348.
This commit is contained in:
Guillaume Chatelet 2023-06-14 10:31:49 +00:00
parent 9a7b4c9348
commit bdb07c98c4
13 changed files with 130 additions and 197 deletions

View File

@ -29,8 +29,7 @@ TestLogger &operator<<(TestLogger &logger, Location Loc) {
return logger << Loc.file << ":" << Loc.line << ": FAILURE\n";
}
// When the value is UInt128, __uint128_t or wider, show its hexadecimal
// digits.
// When the value is UInt128, __uint128_t or wider, show its hexadecimal digits.
template <typename T>
cpp::enable_if_t<cpp::is_integral_v<T> && (sizeof(T) > sizeof(uint64_t)),
cpp::string>

View File

@ -42,46 +42,17 @@ namespace testing {
// conditions for such cases.
enum class TestCond { EQ, NE, LT, LE, GT, GE };
struct MatcherBase {
virtual ~MatcherBase() {}
virtual void explainError() { tlog << "unknown error\n"; }
// Override and return true to skip `explainError` step.
virtual bool is_silent() const { return false; }
};
template <typename T> struct Matcher : public MatcherBase {
bool match(const T &t);
};
namespace internal {
// A simple location object to allow consistent passing of __FILE__ and
// __LINE__.
struct Location {
Location(const char *file, int line) : file(file), line(line) {}
const char *file;
int line;
};
// Supports writing a failing Location to tlog.
TestLogger &operator<<(TestLogger &logger, Location Loc);
#define LIBC_TEST_LOC_() \
__llvm_libc::testing::internal::Location(__FILE__, __LINE__)
// Object to forward custom logging after the EXPECT / ASSERT macros.
struct Message {
template <typename T> Message &operator<<(T value) {
tlog << value;
return *this;
}
};
// A trivial object to catch the Message, this enables custom logging and
// returning from the test function, see LIBC_TEST_SCAFFOLDING_ below.
struct Failure {
void operator=(Message msg) {}
};
#define LOC() __llvm_libc::testing::internal::Location(__FILE__, __LINE__)
struct RunContext {
enum class RunResult : bool { Pass, Fail };
@ -100,6 +71,17 @@ bool test(RunContext *Ctx, TestCond Cond, ValType LHS, ValType RHS,
} // namespace internal
struct MatcherBase {
virtual ~MatcherBase() {}
virtual void explainError() { tlog << "unknown error\n"; }
// Override and return true to skip `explainError` step.
virtual bool is_silent() const { return false; }
};
template <typename T> struct Matcher : public MatcherBase {
bool match(T &t);
};
// NOTE: One should not create instances and call methods on them directly. One
// should use the macros TEST or TEST_F to write test cases.
class Test {
@ -174,13 +156,6 @@ protected:
bool testMatch(bool MatchResult, MatcherBase &Matcher, const char *LHSStr,
const char *RHSStr, internal::Location Loc);
template <typename MatcherT, typename ValType>
bool matchAndExplain(MatcherT &&Matcher, ValType Value,
const char *MatcherStr, const char *ValueStr,
internal::Location Loc) {
return testMatch(Matcher.match(Value), Matcher, ValueStr, MatcherStr, Loc);
}
bool testProcessExits(testutils::FunctionCaller *Func, int ExitCode,
const char *LHSStr, const char *RHSStr,
internal::Location Loc);
@ -376,120 +351,106 @@ CString libc_make_test_file_path_func(const char *file_name);
SuiteClass##_##TestName SuiteClass##_##TestName##_Instance; \
void SuiteClass##_##TestName::Run()
// The GNU compiler emits a warning if nested "if" statements are followed by
// an "else" statement and braces are not used to explicitly disambiguate the
// "else" binding. This leads to problems with code like:
//
// if (gate)
// ASSERT_*(condition) << "Some message";
//
// The "switch (0) case 0:" idiom is used to suppress this.
#define LIBC_AMBIGUOUS_ELSE_BLOCKER_ \
switch (0) \
case 0: \
default:
#define EXPECT_EQ(LHS, RHS) \
this->test(__llvm_libc::testing::TestCond::EQ, (LHS), (RHS), #LHS, #RHS, \
LOC())
#define ASSERT_EQ(LHS, RHS) \
if (!EXPECT_EQ(LHS, RHS)) \
return
// If RET_OR_EMPTY is the 'return' keyword we perform an early return which
// corresponds to an assert. If it is empty the execution continues, this
// corresponds to an expect.
//
// The 'else' clause must not be enclosed into braces so that the << operator
// can be used to fill the Message.
//
// TEST is usually implemented as a function performing checking logic and
// returning a boolean. This expression is responsible for logging the
// diagnostic in case of failure.
#define LIBC_TEST_SCAFFOLDING_(TEST, RET_OR_EMPTY) \
LIBC_AMBIGUOUS_ELSE_BLOCKER_ \
if (TEST) \
; \
else \
RET_OR_EMPTY __llvm_libc::testing::internal::Failure() = \
__llvm_libc::testing::internal::Message()
#define EXPECT_NE(LHS, RHS) \
this->test(__llvm_libc::testing::TestCond::NE, (LHS), (RHS), #LHS, #RHS, \
LOC())
#define ASSERT_NE(LHS, RHS) \
if (!EXPECT_NE(LHS, RHS)) \
return
#define LIBC_TEST_BINOP_(COND, LHS, RHS, RET_OR_EMPTY) \
LIBC_TEST_SCAFFOLDING_(test(__llvm_libc::testing::TestCond::COND, LHS, RHS, \
#LHS, #RHS, LIBC_TEST_LOC_()), \
RET_OR_EMPTY)
#define EXPECT_LT(LHS, RHS) \
this->test(__llvm_libc::testing::TestCond::LT, (LHS), (RHS), #LHS, #RHS, \
LOC())
#define ASSERT_LT(LHS, RHS) \
if (!EXPECT_LT(LHS, RHS)) \
return
////////////////////////////////////////////////////////////////////////////////
// Binary operations corresponding to the TestCond enum.
#define EXPECT_LE(LHS, RHS) \
this->test(__llvm_libc::testing::TestCond::LE, (LHS), (RHS), #LHS, #RHS, \
LOC())
#define ASSERT_LE(LHS, RHS) \
if (!EXPECT_LE(LHS, RHS)) \
return
#define EXPECT_EQ(LHS, RHS) LIBC_TEST_BINOP_(EQ, LHS, RHS, )
#define ASSERT_EQ(LHS, RHS) LIBC_TEST_BINOP_(EQ, LHS, RHS, return)
#define EXPECT_GT(LHS, RHS) \
this->test(__llvm_libc::testing::TestCond::GT, (LHS), (RHS), #LHS, #RHS, \
LOC())
#define ASSERT_GT(LHS, RHS) \
if (!EXPECT_GT(LHS, RHS)) \
return
#define EXPECT_NE(LHS, RHS) LIBC_TEST_BINOP_(NE, LHS, RHS, )
#define ASSERT_NE(LHS, RHS) LIBC_TEST_BINOP_(NE, LHS, RHS, return)
#define EXPECT_GE(LHS, RHS) \
this->test(__llvm_libc::testing::TestCond::GE, (LHS), (RHS), #LHS, #RHS, \
LOC())
#define ASSERT_GE(LHS, RHS) \
if (!EXPECT_GE(LHS, RHS)) \
return
#define EXPECT_LT(LHS, RHS) LIBC_TEST_BINOP_(LT, LHS, RHS, )
#define ASSERT_LT(LHS, RHS) LIBC_TEST_BINOP_(LT, LHS, RHS, return)
#define EXPECT_STREQ(LHS, RHS) this->testStrEq((LHS), (RHS), #LHS, #RHS, LOC())
#define ASSERT_STREQ(LHS, RHS) \
if (!EXPECT_STREQ(LHS, RHS)) \
return
#define EXPECT_LE(LHS, RHS) LIBC_TEST_BINOP_(LE, LHS, RHS, )
#define ASSERT_LE(LHS, RHS) LIBC_TEST_BINOP_(LE, LHS, RHS, return)
#define EXPECT_STRNE(LHS, RHS) this->testStrNe((LHS), (RHS), #LHS, #RHS, LOC())
#define ASSERT_STRNE(LHS, RHS) \
if (!EXPECT_STRNE(LHS, RHS)) \
return
#define EXPECT_GT(LHS, RHS) LIBC_TEST_BINOP_(GT, LHS, RHS, )
#define ASSERT_GT(LHS, RHS) LIBC_TEST_BINOP_(GT, LHS, RHS, return)
#define EXPECT_TRUE(VAL) EXPECT_EQ((VAL), true)
#define EXPECT_GE(LHS, RHS) LIBC_TEST_BINOP_(GE, LHS, RHS, )
#define ASSERT_GE(LHS, RHS) LIBC_TEST_BINOP_(GE, LHS, RHS, return)
#define ASSERT_TRUE(VAL) \
if (!EXPECT_TRUE(VAL)) \
return
////////////////////////////////////////////////////////////////////////////////
// Boolean checks are handled as comparison to the true / false values.
#define EXPECT_FALSE(VAL) EXPECT_EQ((VAL), false)
#define EXPECT_TRUE(VAL) EXPECT_EQ(VAL, true)
#define ASSERT_TRUE(VAL) ASSERT_EQ(VAL, true)
#define EXPECT_FALSE(VAL) EXPECT_EQ(VAL, false)
#define ASSERT_FALSE(VAL) ASSERT_EQ(VAL, false)
////////////////////////////////////////////////////////////////////////////////
// String checks.
#define LIBC_TEST_STR_(TEST_FUNC, LHS, RHS, RET_OR_EMPTY) \
LIBC_TEST_SCAFFOLDING_(TEST_FUNC(LHS, RHS, #LHS, #RHS, LIBC_TEST_LOC_()), \
RET_OR_EMPTY)
#define EXPECT_STREQ(LHS, RHS) LIBC_TEST_STR_(testStrEq, LHS, RHS, )
#define ASSERT_STREQ(LHS, RHS) LIBC_TEST_STR_(testStrEq, LHS, RHS, return)
#define EXPECT_STRNE(LHS, RHS) LIBC_TEST_STR_(testStrNe, LHS, RHS, )
#define ASSERT_STRNE(LHS, RHS) LIBC_TEST_STR_(testStrNe, LHS, RHS, return)
////////////////////////////////////////////////////////////////////////////////
// Subprocess checks.
#define ASSERT_FALSE(VAL) \
if (!EXPECT_FALSE(VAL)) \
return
#ifdef ENABLE_SUBPROCESS_TESTS
#define LIBC_TEST_PROCESS_(TEST_FUNC, FUNC, VALUE, RET_OR_EMPTY) \
LIBC_TEST_SCAFFOLDING_( \
TEST_FUNC(__llvm_libc::testing::Test::createCallable(FUNC), VALUE, \
#FUNC, #VALUE, LIBC_TEST_LOC_()), \
RET_OR_EMPTY)
#define EXPECT_EXITS(FUNC, EXIT) \
LIBC_TEST_PROCESS_(testProcessExits, FUNC, EXIT, )
this->testProcessExits(__llvm_libc::testing::Test::createCallable(FUNC), \
EXIT, #FUNC, #EXIT, LOC())
#define ASSERT_EXITS(FUNC, EXIT) \
LIBC_TEST_PROCESS_(testProcessExits, FUNC, EXIT, return)
if (!EXPECT_EXITS(FUNC, EXIT)) \
return
#define EXPECT_DEATH(FUNC, SIG) \
LIBC_TEST_PROCESS_(testProcessKilled, FUNC, SIG, )
#define ASSERT_DEATH(FUNC, SIG) \
LIBC_TEST_PROCESS_(testProcessKilled, FUNC, SIG, return)
this->testProcessKilled(__llvm_libc::testing::Test::createCallable(FUNC), \
SIG, #FUNC, #SIG, LOC())
#define ASSERT_DEATH(FUNC, EXIT) \
if (!EXPECT_DEATH(FUNC, EXIT)) \
return
#endif // ENABLE_SUBPROCESS_TESTS
////////////////////////////////////////////////////////////////////////////////
// Custom matcher checks.
#define LIBC_TEST_MATCH_(MATCHER, MATCH, MATCHER_STR, MATCH_STR, RET_OR_EMPTY) \
LIBC_TEST_SCAFFOLDING_(matchAndExplain(MATCHER, MATCH, MATCHER_STR, \
MATCH_STR, LIBC_TEST_LOC_()), \
RET_OR_EMPTY)
#define __CAT1(a, b) a##b
#define __CAT(a, b) __CAT1(a, b)
#define UNIQUE_VAR(prefix) __CAT(prefix, __LINE__)
#define EXPECT_THAT(MATCH, MATCHER) \
LIBC_TEST_MATCH_(MATCHER, MATCH, #MATCHER, #MATCH, )
[&]() -> bool { \
auto UNIQUE_VAR(__matcher) = (MATCHER); \
return this->testMatch(UNIQUE_VAR(__matcher).match((MATCH)), \
UNIQUE_VAR(__matcher), #MATCH, #MATCHER, LOC()); \
}()
#define ASSERT_THAT(MATCH, MATCHER) \
LIBC_TEST_MATCH_(MATCHER, MATCH, #MATCHER, #MATCH, return)
do { \
if (!EXPECT_THAT(MATCH, MATCHER)) \
return; \
} while (0)
#define WITH_SIGNAL(X) X

View File

@ -2,7 +2,6 @@
#include "src/__support/CPP/string.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/OSUtil/io.h" // write_to_stderr
#include "src/__support/UInt128.h"
#include <stdint.h>
@ -36,49 +35,24 @@ template <> TestLogger &TestLogger::operator<<(char ch) {
return *this << cpp::string_view(&ch, 1);
}
// bool specialization
template <> TestLogger &TestLogger::operator<<(bool cond) {
return *this << (cond ? "true" : "false");
}
// void * specialization
template <> TestLogger &TestLogger::operator<<(void *addr) {
return *this << "0x" << cpp::to_string(reinterpret_cast<uintptr_t>(addr));
}
template <typename T> TestLogger &TestLogger::operator<<(T t) {
if constexpr (cpp::is_integral_v<T> && cpp::is_unsigned_v<T> &&
sizeof(T) > sizeof(uint64_t)) {
static_assert(sizeof(T) % 8 == 0, "Unsupported size of UInt");
char buf[IntegerToString::hex_bufsize<T>()];
IntegerToString::hex(t, buf, false);
return *this << "0x" << cpp::string_view(buf, sizeof(buf));
} else {
return *this << cpp::to_string(t);
}
return *this << cpp::to_string(t);
}
// is_integral specializations
// char is already specialized to handle character
template TestLogger &TestLogger::operator<< <short>(short);
template TestLogger &TestLogger::operator<< <int>(int);
template TestLogger &TestLogger::operator<< <long>(long);
template TestLogger &TestLogger::operator<< <long long>(long long);
template TestLogger &TestLogger::operator<< <unsigned char>(unsigned char);
template TestLogger &TestLogger::operator<< <unsigned short>(unsigned short);
template TestLogger &TestLogger::operator<< <unsigned int>(unsigned int);
template TestLogger &TestLogger::operator<< <long>(long);
template TestLogger &TestLogger::operator<< <unsigned long>(unsigned long);
template TestLogger &TestLogger::operator<< <long long>(long long);
template TestLogger &
TestLogger::operator<< <unsigned long long>(unsigned long long);
#ifdef __SIZEOF_INT128__
template TestLogger &TestLogger::operator<< <__uint128_t>(__uint128_t);
#endif
template TestLogger &TestLogger::operator<< <cpp::UInt<128>>(cpp::UInt<128>);
template TestLogger &TestLogger::operator<< <cpp::UInt<192>>(cpp::UInt<192>);
template TestLogger &TestLogger::operator<< <cpp::UInt<256>>(cpp::UInt<256>);
template TestLogger &TestLogger::operator<< <cpp::UInt<320>>(cpp::UInt<320>);
// TODO: Add floating point formatting once it's supported by StringStream.
TestLogger tlog;

View File

@ -105,11 +105,11 @@ TEST(LlvmLibcLog10Test, InDoubleRange) {
++count;
// ASSERT_MPFR_MATCH(mpfr::Operation::Log10, x, result, 0.5);
if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log10, x, result,
0.5, rounding_mode)) {
if (!EXPECT_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log10, x,
result, 0.5, rounding_mode)) {
++fails;
while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log10, x,
result, tol, rounding_mode)) {
while (!EXPECT_MPFR_MATCH_ROUNDING_SILENTLY(
mpfr::Operation::Log10, x, result, tol, rounding_mode)) {
mx = x;
mr = result;
tol *= 2.0;

View File

@ -106,11 +106,11 @@ TEST(LlvmLibcLog1pTest, InDoubleRange) {
++count;
// ASSERT_MPFR_MATCH(mpfr::Operation::Log1p, x, result, 0.5);
if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log1p, x, result,
0.5, rounding_mode)) {
if (!EXPECT_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log1p, x,
result, 0.5, rounding_mode)) {
++fails;
while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log1p, x,
result, tol, rounding_mode)) {
while (!EXPECT_MPFR_MATCH_ROUNDING_SILENTLY(
mpfr::Operation::Log1p, x, result, tol, rounding_mode)) {
mx = x;
mr = result;
tol *= 2.0;

View File

@ -105,11 +105,11 @@ TEST(LlvmLibcLog2Test, InDoubleRange) {
++count;
// ASSERT_MPFR_MATCH(mpfr::Operation::Log2, x, result, 0.5);
if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log2, x, result,
0.5, rounding_mode)) {
if (!EXPECT_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log2, x, result,
0.5, rounding_mode)) {
++fails;
while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log2, x,
result, tol, rounding_mode)) {
while (!EXPECT_MPFR_MATCH_ROUNDING_SILENTLY(
mpfr::Operation::Log2, x, result, tol, rounding_mode)) {
mx = x;
mr = result;
tol *= 2.0;

View File

@ -105,11 +105,11 @@ TEST(LlvmLibcLogTest, InDoubleRange) {
++count;
// ASSERT_MPFR_MATCH(mpfr::Operation::Log, x, result, 0.5);
if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log, x, result,
0.5, rounding_mode)) {
if (!EXPECT_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log, x, result,
0.5, rounding_mode)) {
++fails;
while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log, x,
result, tol, rounding_mode)) {
while (!EXPECT_MPFR_MATCH_ROUNDING_SILENTLY(
mpfr::Operation::Log, x, result, tol, rounding_mode)) {
mx = x;
mr = result;
tol *= 2.0;

View File

@ -23,7 +23,7 @@ TEST(LlvmLibcBcopyTest, MoveZeroByte) {
const char Expected[] = {'a', 'b', 'y', 'z'};
void *const Dst = Buffer;
__llvm_libc::bcopy(Buffer + 2, Dst, 0);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
TEST(LlvmLibcBcopyTest, DstAndSrcPointToSameAddress) {
@ -31,7 +31,7 @@ TEST(LlvmLibcBcopyTest, DstAndSrcPointToSameAddress) {
const char Expected[] = {'a', 'b'};
void *const Dst = Buffer;
__llvm_libc::bcopy(Buffer, Dst, 1);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
TEST(LlvmLibcBcopyTest, DstStartsBeforeSrc) {
@ -41,7 +41,7 @@ TEST(LlvmLibcBcopyTest, DstStartsBeforeSrc) {
const char Expected[] = {'z', 'b', 'c', 'c', 'z'};
void *const Dst = Buffer + 1;
__llvm_libc::bcopy(Buffer + 2, Dst, 2);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
TEST(LlvmLibcBcopyTest, DstStartsAfterSrc) {
@ -49,7 +49,7 @@ TEST(LlvmLibcBcopyTest, DstStartsAfterSrc) {
const char Expected[] = {'z', 'a', 'a', 'b', 'z'};
void *const Dst = Buffer + 2;
__llvm_libc::bcopy(Buffer + 1, Dst, 2);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
// e.g. `Dst` follow `src`.
@ -61,7 +61,7 @@ TEST(LlvmLibcBcopyTest, SrcFollowDst) {
const char Expected[] = {'z', 'b', 'b', 'z'};
void *const Dst = Buffer + 1;
__llvm_libc::bcopy(Buffer + 2, Dst, 1);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
TEST(LlvmLibcBcopyTest, DstFollowSrc) {
@ -69,7 +69,7 @@ TEST(LlvmLibcBcopyTest, DstFollowSrc) {
const char Expected[] = {'z', 'a', 'a', 'z'};
void *const Dst = Buffer + 2;
__llvm_libc::bcopy(Buffer + 1, Dst, 1);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
// Adapt CheckMemmove signature to bcopy.

View File

@ -31,21 +31,21 @@ TEST(LlvmLibcMemmemTest, EmptyNeedleReturnsHaystack) {
char h[] = {'a', 'b', 'c'};
char *n = nullptr;
void *result = __llvm_libc::memmem(h, sizeof(h), n, 0);
ASSERT_EQ(static_cast<char *>(result), h + 0);
ASSERT_EQ(static_cast<char *>(result), h);
}
TEST(LlvmLibcMemmemTest, ExactMatchReturnsHaystack) {
char h[] = {'a', 'b', 'c'};
char n[] = {'a', 'b', 'c'};
void *result = __llvm_libc::memmem(h, sizeof(h), n, sizeof(n));
ASSERT_EQ(static_cast<char *>(result), h + 0);
ASSERT_EQ(static_cast<char *>(result), h);
}
TEST(LlvmLibcMemmemTest, ReturnFirstMatchOfNeedle) {
char h[] = {'a', 'a', 'b', 'c'};
char n[] = {'a'};
void *result = __llvm_libc::memmem(h, sizeof(h), n, sizeof(n));
ASSERT_EQ(static_cast<char *>(result), h + 0);
ASSERT_EQ(static_cast<char *>(result), h);
}
TEST(LlvmLibcMemmemTest, ReturnFirstExactMatchOfNeedle) {
@ -102,7 +102,7 @@ TEST(LlvmLibcMemmemTest, ReturnMatchOfSpecifiedNeedleLength) {
char h[] = {'a', 'b', 'c'};
char n[] = {'x', 'y', 'z'};
void *result = __llvm_libc::memmem(h, sizeof(h), n, 0);
ASSERT_EQ(static_cast<char *>(result), h + 0);
ASSERT_EQ(static_cast<char *>(result), h);
}
{
char h[] = {'a', 'b', 'c'};

View File

@ -24,7 +24,7 @@ TEST(LlvmLibcMemmoveTest, MoveZeroByte) {
void *const Dst = Buffer;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 2, 0);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
TEST(LlvmLibcMemmoveTest, DstAndSrcPointToSameAddress) {
@ -33,7 +33,7 @@ TEST(LlvmLibcMemmoveTest, DstAndSrcPointToSameAddress) {
void *const Dst = Buffer;
void *const Ret = __llvm_libc::memmove(Dst, Buffer, 1);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
TEST(LlvmLibcMemmoveTest, DstStartsBeforeSrc) {
@ -44,7 +44,7 @@ TEST(LlvmLibcMemmoveTest, DstStartsBeforeSrc) {
void *const Dst = Buffer + 1;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 2, 2);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
TEST(LlvmLibcMemmoveTest, DstStartsAfterSrc) {
@ -53,7 +53,7 @@ TEST(LlvmLibcMemmoveTest, DstStartsAfterSrc) {
void *const Dst = Buffer + 2;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 1, 2);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
// e.g. `Dst` follow `src`.
@ -66,7 +66,7 @@ TEST(LlvmLibcMemmoveTest, SrcFollowDst) {
void *const Dst = Buffer + 1;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 2, 1);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
TEST(LlvmLibcMemmoveTest, DstFollowSrc) {
@ -75,7 +75,7 @@ TEST(LlvmLibcMemmoveTest, DstFollowSrc) {
void *const Dst = Buffer + 2;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 1, 1);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
ASSERT_MEM_EQ(Buffer, Expected);
}
// Adapt CheckMemmove signature to op implementation signatures.

View File

@ -24,5 +24,5 @@ TEST(LlvmLibcMempcpyTest, ZeroCount) {
const char *src = "12345";
char dest[10];
void *result = __llvm_libc::mempcpy(dest, src, 0);
ASSERT_EQ(static_cast<char *>(result), dest + 0);
ASSERT_EQ(static_cast<char *>(result), dest);
}

View File

@ -356,11 +356,11 @@ template <typename T> bool round_to_long(T x, RoundingMode mode, long &result);
mpfr::RoundingMode::TowardZero); \
}
#define TEST_MPFR_MATCH_ROUNDING_SILENTLY(op, input, match_value, \
ulp_tolerance, rounding) \
__llvm_libc::testing::mpfr::get_silent_mpfr_matcher<op>( \
input, match_value, ulp_tolerance, rounding) \
.match(match_value)
#define EXPECT_MPFR_MATCH_ROUNDING_SILENTLY(op, input, match_value, \
ulp_tolerance, rounding) \
EXPECT_THAT(match_value, \
__llvm_libc::testing::mpfr::get_silent_mpfr_matcher<op>( \
input, match_value, ulp_tolerance, rounding))
#define ASSERT_MPFR_MATCH_DEFAULT(op, input, match_value, ulp_tolerance) \
ASSERT_THAT(match_value, \

View File

@ -16,7 +16,6 @@ cc_library(
"//libc:__support_cpp_string",
"//libc:__support_cpp_string_view",
"//libc:__support_osutil_io",
"//libc:__support_uint128",
"//libc:libc_root",
],
)