@@ -92,7 +92,7 @@ TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromEmptyReuseListThen
92
92
EXPECT_EQ (nullptr , allocation2);
93
93
}
94
94
95
- TEST_F (InternalAllocationStorageTest, whenAllocationIsStoredAsReusableAndNotUsedThenCanBeObtained ) {
95
+ TEST_F (InternalAllocationStorageTest, whenCompletedAllocationIsStoredAsReusableAndThenCanBeObtained ) {
96
96
void *host_ptr = (void *)0x1234 ;
97
97
auto allocation = memoryManager->allocateGraphicsMemory (1 , host_ptr);
98
98
EXPECT_NE (nullptr , allocation);
@@ -102,7 +102,26 @@ TEST_F(InternalAllocationStorageTest, whenAllocationIsStoredAsReusableAndNotUsed
102
102
103
103
auto *hwTag = csr->getTagAddress ();
104
104
105
- *hwTag = 3u ;
105
+ *hwTag = 2u ;
106
+ auto reusedAllocation = storage->obtainReusableAllocation (1 , false ).release ();
107
+
108
+ EXPECT_EQ (allocation, reusedAllocation);
109
+ EXPECT_TRUE (csr->getAllocationsForReuse ().peekIsEmpty ());
110
+ memoryManager->freeGraphicsMemory (allocation);
111
+ }
112
+
113
+ TEST_F (InternalAllocationStorageTest, whenNotUsedAllocationIsStoredAsReusableAndThenCanBeObtained) {
114
+ void *host_ptr = (void *)0x1234 ;
115
+ auto allocation = memoryManager->allocateGraphicsMemory (1 , host_ptr);
116
+ EXPECT_NE (nullptr , allocation);
117
+ EXPECT_FALSE (allocation->peekWasUsed ());
118
+ EXPECT_EQ (0u , csr->peekTaskCount ());
119
+ *csr->getTagAddress () = 0 ; // initial hw tag for dll
120
+
121
+ storage->storeAllocation (std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
122
+ EXPECT_EQ (0u , allocation->getTaskCount (0u ));
123
+ EXPECT_FALSE (csr->getAllocationsForReuse ().peekIsEmpty ());
124
+
106
125
auto reusedAllocation = storage->obtainReusableAllocation (1 , false ).release ();
107
126
108
127
EXPECT_EQ (allocation, reusedAllocation);
@@ -203,4 +222,4 @@ TEST_F(InternalAllocationStorageTest, givenInternalAllocationWhenItIsPutOnReusab
203
222
EXPECT_EQ (allocation, internalAllocation.get ());
204
223
internalAllocation.release ();
205
224
memoryManager->freeGraphicsMemory (allocation);
206
- }
225
+ }
0 commit comments