Command Queue: Destroy timestamp packet container before releasing context

Change-Id: I7ee492586ee178bc89c44d5d6663d3ff8fb2e778
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2018-12-13 16:24:42 +01:00
committed by sys_ocldev
parent 1439f49845
commit 74510286a1
3 changed files with 22 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
#include "runtime/helpers/basic_math.h"
#include "runtime/helpers/kernel_commands.h"
#include "runtime/helpers/options.h"
#include "runtime/helpers/timestamp_packet.h"
#include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/command_stream/command_stream_fixture.h"
@@ -949,3 +950,22 @@ HWTEST_F(CommandQueueCommandStreamTest, givenCsrWithDebugSurfaceAllocatedWhenSet
RENDER_SURFACE_STATE *surfaceState = (RENDER_SURFACE_STATE *)kernel->getSurfaceStateHeap();
EXPECT_EQ(debugSurface->getGpuAddress(), surfaceState->getSurfaceBaseAddress());
}
struct MockTimestampPacketContainer : TimestampPacketContainer {
MockTimestampPacketContainer(Context &context) : context(context) {
}
~MockTimestampPacketContainer() override {
EXPECT_EQ(1, context.getRefInternalCount());
}
Context &context;
};
TEST(CommandQueueDestructorTest, whenCommandQueueIsDestroyedThenDestroysTimestampPacketContainerBeforeReleasingContext) {
auto context = new MockContext;
EXPECT_EQ(1, context->getRefInternalCount());
MockCommandQueue queue(context, context->getDevice(0), nullptr);
queue.timestampPacketContainer.reset(new MockTimestampPacketContainer(*context));
EXPECT_EQ(2, context->getRefInternalCount());
context->release();
EXPECT_EQ(1, context->getRefInternalCount());
}