1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
5 #include <gtest/gtest.h>
6 #include <gmock/gmock-spec-builders.h>
8 #include "ie_allocator.hpp"
10 using namespace ::testing;
12 using namespace InferenceEngine;
14 class SystemAllocatorTests: public ::testing::Test {
16 virtual void TearDown() {
19 virtual void SetUp() {
20 allocator = details::shared_from_irelease(CreateDefaultAllocator());
22 std::shared_ptr<IAllocator> allocator;
27 TEST_F(SystemAllocatorTests, canAllocate) {
28 void* handle = allocator->alloc(100);
29 EXPECT_NE(nullptr, handle);
30 allocator->free(handle);
33 TEST_F(SystemAllocatorTests, canLockAllocatedMemory) {
34 //large block such as 10k will result in sigsegv if not allocated
35 void * handle = allocator->alloc(10000);
36 char * ptr = (char *)allocator->lock(handle);
38 ASSERT_EQ(ptr[9999], 11);
39 allocator->unlock(ptr);
40 allocator->free(handle);