Skip to content

Commit 10e4e62

Browse files
Don't use DEFAULT_PLATFORM in unit tests
testing for default supported platform may be disabled Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 4b0d986 commit 10e4e62

File tree

6 files changed

+27
-19
lines changed

6 files changed

+27
-19
lines changed

opencl/test/unit_test/command_stream/get_devices_tests.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -11,6 +11,7 @@
1111
#include "shared/source/os_interface/device_factory.h"
1212
#include "shared/source/os_interface/hw_info_config.h"
1313
#include "shared/test/common/helpers/debug_manager_state_restore.h"
14+
#include "shared/test/common/helpers/default_hw_info.h"
1415
#include "shared/test/common/helpers/ult_hw_config.h"
1516
#include "shared/test/common/helpers/variable_backup.h"
1617
#include "shared/test/common/libult/create_command_stream.h"
@@ -228,14 +229,14 @@ HWTEST_F(PrepareDeviceEnvironmentsTest, givenPrepareDeviceEnvironmentsAndUnknown
228229
}
229230
EXPECT_TRUE(i < IGFX_MAX_PRODUCT);
230231
ASSERT_NE(nullptr, hardwarePrefix[i]);
231-
HardwareInfo defaultHwInfo = DEFAULT_PLATFORM::hwInfo;
232-
defaultHwInfo.featureTable = {};
233-
defaultHwInfo.workaroundTable = {};
234-
defaultHwInfo.gtSystemInfo = {};
235-
hardwareInfoSetup[defaultHwInfo.platform.eProductFamily](&defaultHwInfo, true, 0x0);
236-
HwInfoConfig *hwConfig = HwInfoConfig::get(defaultHwInfo.platform.eProductFamily);
237-
hwConfig->configureHardwareCustom(&defaultHwInfo, nullptr);
238-
EXPECT_EQ(0, memcmp(&defaultHwInfo.platform, &hwInfo->platform, sizeof(PLATFORM)));
232+
HardwareInfo baseHwInfo = *defaultHwInfo;
233+
baseHwInfo.featureTable = {};
234+
baseHwInfo.workaroundTable = {};
235+
baseHwInfo.gtSystemInfo = {};
236+
hardwareInfoSetup[baseHwInfo.platform.eProductFamily](&baseHwInfo, true, 0x0);
237+
HwInfoConfig *hwConfig = HwInfoConfig::get(baseHwInfo.platform.eProductFamily);
238+
hwConfig->configureHardwareCustom(&baseHwInfo, nullptr);
239+
EXPECT_EQ(0, memcmp(&baseHwInfo.platform, &hwInfo->platform, sizeof(PLATFORM)));
239240
break;
240241
}
241242
default:

opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,19 +644,19 @@ TEST_F(OfflineCompilerTests, givenVariousClStdValuesWhenCompilingSourceThenCorre
644644
mockOfflineCompiler->initialize(argv.size(), argv);
645645

646646
std::string internalOptions = mockOfflineCompiler->internalOptions;
647-
std::string oclVersionOption = getOclVersionCompilerInternalOption(DEFAULT_PLATFORM::hwInfo.capabilityTable.clVersionSupport);
647+
std::string oclVersionOption = getOclVersionCompilerInternalOption(mockOfflineCompiler->hwInfo.capabilityTable.clVersionSupport);
648648
EXPECT_THAT(internalOptions, ::testing::HasSubstr(oclVersionOption));
649649

650650
if (clStdOptionValue == "-cl-std=CL2.0") {
651651
auto expectedRegex = std::string{"cl_khr_3d_image_writes"};
652-
if (DEFAULT_PLATFORM::hwInfo.capabilityTable.supportsImages) {
652+
if (mockOfflineCompiler->hwInfo.capabilityTable.supportsImages) {
653653
expectedRegex += ".+" + std::string{"cl_khr_3d_image_writes"};
654654
}
655655
EXPECT_THAT(internalOptions, ::testing::ContainsRegex(expectedRegex));
656656
}
657657

658658
OpenClCFeaturesContainer openclCFeatures;
659-
getOpenclCFeaturesList(DEFAULT_PLATFORM::hwInfo, openclCFeatures);
659+
getOpenclCFeaturesList(mockOfflineCompiler->hwInfo, openclCFeatures);
660660
for (auto &feature : openclCFeatures) {
661661
if (clStdOptionValue == "-cl-std=CL3.0") {
662662
EXPECT_THAT(internalOptions, ::testing::HasSubstr(std::string{feature.name}));
@@ -665,7 +665,7 @@ TEST_F(OfflineCompilerTests, givenVariousClStdValuesWhenCompilingSourceThenCorre
665665
}
666666
}
667667

668-
if (DEFAULT_PLATFORM::hwInfo.capabilityTable.supportsImages) {
668+
if (mockOfflineCompiler->hwInfo.capabilityTable.supportsImages) {
669669
EXPECT_THAT(internalOptions, ::testing::HasSubstr(CompilerOptions::enableImageSupport.data()));
670670
} else {
671671
EXPECT_THAT(internalOptions, ::testing::Not(::testing::HasSubstr(CompilerOptions::enableImageSupport.data())));
@@ -1244,7 +1244,7 @@ TEST(OfflineCompilerTest, WhenGeneratingElfBinaryThenBinaryIsCreated) {
12441244
memset(&binHeader, 0, sizeof(binHeader));
12451245
binHeader.Magic = iOpenCL::MAGIC_CL;
12461246
binHeader.Version = iOpenCL::CURRENT_ICBE_VERSION - 3;
1247-
binHeader.Device = DEFAULT_PLATFORM::hwInfo.platform.eRenderCoreFamily;
1247+
binHeader.Device = mockOfflineCompiler->hwInfo.platform.eRenderCoreFamily;
12481248
binHeader.GPUPointerSizeInBytes = 8;
12491249
binHeader.NumberOfKernels = 0;
12501250
binHeader.SteppingId = 0;
@@ -1984,7 +1984,7 @@ TEST(OclocCompile, givenDeviceAndInternalOptionsOptionWhenCompilingToSpirvThenIn
19841984
ASSERT_EQ(0, retVal);
19851985
retVal = ocloc.build();
19861986
EXPECT_EQ(0, retVal);
1987-
std::string regexToMatch = "\\-ocl\\-version=" + std::to_string(DEFAULT_PLATFORM::hwInfo.capabilityTable.clVersionSupport) +
1987+
std::string regexToMatch = "\\-ocl\\-version=" + std::to_string(ocloc.hwInfo.capabilityTable.clVersionSupport) +
19881988
"0 \\-cl\\-ext=\\-all.* \\-cl\\-ext=\\+custom_param";
19891989
EXPECT_THAT(ocloc.internalOptions, ::testing::ContainsRegex(regexToMatch));
19901990
}

shared/source/dll/get_devices.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 Intel Corporation
2+
* Copyright (C) 2019-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -52,5 +52,7 @@ bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment) {
5252
bool prepareDeviceEnvironment(ExecutionEnvironment &executionEnvironment, std::string &osPciPath, const uint32_t rootDeviceIndex) {
5353
return prepareDeviceEnvironments(executionEnvironment, osPciPath, rootDeviceIndex);
5454
}
55-
55+
const HardwareInfo *getDefaultHwInfo() {
56+
return &DEFAULT_PLATFORM::hwInfo;
57+
}
5658
} // namespace NEO

shared/source/os_interface/device_factory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bool DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(ExecutionE
3030
executionEnvironment.prepareRootDeviceEnvironments(numRootDevices);
3131

3232
auto productFamily = DebugManager.flags.ProductFamilyOverride.get();
33-
const HardwareInfo *hwInfoConst = &DEFAULT_PLATFORM::hwInfo;
33+
const HardwareInfo *hwInfoConst = getDefaultHwInfo();
3434
getHwInfoForPlatformString(productFamily, hwInfoConst);
3535
std::string hwInfoConfigStr;
3636
uint64_t hwInfoConfig = 0x0;

shared/source/os_interface/device_factory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace NEO {
1515

1616
class ExecutionEnvironment;
1717
class Device;
18+
struct HardwareInfo;
19+
const HardwareInfo *getDefaultHwInfo();
1820
bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment);
1921
bool prepareDeviceEnvironment(ExecutionEnvironment &executionEnvironment, std::string &osPciPath, const uint32_t rootDeviceIndex);
2022
class DeviceFactory {

shared/test/common/libult/create_command_stream.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -66,5 +66,8 @@ bool prepareDeviceEnvironment(ExecutionEnvironment &executionEnvironment, std::s
6666

6767
return prepareDeviceEnvironmentImpl(executionEnvironment, osPciPath, rootDeviceIndex);
6868
}
69+
const HardwareInfo *getDefaultHwInfo() {
70+
return defaultHwInfo.get();
71+
}
6972

7073
} // namespace NEO

0 commit comments

Comments
 (0)