@@ -92,7 +92,7 @@ TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromEmptyReuseListThen
9292 EXPECT_EQ (nullptr , allocation2);
9393}
9494
95- TEST_F (InternalAllocationStorageTest, whenAllocationIsStoredAsReusableAndNotUsedThenCanBeObtained ) {
95+ TEST_F (InternalAllocationStorageTest, whenCompletedAllocationIsStoredAsReusableAndThenCanBeObtained ) {
9696 void *host_ptr = (void *)0x1234 ;
9797 auto allocation = memoryManager->allocateGraphicsMemory (1 , host_ptr);
9898 EXPECT_NE (nullptr , allocation);
@@ -102,7 +102,26 @@ TEST_F(InternalAllocationStorageTest, whenAllocationIsStoredAsReusableAndNotUsed
102102
103103 auto *hwTag = csr->getTagAddress ();
104104
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+
106125 auto reusedAllocation = storage->obtainReusableAllocation (1 , false ).release ();
107126
108127 EXPECT_EQ (allocation, reusedAllocation);
@@ -203,4 +222,4 @@ TEST_F(InternalAllocationStorageTest, givenInternalAllocationWhenItIsPutOnReusab
203222 EXPECT_EQ (allocation, internalAllocation.get ());
204223 internalAllocation.release ();
205224 memoryManager->freeGraphicsMemory (allocation);
206- }
225+ }
0 commit comments