Files
clang-p2996/compiler-rt/lib/xray/tests/unit/test_helpers.h
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00

78 lines
2.2 KiB
C++

//===-- test_helpers.h ----------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file is a part of XRay, a function call tracing system.
//
//===----------------------------------------------------------------------===//
#ifndef COMPILER_RT_LIB_XRAY_TESTS_TEST_HELPERS_H_
#define COMPILER_RT_LIB_XRAY_TESTS_TEST_HELPERS_H_
#include "xray_buffer_queue.h"
#include "xray_segmented_array.h"
#include "llvm/XRay/Trace.h"
#include "llvm/XRay/XRayRecord.h"
#include "gmock/gmock.h"
// TODO: Move these to llvm/include/Testing/XRay/...
namespace llvm {
namespace xray {
std::string RecordTypeAsString(RecordTypes T);
void PrintTo(RecordTypes T, std::ostream *OS);
void PrintTo(const XRayRecord &R, std::ostream *OS);
void PrintTo(const Trace &T, std::ostream *OS);
namespace testing {
MATCHER_P(FuncId, F, "") {
*result_listener << "where the function id is " << F;
return arg.FuncId == F;
}
MATCHER_P(RecordType, T, "") {
*result_listener << "where the record type is " << RecordTypeAsString(T);
return arg.Type == T;
}
MATCHER_P(HasArg, A, "") {
*result_listener << "where args contains " << A;
return !arg.CallArgs.empty() &&
std::any_of(arg.CallArgs.begin(), arg.CallArgs.end(),
[this](decltype(A) V) { return V == A; });
}
MATCHER_P(TSCIs, M, std::string("TSC is ") + ::testing::PrintToString(M)) {
return ::testing::Matcher<decltype(arg.TSC)>(M).MatchAndExplain(
arg.TSC, result_listener);
}
} // namespace testing
} // namespace xray
} // namespace llvm
namespace __xray {
std::string serialize(BufferQueue &Buffers, int32_t Version);
template <class T> void PrintTo(const Array<T> &A, std::ostream *OS) {
*OS << "[";
bool first = true;
for (const auto &E : A) {
if (!first) {
*OS << ", ";
}
PrintTo(E, OS);
first = false;
}
*OS << "]";
}
} // namespace __xray
#endif // COMPILER_RT_LIB_XRAY_TESTS_TEST_HELPERS_H_