diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-12-12 08:57:48 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-12 08:57:48 -0500 |
| commit | 49ed6b60d662906f290578f802f80b0ead1a2b9d (patch) | |
| tree | e47050f6508a4b3a4d38b756e9b3c53e0d159507 /tools/render-test/options.cpp | |
| parent | 62d3e387774255be4d507cca045ac97dabac9970 (diff) | |
Running tests in slang-test process (#740)
* First pass at having an interface to write text to that can be replaced.
Simplifed and made more rigerous the interface used to write formatted strings.
* Added AppContext to simplify setting up and parsing around of streams.
* Added more simplified way to get the std error/out from AppContext.
* Work in progress using dll for tools to speed up testing.
* First pass at ISlangWriter interface.
* Added support for writing VaArgs.
Added NullWriter.
* Use ISlangWriter for output.
* Use ISlangWriter for output - replacing OutputCallback.
Make IRDump go to ISlangWriter
* SlangWriterTargetType -> SlangWriterChannel
Improvements around AppContext
* Shared library working with slang-reflection-test.
* Dll testing working for render-test.
* Include va_list definintion from header.
* Fix errors from clang.
* Fix typo for linux.
* Added -usexes option
* Fix typo.
* Fix arguments problem on linux.
* Fix typo for linux.
* Add windows tool shared library projects.
* Fix warning from x86 win build.
Fix signed warning from slang-test/main.cpp
* First attempt at getting premake to work on travis, and run tests.
* Try moving build out into script.
* Invoke bash scripts so they don't have to be executable.
* Drive configuration/tests from env parameters set by travis
* Try using source to run travis tests.
* Remove the build.linux directory - but doing so will overwrite Makefile.
* Made -fno-delete-null-pointer-checks gcc only.
* Try to fix warning from -fno-delete-null-pointer-checks
* Turn of warnings for unknown switches.
* Try to make premake choose the correct tooling.
* Disabled missing braces warning.
* Disable -Wundefined-var-template on clang.
* -Wunused-function disabled for clang.
* Fix typo due to SlangBool.
* Remove this nullptr tests.
* "-Wno-unused-private-field" for clang.
* Added "-Wno-undefined-bool-conversion"
* Add DominatorList::end fix.
* Split scripts into travis_build.sh travis_test.sh
* Fix gcc/clang template pre-declaration issue around QualType.
* Fix premake to build such that pthread correctly links with slang-glslang
Diffstat (limited to 'tools/render-test/options.cpp')
| -rw-r--r-- | tools/render-test/options.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/tools/render-test/options.cpp b/tools/render-test/options.cpp index d99ba355e..bd5640020 100644 --- a/tools/render-test/options.cpp +++ b/tools/render-test/options.cpp @@ -6,8 +6,12 @@ #include <stdlib.h> #include <string.h> +#include "../../source/core/slang-writer.h" + namespace renderer_test { +static const Options gDefaultOptions; + Options gOptions; // Only set it, if the @@ -16,17 +20,20 @@ void setDefaultRendererType(RendererType type) gOptions.rendererType = (gOptions.rendererType == RendererType::Unknown) ? type : gOptions.rendererType; } -SlangResult parseOptions(int* argc, char** argv) +SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper stdError) { + // Reset the options + gOptions = gDefaultOptions; + + List<const char*> positionalArgs; + typedef Options::ShaderProgramType ShaderProgramType; typedef Options::InputLanguageID InputLanguageID; + //int argCount = argc; - int argCount = *argc; char const* const* argCursor = argv; - char const* const* argEnd = argCursor + argCount; - - char const** writeCursor = (char const**) argv; + char const* const* argEnd = argCursor + argc; // first argument is the application name if( argCursor != argEnd ) @@ -40,7 +47,7 @@ SlangResult parseOptions(int* argc, char** argv) char const* arg = *argCursor++; if( arg[0] != '-' ) { - *writeCursor++ = arg; + positionalArgs.Add(arg); continue; } @@ -48,8 +55,7 @@ SlangResult parseOptions(int* argc, char** argv) { while(argCursor != argEnd) { - char const* arg = *argCursor++; - *writeCursor++ = arg; + positionalArgs.Add(*argCursor++); } break; } @@ -57,7 +63,7 @@ SlangResult parseOptions(int* argc, char** argv) { if( argCursor == argEnd ) { - fprintf(stderr, "expected argument for '%s' option\n", arg); + stdError.print("expected argument for '%s' option\n", arg); return SLANG_FAIL; } gOptions.outputPath = *argCursor++; @@ -98,12 +104,12 @@ SlangResult parseOptions(int* argc, char** argv) if( argCursor == argEnd ) { - fprintf(stderr, "expected argument for '%s' option\n", arg); + stdError.print("expected argument for '%s' option\n", arg); return SLANG_FAIL; } if( gOptions.slangArgCount == Options::kMaxSlangArgs ) { - fprintf(stderr, "maximum number of '%s' options exceeded (%d)\n", arg, Options::kMaxSlangArgs); + stdError.print("maximum number of '%s' options exceeded (%d)\n", arg, Options::kMaxSlangArgs); return SLANG_FAIL; } gOptions.slangArgs[gOptions.slangArgCount++] = *argCursor++; @@ -145,30 +151,26 @@ SlangResult parseOptions(int* argc, char** argv) } else { - fprintf(stderr, "unknown option '%s'\n", arg); + stdError.print("unknown option '%s'\n", arg); return SLANG_FAIL; } } - // any arguments left over were positional arguments - argCount = (int)(writeCursor - (const char**)argv); - argCursor = argv; - argEnd = argCursor + argCount; - + // first positional argument is source shader path - if( argCursor != argEnd ) + if(positionalArgs.Count()) { - gOptions.sourcePath = *argCursor++; + gOptions.sourcePath = positionalArgs[0]; + positionalArgs.RemoveAt(0); } // any remaining arguments represent an error - if(argCursor != argEnd) + if(positionalArgs.Count() != 0) { - fprintf(stderr, "unexpected arguments\n"); + stdError.print("unexpected arguments\n"); return SLANG_FAIL; } - *argc = 0; return SLANG_OK; } |
