From 3b93e2315604814eebecec27dafcd736c972dbf7 Mon Sep 17 00:00:00 2001 From: Mateusz Hoppe Date: Wed, 24 Sep 2025 09:30:17 +0000 Subject: [PATCH] test: improve test coverage - in decodeSingleDeviceBinary() - in ImplicitArgs Signed-off-by: Mateusz Hoppe --- .../zebin_decoder_tests.cpp | 58 +++++++++++++++++++ .../kernel/implicit_args_helper_tests.cpp | 4 ++ 2 files changed, 62 insertions(+) diff --git a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp index 24776d77d4..d55cc3377f 100644 --- a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp +++ b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp @@ -6817,6 +6817,64 @@ TEST_F(IntelGTNotesFixture, GivenIndirectAccessBufferVersionInIntelGTNotesWhenVa EXPECT_EQ(indirectAccessBufferMajorVersion, programInfo.indirectAccessBufferMajorVersion); } +TEST_F(IntelGTNotesFixture, GivenFailFromValidateTargetDeviceWhenDecodingBinaryThenInvalidBinaryReturend) { + + MockExecutionEnvironment executionEnvironment; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + compilerProductHelper.adjustHwInfoForIgc(hwInfo); + TargetDevice targetDevice = getTargetDevice(rootDeviceEnvironment); + if (zebin.elfHeader->identity.eClass == NEO::Elf::EI_CLASS_64) { + targetDevice.maxPointerSizeInBytes = 8; + } + + { + std::vector elfNoteSections; + for (int i = 0; i < 2; i++) { + auto &inserted = elfNoteSections.emplace_back(); + inserted.descSize = 4u; + inserted.nameSize = 8u; + } + + elfNoteSections.at(0).type = Zebin::Elf::IntelGTSectionType::productFamily; + elfNoteSections.at(1).type = Zebin::Elf::IntelGTSectionType::productConfig; + + std::vector descData; + + uint8_t productFamilyData[4] = {0}; + descData.push_back(productFamilyData); + + uint8_t productConfigData[4] = {0}; + descData.push_back(productConfigData); + + const auto sectionDataSize = std::accumulate(elfNoteSections.begin(), elfNoteSections.end(), size_t{0u}, + [](auto totalSize, const auto &elfNoteSection) { + return totalSize + sizeof(NEO::Elf::ElfNoteSection) + elfNoteSection.nameSize + elfNoteSection.descSize; + }); + auto noteIntelGTSectionData = std::make_unique(sectionDataSize); + appendIntelGTSectionData(elfNoteSections, noteIntelGTSectionData.get(), descData, sectionDataSize); + zebin.appendSection(NEO::Elf::SHT_NOTE, Zebin::Elf::SectionNames::noteIntelGT, ArrayRef::fromAny(noteIntelGTSectionData.get(), sectionDataSize)); + } + + std::string outErrReason, outWarning; + auto elf = Zebin::Elf::decodeElf(zebin.storage, outErrReason, outWarning); + SingleDeviceBinary singleDeviceBinary{}; + singleDeviceBinary.targetDevice = targetDevice; + + EXPECT_FALSE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, singleDeviceBinary.generatorFeatureVersions, singleDeviceBinary.generator)); + + NEO::MockExecutionEnvironment mockExecutionEnvironment{}; + auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + NEO::ProgramInfo programInfo; + singleDeviceBinary.deviceBinary = {zebin.storage.data(), zebin.storage.size()}; + + std::string errors; + std::string warnings; + auto error = NEO::decodeSingleDeviceBinary(programInfo, singleDeviceBinary, errors, warnings, gfxCoreHelper); + EXPECT_EQ(NEO::DecodeError::invalidBinary, error); +} + TEST_F(IntelGTNotesFixture, GivenNotNullTerminatedVersioningStringWhenGettingIntelGTNotesThenEmitWarningAndDontUseIt) { Zebin::Elf::ElfNoteSection elfNoteSection = {}; elfNoteSection.type = 4; diff --git a/shared/test/unit_test/kernel/implicit_args_helper_tests.cpp b/shared/test/unit_test/kernel/implicit_args_helper_tests.cpp index ca30bd876a..f046cec487 100644 --- a/shared/test/unit_test/kernel/implicit_args_helper_tests.cpp +++ b/shared/test/unit_test/kernel/implicit_args_helper_tests.cpp @@ -246,6 +246,8 @@ TEST(ImplicitArgsV0Test, givenImplicitArgsV0WhenSettingFieldsThenCorrectFieldsAr EXPECT_EQ(0xff000u, implicitArgs.v0.printfBufferPtr); EXPECT_EQ(16u, implicitArgs.v0.numWorkDim); EXPECT_EQ(0x1000123400u, implicitArgs.v0.rtGlobalBufferPtr); + + EXPECT_EQ(32u, implicitArgs.getSimdWidth().value()); } TEST(ImplicitArgsV1Test, givenImplicitArgsV1WhenSettingFieldsThenCorrectFieldsAreSet) { @@ -295,6 +297,8 @@ TEST(ImplicitArgsV1Test, givenImplicitArgsV1WhenSettingFieldsThenCorrectFieldsAr EXPECT_EQ(16u, implicitArgs.v1.numWorkDim); EXPECT_EQ(0x1000123400u, implicitArgs.v1.rtGlobalBufferPtr); EXPECT_EQ(0x1234000u, implicitArgs.v1.syncBufferPtr); + + EXPECT_EQ(32u, implicitArgs.getSimdWidth().value()); } TEST(ImplicitArgsV2Test, givenImplicitArgsV2WhenSettingFieldsThenCorrectFieldsAreSet) {