mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Add CpuInfo::isCpuFlagPresent() method
Related-To: NEO-5276 Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
efcd05d7bd
commit
92f067b9aa
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -23,3 +23,5 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/timer_util_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vec_tests.cpp
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
16
shared/test/unit_test/utilities/linux/CMakeLists.txt
Normal file
16
shared/test/unit_test/utilities/linux/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(UTILITIES_CPUINFO_TESTS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_linux.cpp
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${UTILITIES_CPUINFO_TESTS_LINUX}
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/utilities/cpu_info.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(CpuInfo, givenProcCpuinfoFileExistsWhenIsCpuFlagPresentIsCalledThenValidValueIsReturned) {
|
||||
std::string cpuinfoFile = "test_files/linux/proc/cpuinfo";
|
||||
EXPECT_TRUE(fileExists(cpuinfoFile));
|
||||
|
||||
CpuInfo testCpuInfo;
|
||||
EXPECT_TRUE(testCpuInfo.isCpuFlagPresent("fpu"));
|
||||
EXPECT_TRUE(testCpuInfo.isCpuFlagPresent("vme"));
|
||||
EXPECT_FALSE(testCpuInfo.isCpuFlagPresent("nonExistingCpuFlag"));
|
||||
}
|
||||
16
shared/test/unit_test/utilities/windows/CMakeLists.txt
Normal file
16
shared/test/unit_test/utilities/windows/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(UTILITIES_CPUINFO_TESTS_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo_tests_windows.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${UTILITIES_CPUINFO_TESTS_WINDOWS}
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/utilities/cpu_info.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(CpuInfo, givenIsCpuFlagPresentCalledThenFalseIsReturned) {
|
||||
CpuInfo testCpuInfo;
|
||||
|
||||
EXPECT_FALSE(testCpuInfo.isCpuFlagPresent("fpu"));
|
||||
EXPECT_FALSE(testCpuInfo.isCpuFlagPresent("vme"));
|
||||
EXPECT_FALSE(testCpuInfo.isCpuFlagPresent("nonExistingCpuFlag"));
|
||||
}
|
||||
Reference in New Issue
Block a user