CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
101 lines
3.3 KiB
C++
101 lines
3.3 KiB
C++
//===- CommonTestUtils.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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef ORC_RT_UNITTEST_COMMONTESTUTILS_H
|
|
#define ORC_RT_UNITTEST_COMMONTESTUTILS_H
|
|
|
|
#include "orc-rt/Error.h"
|
|
#include "orc-rt/ExecutorProcessInfo.h"
|
|
#include "orc-rt/TaskDispatcher.h"
|
|
#include "orc-rt/move_only_function.h"
|
|
|
|
#include <cstddef>
|
|
#include <future>
|
|
|
|
inline void noErrors(orc_rt::Error Err) { orc_rt::cantFail(std::move(Err)); }
|
|
|
|
inline orc_rt::ExecutorProcessInfo mockExecutorProcessInfo() noexcept {
|
|
return orc_rt::ExecutorProcessInfo("arm64-apple-darwin", 16384);
|
|
}
|
|
|
|
class NoDispatcher : public orc_rt::TaskDispatcher {
|
|
public:
|
|
void dispatch(std::unique_ptr<orc_rt::Task> T) override {
|
|
assert(false && "strictly no dispatching!");
|
|
}
|
|
void shutdown() override {}
|
|
};
|
|
|
|
template <size_t Idx = 0> class OpCounter {
|
|
public:
|
|
OpCounter() { ++DefaultConstructions; }
|
|
OpCounter(const OpCounter &Other) { ++CopyConstructions; }
|
|
OpCounter &operator=(const OpCounter &Other) {
|
|
++CopyAssignments;
|
|
return *this;
|
|
}
|
|
OpCounter(OpCounter &&Other) { ++MoveConstructions; }
|
|
OpCounter &operator=(OpCounter &&Other) {
|
|
++MoveAssignments;
|
|
return *this;
|
|
}
|
|
~OpCounter() { ++Destructions; }
|
|
|
|
static size_t defaultConstructions() { return DefaultConstructions; }
|
|
static size_t copyConstructions() { return CopyConstructions; }
|
|
static size_t copyAssignments() { return CopyAssignments; }
|
|
static size_t copies() { return copyConstructions() + copyAssignments(); }
|
|
static size_t moveConstructions() { return MoveConstructions; }
|
|
static size_t moveAssignments() { return MoveAssignments; }
|
|
static size_t moves() { return moveConstructions() + moveAssignments(); }
|
|
static size_t destructions() { return Destructions; }
|
|
|
|
static bool destructionsMatch() {
|
|
return destructions() == defaultConstructions() + copies() + moves();
|
|
}
|
|
|
|
static void reset() {
|
|
DefaultConstructions = 0;
|
|
CopyConstructions = 0;
|
|
CopyAssignments = 0;
|
|
MoveConstructions = 0;
|
|
MoveAssignments = 0;
|
|
Destructions = 0;
|
|
}
|
|
|
|
private:
|
|
static size_t DefaultConstructions;
|
|
static size_t CopyConstructions;
|
|
static size_t CopyAssignments;
|
|
static size_t MoveConstructions;
|
|
static size_t MoveAssignments;
|
|
static size_t Destructions;
|
|
};
|
|
|
|
template <size_t Idx> size_t OpCounter<Idx>::DefaultConstructions = 0;
|
|
template <size_t Idx> size_t OpCounter<Idx>::CopyConstructions = 0;
|
|
template <size_t Idx> size_t OpCounter<Idx>::CopyAssignments = 0;
|
|
template <size_t Idx> size_t OpCounter<Idx>::MoveConstructions = 0;
|
|
template <size_t Idx> size_t OpCounter<Idx>::MoveAssignments = 0;
|
|
template <size_t Idx> size_t OpCounter<Idx>::Destructions = 0;
|
|
|
|
template <typename T>
|
|
orc_rt::move_only_function<void(T)> waitFor(std::future<T> &F) {
|
|
std::promise<T> P;
|
|
F = P.get_future();
|
|
return [P = std::move(P)](T Val) mutable { P.set_value(std::move(Val)); };
|
|
}
|
|
|
|
inline orc_rt::move_only_function<void()> waitFor(std::future<void> &F) {
|
|
std::promise<void> P;
|
|
F = P.get_future();
|
|
return [P = std::move(P)]() mutable { P.set_value(); };
|
|
}
|
|
|
|
#endif // ORC_RT_UNITTEST_COMMONTESTUTILS_H
|