From 50efd09ad80fe16d1bcf9063167bf9e294db2b2e Mon Sep 17 00:00:00 2001 From: Patryk Wrobel Date: Fri, 1 Apr 2022 16:37:48 +0000 Subject: [PATCH] Improve code coverage of binary encoder and decoder This change contains ULTs, which improve the coverage of BinaryEncoder and BinaryDecoder classes. Related-To: NEO-6834 Signed-off-by: Patryk Wrobel --- .../decoder/decoder_tests.cpp | 192 +++++++++++++++++- .../decoder/encoder_tests.cpp | 131 +++++++++++- .../decoder/mock/mock_decoder.h | 51 +++-- .../decoder/mock/mock_encoder.h | 57 ++++-- .../decoder/mock/mock_iga_wrapper.h | 5 +- .../mock/mock_argument_helper.h | 3 + .../source/decoder/binary_decoder.cpp | 2 +- .../source/decoder/binary_decoder.h | 8 +- 8 files changed, 400 insertions(+), 49 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 362925b467..160d532aee 100644 --- a/opencl/test/unit_test/offline_compiler/decoder/decoder_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/decoder/decoder_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/offline_compiler/source/decoder/translate_platform_base.h" #include "shared/source/helpers/array_count.h" #include "shared/test/common/helpers/test_files.h" @@ -12,9 +13,13 @@ #include "opencl/test/unit_test/test_files/patch_list.h" #include "gtest/gtest.h" +#include "igad.h" +#include "igfxfmid.h" #include "mock/mock_decoder.h" +#include #include +#include SProgramBinaryHeader createProgramBinaryHeader(const uint32_t numberOfKernels, const uint32_t patchListSize) { return SProgramBinaryHeader{MAGIC_CL, 0, 0, 0, numberOfKernels, 0, patchListSize}; @@ -30,8 +35,9 @@ SKernelBinaryHeaderCommon createKernelBinaryHeaderCommon(const uint32_t kernelNa } namespace NEO { + TEST(DecoderTests, WhenParsingValidListOfParametersThenReturnValueIsZero) { - std::vector args = { + const std::vector args = { "ocloc", "decoder", "-file", @@ -45,6 +51,117 @@ TEST(DecoderTests, WhenParsingValidListOfParametersThenReturnValueIsZero) { EXPECT_EQ(0, decoder.validateInput(args)); } +TEST(DecoderTests, GivenFlagsWhichRequireMoreArgsWithoutThemWhenParsingThenErrorIsReported) { + const std::array flagsToTest = { + "-file", "-device", "-patch", "-dump"}; + + for (const auto &flag : flagsToTest) { + const std::vector args = { + "ocloc", + "decoder", + flag}; + + constexpr auto suppressMessages{false}; + MockDecoder decoder{suppressMessages}; + + ::testing::internal::CaptureStdout(); + const auto result = decoder.validateInput(args); + const auto output{::testing::internal::GetCapturedStdout()}; + + EXPECT_EQ(-1, result); + + const std::string expectedErrorMessage{"Unknown argument " + flag + "\n"}; + EXPECT_EQ(expectedErrorMessage, output); + } +} + +TEST(DecoderTests, GivenIgnoreIsaPaddingFlagWhenParsingValidListOfParametersThenReturnValueIsZeroAndInternalFlagIsSet) { + const std::vector args = { + "ocloc", + "decoder", + "-file", + "test_files/binary.bin", + "-patch", + "test_files/patch", + "-dump", + "test_files/created", + "-ignore_isa_padding"}; + + MockDecoder decoder; + EXPECT_EQ(0, decoder.validateInput(args)); + EXPECT_TRUE(decoder.ignoreIsaPadding); +} + +TEST(DecoderTests, GivenQuietModeFlagWhenParsingValidListOfParametersThenReturnValueIsZeroAndMessagesAreSuppressed) { + const std::vector args = { + "ocloc", + "decoder", + "-file", + "test_files/binary.bin", + "-patch", + "test_files/patch", + "-dump", + "test_files/created", + "-q"}; + + constexpr auto suppressMessages{false}; + MockDecoder decoder{suppressMessages}; + + EXPECT_EQ(0, decoder.validateInput(args)); + EXPECT_TRUE(decoder.argHelper->getPrinterRef().isSuppressed()); +} + +TEST(DecoderTests, GivenMissingDumpFlagWhenParsingValidListOfParametersThenReturnValueIsZeroAndWarningAboutCreationOfDefaultDirectoryIsPrinted) { + const std::vector args = { + "ocloc", + "decoder", + "-file", + "test_files/binary.bin", + "-device", + "pvc", + "-patch", + "test_files/patch"}; + + constexpr auto suppressMessages{false}; + MockDecoder decoder{suppressMessages}; + decoder.getMockIga()->isKnownPlatformReturnValue = true; + + ::testing::internal::CaptureStdout(); + const auto result = decoder.validateInput(args); + const auto output{::testing::internal::GetCapturedStdout()}; + + EXPECT_EQ(0, result); + + const std::string expectedErrorMessage{"Warning : Path to dump folder not specificed - using ./dump as default.\n"}; + EXPECT_EQ(expectedErrorMessage, output); +} + +TEST(DecoderTests, GivenMissingDumpFlagAndArgHelperOutputEnabledWhenParsingValidListOfParametersThenReturnValueIsZeroAndDefaultDirectoryWarningIsNotEmitted) { + const std::vector args = { + "ocloc", + "decoder", + "-file", + "test_files/binary.bin", + "-device", + "pvc", + "-patch", + "test_files/patch"}; + + constexpr auto suppressMessages{false}; + MockDecoder decoder{suppressMessages}; + decoder.mockArgHelper->hasOutput = true; + decoder.getMockIga()->isKnownPlatformReturnValue = true; + + ::testing::internal::CaptureStdout(); + const auto result = decoder.validateInput(args); + const auto output{::testing::internal::GetCapturedStdout()}; + + EXPECT_EQ(0, result); + EXPECT_TRUE(output.empty()) << output; + + decoder.mockArgHelper->hasOutput = false; +} + TEST(DecoderTests, GivenValidSizeStringWhenGettingSizeThenProperOutcomeIsExpectedAndExceptionIsNotThrown) { MockDecoder decoder; EXPECT_EQ(static_cast(1), decoder.getSize("uint8_t")); @@ -301,4 +418,77 @@ TEST(DecoderTests, givenPatchtokensBinaryFormatWhenTryingToGetDevBinaryThenRawDa std::string dataString(static_cast(data), dataSize); EXPECT_STREQ("CTNI\n\n\n\n\n\n\n", dataString.c_str()); } + +TEST(DecoderHelperTest, GivenTextSeparatedByTabsWhenSearchingForExistingTextThenItsIndexIsReturned) { + const std::vector lines = {"Some\tNice\tText"}; + const auto position = findPos(lines, "Nice"); + + EXPECT_EQ(0u, position); +} + +TEST(DecoderHelperTest, GivenTextSeparatedByNewLinesWhenSearchingForExistingTextThenItsIndexIsReturned) { + const std::vector lines = {"Some\nNice\nText"}; + const auto position = findPos(lines, "Nice"); + + EXPECT_EQ(0u, position); +} + +TEST(DecoderHelperTest, GivenTextSeparatedByCarriageReturnWhenSearchingForExistingTextThenItsIndexIsReturned) { + const std::vector lines = {"Some\rNice\rText"}; + const auto position = findPos(lines, "Nice"); + + EXPECT_EQ(0u, position); +} + +TEST(DecoderHelperTest, GivenOnlyMatchingSubstringWhenSearchingForExistingTextThenInvalidIndexIsReturned) { + const std::vector lines = {"Carpet"}; + const auto position = findPos(lines, "Car"); + + EXPECT_EQ(lines.size(), position); +} + +TEST(DecoderHelperTest, GivenPathEndedBySlashWhenCallingAddSlashThenNothingIsDone) { + std::string path{"./some/path/"}; + addSlash(path); + + EXPECT_EQ("./some/path/", path); +} + +TEST(DecoderHelperTest, GivenPathEndedByBackSlashWhenCallingAddSlashThenNothingIsDone) { + std::string path{".\\some\\path\\"}; + addSlash(path); + + EXPECT_EQ(".\\some\\path\\", path); +} + +TEST(DecoderHelperTest, GivenGfxCoreFamilyWhenTranslatingToIgaGenBaseThenExpectedIgaGenBaseIsReturned) { + constexpr static std::array translations = { + std::pair{IGFX_GEN8_CORE, IGA_GEN8}, + std::pair{IGFX_GEN9_CORE, IGA_GEN9}, + std::pair{IGFX_GEN11_CORE, IGA_GEN11}, + std::pair{IGFX_GEN11LP_CORE, IGA_GEN11}, + std::pair{IGFX_UNKNOWN_CORE, IGA_GEN_INVALID}}; + + for (const auto &[input, expectedOutput] : translations) { + EXPECT_EQ(expectedOutput, translateToIgaGen(input)); + } +} + +TEST(DecoderHelperTest, GivenProductFamilyWhenTranslatingToIgaGenBaseThenExpectedIgaGenBaseIsReturned) { + constexpr static std::array translations = { + std::pair{IGFX_BROADWELL, IGA_GEN8}, + std::pair{IGFX_CHERRYVIEW, IGA_GEN8lp}, + std::pair{IGFX_SKYLAKE, IGA_GEN9}, + std::pair{IGFX_BROXTON, IGA_GEN9lp}, + std::pair{IGFX_KABYLAKE, IGA_GEN9p5}, + std::pair{IGFX_COFFEELAKE, IGA_GEN9p5}, + std::pair{IGFX_ICELAKE, IGA_GEN11}, + std::pair{IGFX_ICELAKE_LP, IGA_GEN11}, + std::pair{IGFX_UNKNOWN, IGA_GEN_INVALID}}; + + for (const auto &[input, expectedOutput] : translations) { + EXPECT_EQ(expectedOutput, translateToIgaGen(input)); + } +} + } // namespace NEO 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 9bd90cc470..f7fc21e931 100644 --- a/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/decoder/encoder_tests.cpp @@ -12,11 +12,14 @@ #include "gtest/gtest.h" #include "mock/mock_encoder.h" +#include #include +#include namespace NEO { + TEST(EncoderTests, WhenParsingValidListOfParametersThenReturnValueIsZero) { - std::vector args = { + const std::vector args = { "ocloc", "asm", "-dump", @@ -28,6 +31,130 @@ TEST(EncoderTests, WhenParsingValidListOfParametersThenReturnValueIsZero) { EXPECT_EQ(0, encoder.validateInput(args)); } +TEST(EncoderTests, GivenFlagsWhichRequireMoreArgsWithoutThemWhenParsingThenErrorIsReported) { + const std::array flagsToTest = { + "-dump", "-device", "-out"}; + + for (const auto &flag : flagsToTest) { + const std::vector args = { + "ocloc", + "asm", + flag}; + + constexpr auto suppressMessages{false}; + MockEncoder encoder{suppressMessages}; + + ::testing::internal::CaptureStdout(); + const auto result = encoder.validateInput(args); + const auto output{::testing::internal::GetCapturedStdout()}; + + EXPECT_EQ(-1, result); + + const std::string expectedErrorMessage{"Unknown argument " + flag + "\n"}; + EXPECT_EQ(expectedErrorMessage, output); + } +} + +TEST(EncoderTests, GivenIgnoreIsaPaddingFlagWhenParsingValidListOfParametersThenReturnValueIsZeroAndInternalFlagIsSet) { + const std::vector args = { + "ocloc", + "asm", + "-dump", + "test_files/dump", + "-out", + "test_files/binary_gen.bin", + "-ignore_isa_padding"}; + + MockEncoder encoder; + EXPECT_EQ(0, encoder.validateInput(args)); + EXPECT_TRUE(encoder.ignoreIsaPadding); +} + +TEST(EncoderTests, GivenQuietModeFlagWhenParsingValidListOfParametersThenReturnValueIsZeroAndMessagesAreSuppressed) { + const std::vector args = { + "ocloc", + "asm", + "-dump", + "test_files/dump", + "-out", + "test_files/binary_gen.bin", + "-q"}; + + constexpr auto suppressMessages{false}; + MockEncoder encoder{suppressMessages}; + + EXPECT_EQ(0, encoder.validateInput(args)); + EXPECT_TRUE(encoder.argHelper->getPrinterRef().isSuppressed()); +} + +TEST(EncoderTests, GivenMissingDumpFlagAndArgHelperOutputEnabledWhenParsingValidListOfParametersThenReturnValueIsZeroAndDefaultDirectoryIsNotUsedAsDumpPath) { + const std::vector args = { + "ocloc", + "asm", + "-out", + "test_files/binary_gen.bin", + "-device", + "pvc"}; + + constexpr auto suppressMessages{false}; + MockEncoder encoder{suppressMessages}; + encoder.mockArgHelper->hasOutput = true; + encoder.getMockIga()->isKnownPlatformReturnValue = true; + + ::testing::internal::CaptureStdout(); + const auto result = encoder.validateInput(args); + const auto output{::testing::internal::GetCapturedStdout()}; + + EXPECT_EQ(0, result); + EXPECT_TRUE(output.empty()) << output; + EXPECT_TRUE(encoder.pathToDump.empty()) << encoder.pathToDump; + + encoder.mockArgHelper->hasOutput = false; +} + +TEST(EncoderTests, GivenMissingPTMFileWhenEncodingThenErrorIsReturnedAndLogIsPrinted) { + constexpr auto suppressMessages{false}; + MockEncoder encoder{suppressMessages}; + + ::testing::internal::CaptureStdout(); + const auto result = encoder.encode(); + const auto output{::testing::internal::GetCapturedStdout()}; + + EXPECT_EQ(-1, result); + EXPECT_EQ("Error! Couldn't find PTM.txt", output); +} + +TEST(EncoderTests, GivenMissingSourceFileWhenTryingToCopyBinaryThenErrorIsReturned) { + MockEncoder encoder; + encoder.callBaseCopyBinaryToBinary = true; + + std::stringstream outputStream; + EXPECT_FALSE(encoder.copyBinaryToBinary("bad_source.bin", outputStream, nullptr)); +} + +TEST(EncoderTests, GivenValidSourceFileWhenTryingToCopyBinaryThenItIsCopied) { + MockEncoder encoder; + encoder.callBaseCopyBinaryToBinary = true; + encoder.filesMap["good_source.bin"] = "TEXT!"; + + std::stringstream outputStream; + ASSERT_TRUE(encoder.copyBinaryToBinary("good_source.bin", outputStream, nullptr)); + EXPECT_EQ("TEXT!", outputStream.str()); +} + +TEST(EncoderTests, GivenValidSourceFileAndOutputLengthArgumentWhenTryingToCopyBinaryThenItIsCopiedAndLengthIsSet) { + MockEncoder encoder; + encoder.callBaseCopyBinaryToBinary = true; + encoder.filesMap["good_source.bin"] = "TEXT!"; + + std::stringstream outputStream; + uint32_t outputLength{}; + ASSERT_TRUE(encoder.copyBinaryToBinary("good_source.bin", outputStream, &outputLength)); + + EXPECT_EQ("TEXT!", outputStream.str()); + EXPECT_EQ(5u, outputLength); +} + TEST(EncoderTests, WhenMissingParametersThenErrorCodeIsReturned) { std::vector args = { "ocloc", @@ -449,4 +576,4 @@ TEST(EncoderTests, WhenProcessingDeviceBinaryAndAsmIsAvailableThenAseembleItWith EXPECT_EQ(encoder.filesMap["kernel_KernelHeap.asm"], encoder.getMockIga()->receivedAsm); } -} // namespace NEO +} // namespace NEO \ No newline at end of file diff --git a/opencl/test/unit_test/offline_compiler/decoder/mock/mock_decoder.h b/opencl/test/unit_test/offline_compiler/decoder/mock/mock_decoder.h index e2505d2cee..ca1acd83e4 100644 --- a/opencl/test/unit_test/offline_compiler/decoder/mock/mock_decoder.h +++ b/opencl/test/unit_test/offline_compiler/decoder/mock/mock_decoder.h @@ -8,38 +8,51 @@ #pragma once #include "shared/offline_compiler/source/decoder/binary_decoder.h" +#include "opencl/test/unit_test/offline_compiler/mock/mock_argument_helper.h" + #include "mock_iga_wrapper.h" -struct MockDecoder : public BinaryDecoder { - MockDecoder() : MockDecoder("", "", "") { - } - MockDecoder(const std::string &file, const std::string &patch, const std::string &dump) - : BinaryDecoder(file, patch, dump) { - this->iga.reset(new MockIgaWrapper); - oclocArgHelperWithoutInput = std::make_unique(); - argHelper = oclocArgHelperWithoutInput.get(); - argHelper->getPrinterRef() = MessagePrinter(true); - }; - using BinaryDecoder::argHelper; - using BinaryDecoder::binaryFile; +#include +#include +#include + +class MockDecoder : public BinaryDecoder { + public: using BinaryDecoder::decode; using BinaryDecoder::getDevBinary; using BinaryDecoder::getSize; - using BinaryDecoder::iga; - using BinaryDecoder::kernelHeader; using BinaryDecoder::parseTokens; - using BinaryDecoder::patchTokens; - using BinaryDecoder::pathToDump; - using BinaryDecoder::pathToPatch; using BinaryDecoder::processBinary; using BinaryDecoder::processKernel; - using BinaryDecoder::programHeader; using BinaryDecoder::readPatchTokens; using BinaryDecoder::readStructFields; - std::unique_ptr oclocArgHelperWithoutInput; + using BinaryDecoder::argHelper; + using BinaryDecoder::binaryFile; + using BinaryDecoder::iga; + using BinaryDecoder::ignoreIsaPadding; + using BinaryDecoder::kernelHeader; + using BinaryDecoder::patchTokens; + using BinaryDecoder::pathToDump; + using BinaryDecoder::pathToPatch; + using BinaryDecoder::programHeader; + + MockDecoder(bool suppressMessages = true) : MockDecoder("", "", "") { + argHelper->getPrinterRef() = MessagePrinter(suppressMessages); + } + + MockDecoder(const std::string &file, const std::string &patch, const std::string &dump) + : BinaryDecoder(file, patch, dump) { + this->iga.reset(new MockIgaWrapper); + + mockArgHelper = std::make_unique(filesMap); + argHelper = mockArgHelper.get(); + } MockIgaWrapper *getMockIga() const { return static_cast(iga.get()); } + + std::map filesMap{}; + std::unique_ptr mockArgHelper{}; }; diff --git a/opencl/test/unit_test/offline_compiler/decoder/mock/mock_encoder.h b/opencl/test/unit_test/offline_compiler/decoder/mock/mock_encoder.h index 5d9b7730e8..a43acf33b7 100644 --- a/opencl/test/unit_test/offline_compiler/decoder/mock/mock_encoder.h +++ b/opencl/test/unit_test/offline_compiler/decoder/mock/mock_encoder.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -16,45 +16,58 @@ #include #include -struct MockEncoder : public BinaryEncoder { - MockEncoder() : MockEncoder("", ""){}; +class MockEncoder : public BinaryEncoder { + public: + using BinaryEncoder::addPadding; + using BinaryEncoder::calculatePatchListSizes; + using BinaryEncoder::copyBinaryToBinary; + using BinaryEncoder::createElf; + using BinaryEncoder::encode; + using BinaryEncoder::processBinary; + using BinaryEncoder::processKernel; + using BinaryEncoder::write; + using BinaryEncoder::writeDeviceBinary; + + using BinaryEncoder::argHelper; + using BinaryEncoder::elfName; + using BinaryEncoder::iga; + using BinaryEncoder::ignoreIsaPadding; + using BinaryEncoder::pathToDump; + + MockEncoder(bool suppressMessages = true) : MockEncoder("", "") { + argHelper->getPrinterRef() = MessagePrinter(suppressMessages); + } + MockEncoder(const std::string &dump, const std::string &elf) : BinaryEncoder(dump, elf) { this->iga.reset(new MockIgaWrapper); - oclocArgHelperWithoutInput = std::make_unique(filesMap); - argHelper = oclocArgHelperWithoutInput.get(); - argHelper->getPrinterRef() = MessagePrinter(true); - }; - std::map filesMap; + mockArgHelper = std::make_unique(filesMap); + argHelper = mockArgHelper.get(); + } bool copyBinaryToBinary(const std::string &srcFileName, std::ostream &outBinary, uint32_t *binaryLength) override { + if (callBaseCopyBinaryToBinary) { + return BinaryEncoder::copyBinaryToBinary(srcFileName, outBinary, binaryLength); + } + auto it = filesMap.find(srcFileName); if (it == filesMap.end()) { return false; } + outBinary.write(it->second.c_str(), it->second.size()); if (binaryLength != nullptr) { *binaryLength = static_cast(it->second.size()); } return true; } - using BinaryEncoder::addPadding; - using BinaryEncoder::calculatePatchListSizes; - using BinaryEncoder::copyBinaryToBinary; - using BinaryEncoder::createElf; - using BinaryEncoder::elfName; - using BinaryEncoder::encode; - using BinaryEncoder::iga; - using BinaryEncoder::pathToDump; - using BinaryEncoder::processBinary; - using BinaryEncoder::processKernel; - using BinaryEncoder::write; - using BinaryEncoder::writeDeviceBinary; - - std::unique_ptr oclocArgHelperWithoutInput; MockIgaWrapper *getMockIga() const { return static_cast(iga.get()); } + + std::map filesMap{}; + std::unique_ptr mockArgHelper{}; + bool callBaseCopyBinaryToBinary{false}; }; 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 d185c7c7b7..68f90c9dbe 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -33,7 +33,7 @@ struct MockIgaWrapper : public IgaWrapper { } bool isKnownPlatform() const override { - return false; + return isKnownPlatformReturnValue; } bool tryLoadIga() override { @@ -47,4 +47,5 @@ struct MockIgaWrapper : public IgaWrapper { bool disasmWasCalled = false; bool asmWasCalled = false; + bool isKnownPlatformReturnValue = false; }; diff --git a/opencl/test/unit_test/offline_compiler/mock/mock_argument_helper.h b/opencl/test/unit_test/offline_compiler/mock/mock_argument_helper.h index 96ba8897ed..e3e32bd9f3 100644 --- a/opencl/test/unit_test/offline_compiler/mock/mock_argument_helper.h +++ b/opencl/test/unit_test/offline_compiler/mock/mock_argument_helper.h @@ -14,10 +14,13 @@ #include #include +#include #include class MockOclocArgHelper : public OclocArgHelper { public: + using OclocArgHelper::hasOutput; + using FileName = std::string; using FileData = std::string; using FilesMap = std::map; diff --git a/shared/offline_compiler/source/decoder/binary_decoder.cpp b/shared/offline_compiler/source/decoder/binary_decoder.cpp index 776e10340e..263f2e735a 100644 --- a/shared/offline_compiler/source/decoder/binary_decoder.cpp +++ b/shared/offline_compiler/source/decoder/binary_decoder.cpp @@ -553,4 +553,4 @@ int BinaryDecoder::validateInput(const std::vector &args) { MakeDirectory(pathToDump.c_str()); } return 0; -} +} \ No newline at end of file diff --git a/shared/offline_compiler/source/decoder/binary_decoder.h b/shared/offline_compiler/source/decoder/binary_decoder.h index 5d5a761e26..7b0e0887af 100644 --- a/shared/offline_compiler/source/decoder/binary_decoder.h +++ b/shared/offline_compiler/source/decoder/binary_decoder.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -34,9 +34,13 @@ class BinaryDecoder { public: BinaryDecoder(const std::string &file, const std::string &patch, const std::string &dump) : binaryFile(file), pathToPatch(patch), pathToDump(dump){}; + BinaryDecoder(OclocArgHelper *helper) : argHelper(helper), iga(new IgaWrapper) { iga->setMessagePrinter(argHelper->getPrinterRef()); - }; + } + + MOCKABLE_VIRTUAL ~BinaryDecoder() = default; + int decode(); int validateInput(const std::vector &args);