mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Add gdi system functions logging
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a6c1d9578e
commit
50a27bd48e
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -33,6 +33,7 @@ uint32_t mockFreadCalled = 0;
|
||||
size_t mockFreadReturn = 0;
|
||||
uint32_t mockFwriteCalled = 0;
|
||||
size_t mockFwriteReturn = 0;
|
||||
bool mockVfptrinfUseStdioFunction = false;
|
||||
|
||||
std::unordered_map<std::string, std::string> *mockableEnvValues = nullptr;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -28,6 +28,7 @@ extern uint32_t mockFreadCalled;
|
||||
extern size_t mockFreadReturn;
|
||||
extern uint32_t mockFwriteCalled;
|
||||
extern size_t mockFwriteReturn;
|
||||
extern bool mockVfptrinfUseStdioFunction;
|
||||
|
||||
extern std::unordered_map<std::string, std::string> *mockableEnvValues;
|
||||
|
||||
@@ -41,6 +42,9 @@ inline FILE *mockFopen(const char *filename, const char *mode) {
|
||||
|
||||
inline int mockVfptrinf(FILE *stream, const char *format, va_list arg) {
|
||||
mockVfptrinfCalled++;
|
||||
if (mockVfptrinfUseStdioFunction) {
|
||||
return vfprintf(stream, format, arg);
|
||||
}
|
||||
return 0x10;
|
||||
}
|
||||
|
||||
|
||||
@@ -425,6 +425,8 @@ DirectSubmissionReadBackCommandBuffer = -1
|
||||
DirectSubmissionReadBackRingBuffer = -1
|
||||
ReadBackCommandBufferAllocation = -1
|
||||
PrintImageBlitBlockCopyCmdDetails = 0
|
||||
LogGdiCalls = 0
|
||||
LogGdiCallsToFile = 0
|
||||
UseContextEndOffsetForEventCompletion = -1
|
||||
DirectSubmissionInsertExtraMiMemFenceCommands = -1
|
||||
DirectSubmissionInsertSfenceInstructionPriorToSubmission = -1
|
||||
|
||||
@@ -49,6 +49,10 @@ if(NOT NEO_SKIP_UNIT_TESTS)
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/includes${BRANCH_DIR_SUFFIX}
|
||||
)
|
||||
|
||||
if(UNIX AND NOT DISABLE_WDDM_LINUX)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${WDK_INCLUDE_PATHS})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(${TARGET_NAME} dbghelp)
|
||||
endif()
|
||||
|
||||
@@ -19,6 +19,12 @@ set(NEO_CORE_OS_INTERFACE_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_tests.cpp
|
||||
)
|
||||
|
||||
if(WIN32 OR(UNIX AND NOT DISABLE_WDDM_LINUX))
|
||||
list(APPEND NEO_CORE_OS_INTERFACE_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface_logging_tests.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_TESTS ${NEO_CORE_OS_INTERFACE_TESTS})
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_AUB_TESTS ${NEO_CORE_OS_INTERFACE_AUB_TESTS})
|
||||
|
||||
1321
shared/test/unit_test/os_interface/gdi_interface_logging_tests.cpp
Normal file
1321
shared/test/unit_test/os_interface/gdi_interface_logging_tests.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,11 @@
|
||||
#if defined(_WIN32)
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
#include "shared/source/os_interface/windows/gdi_interface.h"
|
||||
#include "shared/source/os_interface/windows/gdi_interface_logging.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||
#include "shared/test/common/mocks/windows/mock_gdi_interface.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -46,4 +50,52 @@ TEST(ThkWrapperTest, givenThkWrapperWhenConstructedThenmFuncIsInitialized) {
|
||||
NEO::ThkWrapper<void *> wrapper;
|
||||
EXPECT_EQ(nullptr, wrapper.mFunc);
|
||||
}
|
||||
|
||||
TEST(GdiInterface, GivenGdiLoggingSupportWhenLoggingEnabledAndLoggingToFileUsedThenExpectIoFunctionsUsed) {
|
||||
if (!GdiLogging::gdiLoggingSupport) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
VariableBackup<uint32_t> mockFopenCalledBackup(&NEO::IoFunctions::mockFopenCalled, 0);
|
||||
VariableBackup<uint32_t> mockFcloseCalledBackup(&NEO::IoFunctions::mockFcloseCalled, 0);
|
||||
VariableBackup<uint32_t> mockVfptrinfCalledBackup(&NEO::IoFunctions::mockVfptrinfCalled, 0);
|
||||
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.LogGdiCalls.set(true);
|
||||
DebugManager.flags.LogGdiCallsToFile.set(true);
|
||||
|
||||
std::unique_ptr<Gdi> gdi = std::make_unique<Gdi>();
|
||||
EXPECT_EQ(1u, NEO::IoFunctions::mockFopenCalled);
|
||||
|
||||
D3DKMT_OPENADAPTERFROMLUID param = {};
|
||||
gdi->openAdapterFromLuid(¶m);
|
||||
EXPECT_EQ(2u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
|
||||
gdi.reset(nullptr);
|
||||
EXPECT_EQ(1u, NEO::IoFunctions::mockFcloseCalled);
|
||||
}
|
||||
|
||||
TEST(GdiInterface, GivenGdiLoggingSupportWhenLoggingEnabledAndLoggingToFileNotUsedThenExpectIoFunctionsUsed) {
|
||||
if (!GdiLogging::gdiLoggingSupport) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
VariableBackup<uint32_t> mockFopenCalledBackup(&NEO::IoFunctions::mockFopenCalled, 0);
|
||||
VariableBackup<uint32_t> mockFcloseCalledBackup(&NEO::IoFunctions::mockFcloseCalled, 0);
|
||||
VariableBackup<uint32_t> mockVfptrinfCalledBackup(&NEO::IoFunctions::mockVfptrinfCalled, 0);
|
||||
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.LogGdiCalls.set(true);
|
||||
DebugManager.flags.LogGdiCallsToFile.set(false);
|
||||
|
||||
std::unique_ptr<Gdi> gdi = std::make_unique<Gdi>();
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFopenCalled);
|
||||
|
||||
D3DKMT_OPENADAPTERFROMLUID param = {};
|
||||
gdi->openAdapterFromLuid(¶m);
|
||||
EXPECT_EQ(2u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
|
||||
gdi.reset(nullptr);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFcloseCalled);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user