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
90 lines
3.0 KiB
C++
90 lines
3.0 KiB
C++
//===- MemoryFlags.cpp ----------------------------------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Tests for orc-rt's MemoryFlags.h APIs.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "orc-rt/MemoryFlags.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace orc_rt;
|
|
|
|
TEST(MemProtTest, Basics) {
|
|
MemProt MPNone = MemProt::None;
|
|
|
|
EXPECT_EQ(MPNone & MemProt::Read, MemProt::None);
|
|
EXPECT_EQ(MPNone & MemProt::Write, MemProt::None);
|
|
EXPECT_EQ(MPNone & MemProt::Exec, MemProt::None);
|
|
|
|
EXPECT_EQ(MPNone | MemProt::Read, MemProt::Read);
|
|
EXPECT_EQ(MPNone | MemProt::Write, MemProt::Write);
|
|
EXPECT_EQ(MPNone | MemProt::Exec, MemProt::Exec);
|
|
|
|
MemProt MPAll = MemProt::Read | MemProt::Write | MemProt::Exec;
|
|
EXPECT_EQ(MPAll & MemProt::Read, MemProt::Read);
|
|
EXPECT_EQ(MPAll & MemProt::Write, MemProt::Write);
|
|
EXPECT_EQ(MPAll & MemProt::Exec, MemProt::Exec);
|
|
}
|
|
|
|
TEST(AllocGroupTest, Default) {
|
|
AllocGroup G;
|
|
EXPECT_EQ(G.getMemProt(), MemProt::None);
|
|
EXPECT_EQ(G.getMemLifetime(), MemLifetime::Standard);
|
|
}
|
|
|
|
TEST(AllocGroupTest, InitMemProtOnly) {
|
|
AllocGroup G(MemProt::Read | MemProt::Write);
|
|
EXPECT_EQ(G.getMemProt(), MemProt::Read | MemProt::Write);
|
|
EXPECT_EQ(G.getMemLifetime(), MemLifetime::Standard);
|
|
}
|
|
|
|
TEST(AllocGroupTest, InitMemProtAndLifetime) {
|
|
AllocGroup G(MemProt::Read | MemProt::Write, MemLifetime::Finalize);
|
|
EXPECT_EQ(G.getMemProt(), MemProt::Read | MemProt::Write);
|
|
EXPECT_EQ(G.getMemLifetime(), MemLifetime::Finalize);
|
|
}
|
|
|
|
TEST(AllocGroupTest, Equality) {
|
|
AllocGroup G(MemProt::Read, MemLifetime::Standard);
|
|
EXPECT_EQ(G, AllocGroup(MemProt::Read, MemLifetime::Standard));
|
|
EXPECT_NE(G, AllocGroup(MemProt::Write, MemLifetime::Standard));
|
|
EXPECT_NE(G, AllocGroup(MemProt::Read, MemLifetime::Finalize));
|
|
}
|
|
|
|
TEST(AllocGroupTest, LessThan) {
|
|
// Check that AllocGroups can be compared via less-than so that they can be
|
|
// used as keys in standard containers.
|
|
EXPECT_LT(AllocGroup(MemProt::Read, MemLifetime::Standard),
|
|
AllocGroup(MemProt::Write, MemLifetime::Standard));
|
|
EXPECT_LT(AllocGroup(MemProt::Exec, MemLifetime::Standard),
|
|
AllocGroup(MemProt::Read, MemLifetime::Finalize));
|
|
}
|
|
|
|
TEST(AllocGroupSmallMapTest, EmptyMap) {
|
|
AllocGroupSmallMap<bool> EM;
|
|
EXPECT_TRUE(EM.empty());
|
|
EXPECT_EQ(EM.size(), 0u);
|
|
}
|
|
|
|
TEST(AllocGroupSmallMapTest, NonEmptyMap) {
|
|
AllocGroupSmallMap<unsigned> NEM;
|
|
NEM[MemProt::Read] = 42;
|
|
|
|
EXPECT_FALSE(NEM.empty());
|
|
EXPECT_EQ(NEM.size(), 1U);
|
|
EXPECT_EQ(NEM[MemProt::Read], 42U);
|
|
EXPECT_EQ(NEM.find(MemProt::Read), NEM.begin());
|
|
EXPECT_EQ(NEM.find(MemProt::Read | MemProt::Write), NEM.end());
|
|
|
|
NEM[MemProt::Read | MemProt::Write] = 7;
|
|
EXPECT_EQ(NEM.size(), 2U);
|
|
EXPECT_EQ(NEM.begin()->second, 42U);
|
|
EXPECT_EQ((NEM.begin() + 1)->second, 7U);
|
|
}
|