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
127 lines
4.7 KiB
C++
127 lines
4.7 KiB
C++
//===- OmptTesterStandalone.h - Standalone header variant -------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file
|
|
/// This file represents the 'standalone' header variant, defining the actual
|
|
/// test classes and their behavior (it does not have external dependencies).
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef OPENMP_TOOLS_OMPTEST_INCLUDE_OMPTTESTERSTANDALONE_H
|
|
#define OPENMP_TOOLS_OMPTEST_INCLUDE_OMPTTESTERSTANDALONE_H
|
|
|
|
#include "OmptAssertEvent.h"
|
|
#include "OmptAsserter.h"
|
|
#include "OmptTesterGlobals.h"
|
|
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
// Forward declarations.
|
|
namespace omptest {
|
|
struct OmptEventAsserter;
|
|
class OmptEventReporter;
|
|
class OmptSequencedAsserter;
|
|
} // namespace omptest
|
|
|
|
struct Error {
|
|
operator bool() { return Fail; }
|
|
bool Fail;
|
|
};
|
|
|
|
/// A pretty crude test case abstraction
|
|
struct TestCase {
|
|
TestCase(const std::string &name)
|
|
: IsDisabled(name.rfind("DISABLED_", 0) == 0), Name(name) {}
|
|
TestCase(const std::string &name, const omptest::AssertState &expected)
|
|
: IsDisabled(name.rfind("DISABLED_", 0) == 0), Name(name),
|
|
ExpectedState(expected) {}
|
|
virtual ~TestCase() = default;
|
|
Error exec();
|
|
virtual void execImpl() { assert(false && "Allocating base class"); }
|
|
|
|
bool IsDisabled{false};
|
|
std::string Name;
|
|
omptest::AssertState ExpectedState{omptest::AssertState::Pass};
|
|
omptest::AssertState ResultState{omptest::AssertState::Pass};
|
|
|
|
std::unique_ptr<omptest::OmptSequencedAsserter> SequenceAsserter =
|
|
std::make_unique<omptest::OmptSequencedAsserter>();
|
|
std::unique_ptr<omptest::OmptEventAsserter> SetAsserter =
|
|
std::make_unique<omptest::OmptEventAsserter>();
|
|
std::unique_ptr<omptest::OmptEventReporter> EventReporter =
|
|
std::make_unique<omptest::OmptEventReporter>();
|
|
};
|
|
/// A pretty crude test suite abstraction
|
|
struct TestSuite {
|
|
using TestCaseVec = std::vector<std::unique_ptr<TestCase>>;
|
|
TestSuite() = default;
|
|
TestSuite(const std::string &TSName) : Name(TSName) {}
|
|
TestSuite(const TestSuite &O) = delete;
|
|
TestSuite(TestSuite &&O);
|
|
void setup();
|
|
void teardown();
|
|
TestCaseVec::iterator begin();
|
|
TestCaseVec::iterator end();
|
|
std::string Name;
|
|
TestCaseVec TestCases;
|
|
};
|
|
/// Static class used to register all test cases and provide them to the driver
|
|
class TestRegistrar {
|
|
public:
|
|
static TestRegistrar &get();
|
|
static std::vector<TestSuite> getTestSuites();
|
|
static void addCaseToSuite(TestCase *TC, const std::string &TSName);
|
|
|
|
private:
|
|
TestRegistrar() = default;
|
|
TestRegistrar(const TestRegistrar &o) = delete;
|
|
TestRegistrar operator=(const TestRegistrar &o) = delete;
|
|
// Keep tests in order 'of appearance', i.e. top -> bottom.
|
|
// This effectively mimicks the (observed) behavior of GoogleTest.
|
|
// Avoid maps as they do not have corresponding order guarantees.
|
|
static std::vector<std::pair<std::string, TestSuite>> Tests;
|
|
};
|
|
/// Hack to register test cases
|
|
struct Registerer {
|
|
Registerer(TestCase *TC, const std::string SuiteName);
|
|
};
|
|
/// Eventually executes all test suites and cases, should contain logic to skip
|
|
/// stuff if needed
|
|
struct Runner {
|
|
Runner() : TestSuites(TestRegistrar::get().getTestSuites()) {}
|
|
int run();
|
|
void reportError(const Error &Err);
|
|
void abortOrKeepGoing();
|
|
// Print an execution summary of all testsuites and their corresponding
|
|
// testcases.
|
|
void printSummary();
|
|
std::vector<TestSuite> TestSuites;
|
|
};
|
|
|
|
/// MACROS TO DEFINE A TESTSUITE + TESTCASE (like GoogleTest does)
|
|
#define XQUOTE(str) QUOTE(str)
|
|
#define QUOTE(str) #str
|
|
|
|
#define TEST_TEMPLATE(SuiteName, CaseName, ExpectedState) \
|
|
struct SuiteName##_##CaseName : public TestCase { \
|
|
SuiteName##_##CaseName() \
|
|
: TestCase(XQUOTE(CaseName), omptest::AssertState::ExpectedState) {} \
|
|
virtual void execImpl() override; \
|
|
}; \
|
|
static Registerer R_##SuiteName##CaseName(new SuiteName##_##CaseName(), \
|
|
#SuiteName); \
|
|
void SuiteName##_##CaseName::execImpl()
|
|
|
|
#define TEST(SuiteName, CaseName) \
|
|
TEST_TEMPLATE(SuiteName, CaseName, /*ExpectedState=*/Pass)
|
|
#define TEST_XFAIL(SuiteName, CaseName) \
|
|
TEST_TEMPLATE(SuiteName, CaseName, /*ExpectedState=*/Fail)
|
|
|
|
#endif
|