LLVM OpenMP 22.0.0git
OmptTesterGoogleTest.h
Go to the documentation of this file.
1//===- OmptTesterGoogleTest.h - GoogleTest header variant -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file represents the GoogleTest-based header variant, defining the
11/// actual test classes and their behavior.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef OPENMP_TOOLS_OMPTEST_INCLUDE_OMPTTESTERGOOGLETEST_H
16#define OPENMP_TOOLS_OMPTEST_INCLUDE_OMPTTESTERGOOGLETEST_H
17
18#include "AssertMacros.h"
19#include "OmptAliases.h"
20#include "OmptAssertEvent.h"
21#include "OmptAsserter.h"
22#include "OmptCallbackHandler.h"
23#include "OmptTesterGlobals.h"
24
25// This will allow us to override the "TEST" macro of gtest
26#define GTEST_DONT_DEFINE_TEST 1
27#include "gtest/gtest.h"
28
29namespace testing {
30class GTEST_API_ OmptTestCase : public testing::Test,
32public:
33 std::unique_ptr<omptest::OmptSequencedAsserter> SequenceAsserter =
34 std::make_unique<omptest::OmptSequencedAsserter>();
35 std::unique_ptr<omptest::OmptEventAsserter> SetAsserter =
36 std::make_unique<omptest::OmptEventAsserter>();
37 std::unique_ptr<omptest::OmptEventReporter> EventReporter =
38 std::make_unique<omptest::OmptEventReporter>();
39
40protected:
46
47 void TearDown() override {
48 // Actively flush potential in-flight trace records
50
51 // Remove subscribers to not be notified of events after test execution.
53
54 // This common testcase must not encounter any failures.
55 if (SequenceAsserter->checkState() == omptest::AssertState::Fail ||
57 ADD_FAILURE();
58 }
59};
60
61class GTEST_API_ OmptTestCaseXFail : public testing::OmptTestCase {
62protected:
63 void TearDown() override {
64 // Actively flush potential in-flight trace records
66
67 // Remove subscribers to not be notified of events after test execution.
69
70 // This eXpectedly failing testcase has to encounter at least one failure.
71 if (SequenceAsserter->checkState() == omptest::AssertState::Pass &&
73 ADD_FAILURE();
74 }
75};
76} // namespace testing
77
78#define TEST(test_suite_name, test_name) \
79 GTEST_TEST_(test_suite_name, test_name, ::testing::OmptTestCase, \
80 ::testing::internal::GetTypeId<::testing::OmptTestCase>())
81
82#define TEST_XFAIL(test_suite_name, test_name) \
83 GTEST_TEST_(test_suite_name, test_name, ::testing::OmptTestCaseXFail, \
84 ::testing::internal::GetTypeId<::testing::OmptTestCaseXFail>())
85
86#endif // include guard
Provides macros to be used in unit tests for OMPT events.
Defines shorthand aliases for OMPT enum values, providing improved ease-of-use and readability.
Contains assertion event constructors, for generally all observable events.
Contains all asserter-related class declarations and important enums.
This file provides the OMPT callback handling declarations.
Contains global function declarations, esp.
int flush_traced_devices()
void subscribe(OmptListener *Listener)
Subscribe a listener to be notified for OMPT events.
void clearSubscribers()
Remove all subscribers.
static OmptCallbackHandler & get()
Singleton handler.
This class provides the members and methods to manage event groups and SyncPoints in conjunction with...
std::unique_ptr< omptest::OmptSequencedAsserter > SequenceAsserter
std::unique_ptr< omptest::OmptEventAsserter > SetAsserter
std::unique_ptr< omptest::OmptEventReporter > EventReporter