diff --git a/level_zero/core/source/dll/linux/CMakeLists.txt b/level_zero/core/source/dll/linux/CMakeLists.txt index e646edaa4a..9106e69b4d 100644 --- a/level_zero/core/source/dll/linux/CMakeLists.txt +++ b/level_zero/core/source/dll/linux/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 Intel Corporation +# Copyright (C) 2020-2021 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -7,6 +7,7 @@ set(L0_SRCS_DLL_LINUX ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0_linux.cpp + ${NEO_SOURCE_DIR}/level_zero/tools/source/debug${BRANCH_DIR_SUFFIX}/linux/debug_session_linux_helper.cpp ) set_property(GLOBAL PROPERTY L0_SRCS_DLL_LINUX ${L0_SRCS_DLL_LINUX}) diff --git a/level_zero/core/test/unit_tests/CMakeLists.txt b/level_zero/core/test/unit_tests/CMakeLists.txt index ce4ecbabef..524a9d4683 100644 --- a/level_zero/core/test/unit_tests/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/CMakeLists.txt @@ -31,6 +31,7 @@ add_executable(${TARGET_NAME} ${NEO_SOURCE_DIR}/shared/test/common/mocks/ult_device_factory.h ${L0_CORE_ENABLERS} ${NEO_SOURCE_DIR}/opencl/test/unit_test/global_environment.cpp + ${NEO_SOURCE_DIR}/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp ${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/kernel_binary_helper_hash_value.cpp ) diff --git a/level_zero/experimental/test/unit_tests/CMakeLists.txt b/level_zero/experimental/test/unit_tests/CMakeLists.txt index 1ba2a2ddd9..a717689f8e 100644 --- a/level_zero/experimental/test/unit_tests/CMakeLists.txt +++ b/level_zero/experimental/test/unit_tests/CMakeLists.txt @@ -36,6 +36,7 @@ add_executable( ${NEO_SOURCE_DIR}/opencl/test/unit_test/global_environment.cpp ${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/kernel_binary_helper_hash_value.cpp ${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests/sources/builtin/create_ult_builtin_functions_lib.cpp + ${NEO_SOURCE_DIR}/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp ) target_sources( diff --git a/level_zero/tools/source/debug/linux/debug_session_linux_helper.cpp b/level_zero/tools/source/debug/linux/debug_session_linux_helper.cpp new file mode 100644 index 0000000000..b1f3aac3ec --- /dev/null +++ b/level_zero/tools/source/debug/linux/debug_session_linux_helper.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/tools/source/debug/debug_session.h" +#include +namespace L0 { + +DebugSession *createDebugSessionHelper(const zet_debug_config_t &config, Device *device, int debugFd) { + return nullptr; +} + +} // namespace L0 \ No newline at end of file diff --git a/level_zero/tools/test/unit_tests/CMakeLists.txt b/level_zero/tools/test/unit_tests/CMakeLists.txt index 352701ac2f..3c3ddcb695 100644 --- a/level_zero/tools/test/unit_tests/CMakeLists.txt +++ b/level_zero/tools/test/unit_tests/CMakeLists.txt @@ -38,6 +38,7 @@ target_sources(${TARGET_NAME} PRIVATE ${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests/ult_configuration.cpp ${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests/white_box.h ${NEO_SOURCE_DIR}/level_zero/core/source/dll/create_builtin_functions_lib.cpp + ${NEO_SOURCE_DIR}/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp ${NEO_SHARED_TEST_DIRECTORY}/unit_test/tests_configuration.h ) diff --git a/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp b/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp new file mode 100644 index 0000000000..192640dbf2 --- /dev/null +++ b/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h" +#include +namespace L0 { + +DebugSession *createDebugSessionHelper(const zet_debug_config_t &config, Device *device, int debugFd) { + return new L0::ult::DebugSessionMock(config, device); +} + +} // namespace L0 \ No newline at end of file diff --git a/level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h b/level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h index 4df47e250d..37edfa7676 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h +++ b/level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h @@ -6,6 +6,7 @@ */ #pragma once +#include "shared/source/os_interface/os_interface.h" #include "level_zero/tools/source/debug/debug_session.h" @@ -23,11 +24,15 @@ class OsInterfaceWithDebugAttach : public NEO::OSInterface { }; struct DebugSessionMock : public L0::DebugSession { - DebugSessionMock(const zet_debug_config_t &config, L0::Device *device) : DebugSession(config, device){}; + DebugSessionMock(const zet_debug_config_t &config, L0::Device *device) : DebugSession(config, device), config(config){}; bool closeConnection() override { return true; } ze_result_t initialize() override { + if (config.pid == 0) { + return ZE_RESULT_ERROR_UNKNOWN; + } return ZE_RESULT_SUCCESS; } + zet_debug_config_t config; }; } // namespace ult diff --git a/opencl/test/unit_test/linux/main_linux_dll.cpp b/opencl/test/unit_test/linux/main_linux_dll.cpp index b9cba832f6..a935aa5d73 100644 --- a/opencl/test/unit_test/linux/main_linux_dll.cpp +++ b/opencl/test/unit_test/linux/main_linux_dll.cpp @@ -11,6 +11,7 @@ #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/os_interface/linux/allocator_helper.h" #include "shared/source/os_interface/linux/os_interface.h" +#include "shared/source/os_interface/linux/sys_calls.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.inl" #include "shared/test/common/helpers/ult_hw_config.inl" @@ -534,6 +535,15 @@ TEST_F(DrmTests, givenDrmIsCreatedWhenCreateVirtualMemoryFailsThenReturnVirtualM ::testing::internal::GetCapturedStdout(); } +TEST(SysCalls, WhenSysCallsPollCalledThenCallIsRedirectedToOs) { + struct pollfd pollFd; + pollFd.fd = 0; + pollFd.events = 0; + + auto result = NEO::SysCalls::poll(&pollFd, 1, 0); + EXPECT_EQ(0, result); +} + int main(int argc, char **argv) { bool useDefaultListener = false; diff --git a/opencl/test/unit_test/os_interface/linux/sys_calls_linux_ult.cpp b/opencl/test/unit_test/os_interface/linux/sys_calls_linux_ult.cpp index 5c846e20f0..29105c086a 100644 --- a/opencl/test/unit_test/os_interface/linux/sys_calls_linux_ult.cpp +++ b/opencl/test/unit_test/os_interface/linux/sys_calls_linux_ult.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -118,5 +119,10 @@ int getDevicePath(int deviceFd, char *buf, size_t &bufSize) { return 0; } + +int poll(struct pollfd *pollFd, unsigned long int numberOfFds, int timeout) { + return 0; +} + } // namespace SysCalls } // namespace NEO diff --git a/shared/source/os_interface/linux/sys_calls.h b/shared/source/os_interface/linux/sys_calls.h index 00f95c28c1..c3cf1aa721 100644 --- a/shared/source/os_interface/linux/sys_calls.h +++ b/shared/source/os_interface/linux/sys_calls.h @@ -6,8 +6,8 @@ */ #pragma once - #include +#include namespace NEO { namespace SysCalls { @@ -18,5 +18,6 @@ int ioctl(int fileDescriptor, unsigned long int request, void *arg); int getDevicePath(int deviceFd, char *buf, size_t &bufSize); int access(const char *pathname, int mode); int readlink(const char *path, char *buf, size_t bufsize); +int poll(struct pollfd *pollFd, unsigned long int numberOfFds, int timeout); } // namespace SysCalls } // namespace NEO diff --git a/shared/source/os_interface/linux/sys_calls_linux.cpp b/shared/source/os_interface/linux/sys_calls_linux.cpp index 1b9175703c..0d84a2eb8f 100644 --- a/shared/source/os_interface/linux/sys_calls_linux.cpp +++ b/shared/source/os_interface/linux/sys_calls_linux.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -51,5 +52,9 @@ int getDevicePath(int deviceFd, char *buf, size_t &bufSize) { return 0; } + +int poll(struct pollfd *pollFd, unsigned long int numberOfFds, int timeout) { + return ::poll(pollFd, numberOfFds, timeout); +} } // namespace SysCalls } // namespace NEO