From 1a4628cd8e555b7ba4e4bcdccc37eacdf91dc20e Mon Sep 17 00:00:00 2001 From: "Milczarek, Slawomir" Date: Tue, 13 Nov 2018 21:52:35 -0800 Subject: [PATCH] AUB file with information about driver version Change-Id: I7f8e01236962580515f36d72805d33af40d5fd2d --- .../aub_command_stream_receiver_hw.inl | 13 +++++++++ .../command_stream/aub_file_stream_tests.cpp | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index c8e3a9a3fb..1cc3c95011 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -23,6 +23,7 @@ #include "runtime/memory_manager/memory_banks.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "runtime/os_interface/debug_settings_manager.h" +#include "driver_version.h" #include #include @@ -179,6 +180,18 @@ void AUBCommandStreamReceiverHw::initializeEngine(size_t engineIndex) initEngineMMIO(engineInstance); this->initAdditionalMMIO(); + // Write driver version + { +#define QTR(a) #a +#define TOSTR(b) QTR(b) + const std::string driverVersion = TOSTR(NEO_DRIVER_VERSION); +#undef QTR +#undef TOSTR + std::ostringstream str; + str << "driver version: " << driverVersion; + getAubStream()->addComment(str.str().c_str()); + } + // Global HW Status Page { const size_t sizeHWSP = 0x1000; diff --git a/unit_tests/command_stream/aub_file_stream_tests.cpp b/unit_tests/command_stream/aub_file_stream_tests.cpp index 948a079054..4502ceddb0 100644 --- a/unit_tests/command_stream/aub_file_stream_tests.cpp +++ b/unit_tests/command_stream/aub_file_stream_tests.cpp @@ -11,6 +11,7 @@ #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/mocks/mock_aub_csr.h" #include "unit_tests/mocks/mock_aub_file_stream.h" +#include "driver_version.h" #include #include @@ -196,6 +197,34 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMMIOIsCalled } } +HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenInitializeEngineIsCalledThenMemTraceCommentWithDriverVersionIsPutIntoAubStream) { + auto aubExecutionEnvironment = getEnvironment>(false, true, true); + auto aubCsr = aubExecutionEnvironment->template getCsr>(); + + std::unique_ptr mockAubFileStream(new GmockAubFileStream()); + GmockAubFileStream *mockAubFileStreamPtr = static_cast(mockAubFileStream.get()); + ASSERT_NE(nullptr, mockAubFileStreamPtr); + aubCsr->stream = mockAubFileStreamPtr; + + std::vector comments; + + EXPECT_CALL(*mockAubFileStreamPtr, addComment(_)).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool { + comments.push_back(std::string(str)); + return true; + })); + auto engineIndex = aubCsr->getEngineIndex(OCLRT::ENGINE_RCS); + aubCsr->initializeEngine(engineIndex); + +#define QTR(a) #a +#define TOSTR(b) QTR(b) + const std::string expectedVersion = TOSTR(NEO_DRIVER_VERSION); +#undef QTR +#undef TOSTR + + std::string commentWithDriverVersion = "driver version: " + expectedVersion; + EXPECT_EQ(commentWithDriverVersion, comments[0]); +} + HWTEST_F(AubFileStreamTests, givenAddPatchInfoCommentsCalledWhenNoPatchInfoDataObjectsThenCommentsAreEmpty) { auto aubExecutionEnvironment = getEnvironment>(false, true, true); auto aubCsr = aubExecutionEnvironment->template getCsr>();