diff options
Diffstat (limited to 'examples/example-base/test-base.cpp')
| -rw-r--r-- | examples/example-base/test-base.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/example-base/test-base.cpp b/examples/example-base/test-base.cpp new file mode 100644 index 000000000..5c727aabe --- /dev/null +++ b/examples/example-base/test-base.cpp @@ -0,0 +1,50 @@ +#include "test-base.h" + +#ifdef _WIN32 +#include <windows.h> +#include <shellapi.h> +#endif + +int TestBase::parseOption(int argc, char** argv) +{ + // We only make the parse in a very loose way for only extracting the test option. +#ifdef _WIN32 + wchar_t** szArglist; + szArglist = CommandLineToArgvW(GetCommandLineW(), &argc); +#endif + + for (int i = 0; i < argc; i++) + { +#ifdef _WIN32 + if (wcscmp(szArglist[i], L"--test-mode") == 0) +#else + if (strcmp(argv[i], "--test-mode") == 0) +#endif + { + m_isTestMode = true; + } + } + return 0; +} + +void TestBase::printEntrypointHashes(int entryPointCount, int targetCount, ComPtr<slang::IComponentType>& composedProgram) +{ + for (int targetIndex = 0; targetIndex < targetCount; targetIndex++) + { + for (int entryPointIndex = 0; entryPointIndex < entryPointCount; entryPointIndex++) + { + ComPtr<slang::IBlob> entryPointHashBlob; + composedProgram->getEntryPointHash(entryPointIndex, targetIndex, entryPointHashBlob.writeRef()); + + Slang::StringBuilder strBuilder; + strBuilder << "entrypoint: "<< entryPointIndex << ", target: " << targetIndex << ", hash: "; + + uint8_t* buffer = (uint8_t*)entryPointHashBlob->getBufferPointer(); + for (size_t i = 0; i < entryPointHashBlob->getBufferSize(); i++) + { + strBuilder<<Slang::StringUtil::makeStringWithFormat("%.2X", buffer[i]); + } + fprintf(stdout, "%s\n", strBuilder.begin()); + } + } +} |
