Skip to content

Commit

Permalink
fixup and move registry tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Mar 26, 2024
1 parent 8c6acab commit 1c20d68
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
13 changes: 13 additions & 0 deletions cpp/src/arrow/buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1023,4 +1023,17 @@ TEST(TestBufferConcatenation, EmptyBuffer) {
AssertMyBufferEqual(*result, contents);
}

TEST(TestDeviceRegistry, Basics) {
// Test the error cases for the device registry

// CPU is already registered
ASSERT_RAISES(KeyError, RegisterDeviceMemoryManager(
DeviceAllocationType::kCPU, [](int64_t device_id) {
return default_cpu_memory_manager();
}));

// VPI is not registered
ASSERT_RAISES(KeyError, GetDeviceMemoryManager(DeviceAllocationType::kVPI));
}

} // namespace arrow
13 changes: 0 additions & 13 deletions cpp/src/arrow/c/bridge_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4330,19 +4330,6 @@ TEST_F(TestDeviceArrayRoundtrip, Struct) {
TestWithJSON(mm, type, R"([[4, null], null, [5, "foo"]])");
}

TEST(TestDeviceRegistry, Basics) {
// Test the error cases for the device registry

// CPU is already registered
ASSERT_RAISES(KeyError, RegisterDeviceMemoryManager(
DeviceAllocationType::kCPU, [](int64_t device_id) {
return default_cpu_memory_manager();
}));

// VPI is not registered
ASSERT_RAISES(KeyError, GetDeviceMemoryManager(DeviceAllocationType::kVPI));
}

////////////////////////////////////////////////////////////////////////////
// Array stream export tests

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class DeviceMemoryManagerRegistryImpl {

Status RegisterDevice(DeviceAllocationType device_type, MemoryMapper memory_mapper) {
std::lock_guard<std::mutex> lock(lock_);
auto [_, inserted] = registry.try_emplace(device_type, std::move(memory_mapper));
auto [_, inserted] = registry_.try_emplace(device_type, std::move(memory_mapper));
if (!inserted) {
return Status::KeyError("Device type ", static_cast<int>(device_type),
" is already registered");
Expand Down

0 comments on commit 1c20d68

Please sign in to comment.