From 9e6d3d93e791b7dea71fd1e8666191907804991a Mon Sep 17 00:00:00 2001 From: Daria Hinz Date: Thu, 24 Nov 2022 13:11:54 +0100 Subject: [PATCH] Fix ocloc decoder ULTs for IGA This PR fixes the decoder tests in ocloc to improve single SKUs. In tests, checking the existence of the platform in IGA has been added. Signed-off-by: Daria Hinz Related-To: NEO-7509 --- .../decoder/decoder_tests.cpp | 57 ++++++++++--------- .../decoder/encoder_tests.cpp | 7 ++- .../decoder/mock/mock_iga_wrapper.h | 7 +++ 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/opencl/test/unit_test/offline_compiler/decoder/decoder_tests.cpp b/opencl/test/unit_test/offline_compiler/decoder/decoder_tests.cpp index 5f7c9c4b84..45d124ccc3 100644 --- a/opencl/test/unit_test/offline_compiler/decoder/decoder_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/decoder/decoder_tests.cpp @@ -304,9 +304,6 @@ TEST(DecoderTests, givenDeprecatedDeviceNamesWhenValidateInputThenCorrectWarning MockDecoder decoder{suppressMessages}; auto deprecatedAcronyms = decoder.mockArgHelper->productConfigHelper->getDeprecatedAcronyms(); - if (deprecatedAcronyms.empty()) { - GTEST_SKIP(); - } for (const auto &acronym : deprecatedAcronyms) { const std::vector args = { @@ -326,29 +323,34 @@ TEST(DecoderTests, givenDeprecatedDeviceNamesWhenValidateInputThenCorrectWarning } } -TEST(DecoderTests, givenDeviceNamesWhenValidateInputThenSuccessIsReturned) { +TEST(DecoderTests, givenProductNamesThatExistsForIgaWhenValidateInputThenSuccessIsReturned) { constexpr auto suppressMessages{false}; MockDecoder decoder{suppressMessages}; - decoder.mockArgHelper->hasOutput = true; - - auto supportedAcronyms = decoder.mockArgHelper->productConfigHelper->getAllProductAcronyms(); - if (supportedAcronyms.empty()) { + if (!decoder.getMockIga()->isValidPlatform()) { GTEST_SKIP(); } - for (const auto &acronym : supportedAcronyms) { - const std::vector args = { - "ocloc", - "disasm", - "-device", - acronym.str()}; + decoder.mockArgHelper->hasOutput = true; + auto aotInfos = decoder.mockArgHelper->productConfigHelper->getDeviceAotInfo(); - ::testing::internal::CaptureStdout(); - const auto result = decoder.validateInput(args); - const auto output{::testing::internal::GetCapturedStdout()}; + for (const auto &device : aotInfos) { + if (productFamily != device.hwInfo->platform.eProductFamily) + continue; - EXPECT_EQ(result, 0); - EXPECT_TRUE(output.empty()); + for (const auto &acronym : device.acronyms) { + const std::vector args = { + "ocloc", + "disasm", + "-device", + acronym.str()}; + + ::testing::internal::CaptureStdout(); + const auto result = decoder.validateInput(args); + const auto output{::testing::internal::GetCapturedStdout()}; + + EXPECT_EQ(result, 0); + EXPECT_TRUE(output.empty()); + } } decoder.mockArgHelper->hasOutput = false; @@ -391,9 +393,13 @@ TEST(DecoderTests, GivenQuietModeFlagWhenParsingValidListOfParametersThenReturnV } TEST(DecoderTests, GivenMissingDumpFlagWhenParsingValidListOfParametersThenReturnValueIsZeroAndWarningAboutCreationOfDefaultDirectoryIsPrinted) { - if (gEnvironment->productConfig.empty()) { + constexpr auto suppressMessages{false}; + MockDecoder decoder{suppressMessages}; + + if (gEnvironment->productConfig.empty() || !decoder.getMockIga()->isValidPlatform()) { GTEST_SKIP(); } + const std::vector args = { "ocloc", "disasm", @@ -404,9 +410,6 @@ TEST(DecoderTests, GivenMissingDumpFlagWhenParsingValidListOfParametersThenRetur "-patch", "test_files/patch"}; - constexpr auto suppressMessages{false}; - MockDecoder decoder{suppressMessages}; - ::testing::internal::CaptureStdout(); const auto result = decoder.validateInput(args); const auto output{::testing::internal::GetCapturedStdout()}; @@ -418,7 +421,10 @@ TEST(DecoderTests, GivenMissingDumpFlagWhenParsingValidListOfParametersThenRetur } TEST(DecoderTests, GivenMissingDumpFlagAndArgHelperOutputEnabledWhenParsingValidListOfParametersThenReturnValueIsZeroAndDefaultDirectoryWarningIsNotEmitted) { - if (gEnvironment->productConfig.empty()) { + constexpr auto suppressMessages{false}; + MockDecoder decoder{suppressMessages}; + + if (gEnvironment->productConfig.empty() || !decoder.getMockIga()->isValidPlatform()) { GTEST_SKIP(); } const std::vector args = { @@ -430,8 +436,7 @@ TEST(DecoderTests, GivenMissingDumpFlagAndArgHelperOutputEnabledWhenParsingValid gEnvironment->productConfig.c_str(), "-patch", "test_files/patch"}; - constexpr auto suppressMessages{false}; - MockDecoder decoder{suppressMessages}; + decoder.mockArgHelper->hasOutput = true; ::testing::internal::CaptureStdout(); diff --git a/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp b/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp index 7e33e6eb21..637fd51819 100644 --- a/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp @@ -94,7 +94,10 @@ TEST(EncoderTests, GivenQuietModeFlagWhenParsingValidListOfParametersThenReturnV } TEST(EncoderTests, GivenMissingDumpFlagAndArgHelperOutputEnabledWhenParsingValidListOfParametersThenReturnValueIsZeroAndDefaultDirectoryIsNotUsedAsDumpPath) { - if (gEnvironment->productConfig.empty()) { + constexpr auto suppressMessages{false}; + MockEncoder encoder{suppressMessages}; + + if (gEnvironment->productConfig.empty() || !encoder.getMockIga()->isValidPlatform()) { GTEST_SKIP(); } const std::vector args = { @@ -106,8 +109,6 @@ TEST(EncoderTests, GivenMissingDumpFlagAndArgHelperOutputEnabledWhenParsingValid gEnvironment->productConfig.c_str(), }; - constexpr auto suppressMessages{false}; - MockEncoder encoder{suppressMessages}; encoder.mockArgHelper->hasOutput = true; ::testing::internal::CaptureStdout(); diff --git a/opencl/test/unit_test/offline_compiler/decoder/mock/mock_iga_wrapper.h b/opencl/test/unit_test/offline_compiler/decoder/mock/mock_iga_wrapper.h index c67a007b3b..4e53b7b844 100644 --- a/opencl/test/unit_test/offline_compiler/decoder/mock/mock_iga_wrapper.h +++ b/opencl/test/unit_test/offline_compiler/decoder/mock/mock_iga_wrapper.h @@ -11,6 +11,8 @@ #include #include +extern PRODUCT_FAMILY productFamily; + struct MockIgaWrapper : public IgaWrapper { bool tryDisassembleGenISA(const void *kernelPtr, uint32_t kernelSize, std::string &out) override { out = asmToReturn; @@ -39,6 +41,11 @@ struct MockIgaWrapper : public IgaWrapper { return true; } + bool isValidPlatform() { + setProductFamily(productFamily); + return isKnownPlatform(); + } + std::string asmToReturn; std::string binaryToReturn; std::string receivedAsm;