Skip to content

Commit

Permalink
[unittest] Improve OpenMPIRBuilderTest after D149162
Browse files Browse the repository at this point in the history
Make it less sensitive to omp_offload.info operands order and improve
the failure diagnostic.

Caught by D155789
  • Loading branch information
MaskRay committed Jul 20, 2023
1 parent 96c973d commit 14c55e6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/Casting.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <optional>

Expand Down Expand Up @@ -5860,15 +5861,15 @@ TEST_F(OpenMPIRBuilderTest, registerTargetGlobalVariable) {

// Metadata generated for the host offload module
NamedMDNode *OffloadMetadata = M->getNamedMetadata("omp_offload.info");
EXPECT_NE(OffloadMetadata, nullptr);
if (OffloadMetadata) {
EXPECT_EQ(OffloadMetadata->getOperand(0)->getOperand(1).equalsStr(
"test_data_int_0"),
true);
EXPECT_EQ(OffloadMetadata->getOperand(1)->getOperand(1).equalsStr(
"test_data_int_1_decl_tgt_ref_ptr"),
true);
}
ASSERT_THAT(OffloadMetadata, testing::NotNull());
StringRef Nodes[2] = {
cast<MDString>(OffloadMetadata->getOperand(0)->getOperand(1))
->getString(),
cast<MDString>(OffloadMetadata->getOperand(1)->getOperand(1))
->getString()};
EXPECT_THAT(
Nodes, testing::UnorderedElementsAre("test_data_int_0",
"test_data_int_1_decl_tgt_ref_ptr"));
}

TEST_F(OpenMPIRBuilderTest, createGPUOffloadEntry) {
Expand Down

0 comments on commit 14c55e6

Please sign in to comment.