summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-10-21 15:32:13 -0400
committerGitHub <noreply@github.com>2019-10-21 15:32:13 -0400
commit5ca446888656da91165b7bf90b7b2195d1e1afac (patch)
tree893a03930bc706089f28c156032ffe883ea0d2a1 /tools
parenta854bf2fde6e466aa698f4132971faadc827913a (diff)
`Repro` functionality (#1085)
* WIP on serialize/save state. * Relative string encoding. * Added RelativeContainer unit test. Split out RelativeContainer into core. * Fix bug in RelativeString encoding. * More work around relative container. * Fix checks. * Use RelativeBase for safe access. Use malloc/free/realloc instead of List. * Add natvis support for relative types. * Setting up of state (not includes) writing of repro state. * Capture after spCompile. * Writing SourceFile and file system files. Added -dump-repo * First pass at loading state. * First pass at reading repro. * Small optimization around Safe32Ptr * Refactor how repro data is stored - to make saving off the files more simple, by having all all backed by 'files'. Make file loading always set up PathInfo so we get uniqueIdentifier info. * Generate unique file names. * Added RelativeFileSystem Added saveFile to ISlangFileSystemExt and implemented for interfaces Added mechanism to save of files (and manifest) * Added ability to replace files in repo with directory holding their contents. * Add support for entry points. * Fix problem compiling on linux. * Added SIMPLE_EX option, where everything on command line must be specified. * Fix typo in unit test for relative container. * Fix another typo in unit test for RelativeContainer. * Fix small bugs. * Fix release unused variable issue in slang-state-serialize.cpp * Fix checking for SIMPLE_EX in testing, else broke COMMAND_LINE_SIMPLE. * Fix warnings on 32 bit debug build. * Added import-subdir-search-path-repro.slang test. Although disabled for now as writes to root of slang project. * Remove wrong version of import-subdir-search-path-repro.slang * Added import-subdir-search-path-repro.slang
Diffstat (limited to 'tools')
-rw-r--r--tools/render-test/cpu-memory-binding.cpp4
-rw-r--r--tools/slang-test/slang-test-main.cpp6
-rw-r--r--tools/slang-test/slang-test.vcxproj1
-rw-r--r--tools/slang-test/slang-test.vcxproj.filters3
-rw-r--r--tools/slang-test/unit-relative-container.cpp94
5 files changed, 105 insertions, 3 deletions
diff --git a/tools/render-test/cpu-memory-binding.cpp b/tools/render-test/cpu-memory-binding.cpp
index 24d16756d..be4ad96e7 100644
--- a/tools/render-test/cpu-memory-binding.cpp
+++ b/tools/render-test/cpu-memory-binding.cpp
@@ -338,7 +338,7 @@ CPUMemoryBinding::Location CPUMemoryBinding::Location::toIndex(int index) const
if (elementCount == 0)
{
CPPPrelude::Array<uint8_t>& array = *(CPPPrelude::Array<uint8_t>*)cur;
- if (index < array.count)
+ if (index < int(array.count))
{
return Location(elementTypeLayout, array.data + elementStride * index);
}
@@ -592,7 +592,7 @@ SlangResult CPUMemoryBinding::setArrayCount(const Location& location, int count,
// Making smaller, just reduce the count.
// NOTE! Nothing is done here about deallocating resources which are perhaps no longer reachable.
// This isn't a leakage problem tho, as all buffers are released automatically when scope is left.
- if (count <= array.count)
+ if (count <= int(array.count))
{
array.count = count;
return SLANG_OK;
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index e1309d01f..79e810224 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -1004,7 +1004,10 @@ TestResult runSimpleTest(TestContext* context, TestInput& input)
CommandLine cmdLine;
_initSlangCompiler(context, cmdLine);
- cmdLine.addArg(input.filePath);
+ if (input.testOptions->command != "SIMPLE_EX")
+ {
+ cmdLine.addArg(input.filePath);
+ }
for( auto arg : input.testOptions->args )
{
@@ -2384,6 +2387,7 @@ struct TestCommandInfo
static const TestCommandInfo s_testCommandInfos[] =
{
{ "SIMPLE", &runSimpleTest},
+ { "SIMPLE_EX", &runSimpleTest},
{ "REFLECTION", &runReflectionTest},
{ "CPU_REFLECTION", &runReflectionTest},
{ "COMMAND_LINE_SIMPLE", &runSimpleCompareCommandLineTest},
diff --git a/tools/slang-test/slang-test.vcxproj b/tools/slang-test/slang-test.vcxproj
index 8f6096f86..d1326d655 100644
--- a/tools/slang-test/slang-test.vcxproj
+++ b/tools/slang-test/slang-test.vcxproj
@@ -175,6 +175,7 @@
<ClCompile Include="slangc-tool.cpp" />
<ClCompile Include="test-context.cpp" />
<ClCompile Include="test-reporter.cpp" />
+ <ClCompile Include="unit-relative-container.cpp" />
<ClCompile Include="unit-test-byte-encode.cpp" />
<ClCompile Include="unit-test-free-list.cpp" />
<ClCompile Include="unit-test-memory-arena.cpp" />
diff --git a/tools/slang-test/slang-test.vcxproj.filters b/tools/slang-test/slang-test.vcxproj.filters
index e5cd23212..9bf6f9b26 100644
--- a/tools/slang-test/slang-test.vcxproj.filters
+++ b/tools/slang-test/slang-test.vcxproj.filters
@@ -44,6 +44,9 @@
<ClCompile Include="test-reporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="unit-relative-container.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="unit-test-byte-encode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/tools/slang-test/unit-relative-container.cpp b/tools/slang-test/unit-relative-container.cpp
new file mode 100644
index 000000000..4ecd18dba
--- /dev/null
+++ b/tools/slang-test/unit-relative-container.cpp
@@ -0,0 +1,94 @@
+// unit-test-path.cpp
+
+#include "../../source/core/slang-relative-container.h"
+
+#include "test-context.h"
+
+using namespace Slang;
+
+static void _checkEncodeDecode(uint32_t size)
+{
+ uint8_t encode[RelativeString::kMaxSizeEncodeSize];
+
+ size_t encodeSize = RelativeString::calcEncodedSize(size, encode);
+
+ size_t decodedSize;
+ const char* chars = RelativeString::decodeSize((const char*)encode, decodedSize);
+
+ SLANG_CHECK(decodedSize == size);
+ SLANG_CHECK(chars - (const char*)encode == encodeSize);
+}
+
+namespace { // anonymous
+
+struct Root
+{
+ Relative32Array<Relative32Ptr<RelativeString> > dirs;
+ Relative32Ptr<RelativeString> name;
+ float value;
+};
+
+} // anonymous
+
+static void relativeContainerUnitTest()
+{
+ _checkEncodeDecode(253);
+
+ for (int64_t i = 0; i < 0x100000000; i += (i / 2) + 1)
+ {
+ _checkEncodeDecode(uint32_t(i));
+ }
+
+ {
+ RelativeContainer container;
+
+ const char* strings[] =
+ {
+ "Hello",
+ "World",
+ nullptr,
+ };
+
+ {
+ Safe32Ptr<Root> root = container.allocate<Root>();
+
+ auto array = container.allocateArray<Relative32Ptr<RelativeString>>(SLANG_COUNT_OF(strings));
+ for (Int i = 0; i < SLANG_COUNT_OF(strings); ++i)
+ {
+ array[i] = container.newString(strings[i]);
+ }
+
+ root->dirs = array;
+ }
+
+ {
+ RelativeContainer copy;
+ copy.set(container.getData(), container.getDataCount());
+
+ Root* root = (Root*)copy.getData();
+
+ SLANG_CHECK(root->dirs.getCount() == SLANG_COUNT_OF(strings));
+
+ Int count = root->dirs.getCount();
+ for (Int i = 0; i < count; ++i)
+ {
+ RelativeString* str = root->dirs[i];
+
+ const char* check = strings[i];
+
+ if (check)
+ {
+ SLANG_CHECK(str != nullptr);
+ const char* strCstr = str->getCstr();
+ SLANG_CHECK(strcmp(strCstr, check) == 0);
+ }
+ else
+ {
+ SLANG_CHECK(str == nullptr);
+ }
+ }
+ }
+ }
+}
+
+SLANG_UNIT_TEST("RelativeContainer", relativeContainerUnitTest);